:root,
[data-theme="dark-blue"] {
  --bg: #0b0e14;
  --bg-panel: #131722;
  --bg-card: #171c2b;
  --bg-deep: #05070d;
  --border: #262c3d;
  --text: #e6e9f0;
  --text-dim: #8892a6;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --green: #33d17a;
  --red: #ff5c5c;
  --yellow: #ffcc4d;
  --gray: #6b7280;
}

/* Тема, вдохновлённая панелью youtube-shorts-live: тёмная с красным акцентом */
[data-theme="dark-red"] {
  --bg: #0e1013;
  --bg-panel: #121519;
  --bg-card: #171a1f;
  --bg-deep: #0a0c0f;
  --border: #2b2f36;
  --text: #f3f4f6;
  --text-dim: #9ba3af;
  --accent: #fa5d54;
  --accent-ink: #1a0d0c;
  --green: #73d9aa;
  --red: #ff958e;
  --yellow: #f0c576;
  --gray: #6b7280;
}

/* Светлая тема */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-deep: #eef0f3;
  --border: #e0e3e9;
  --text: #171a21;
  --text-dim: #6b7280;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --green: #1a9d5c;
  --red: #dc3c33;
  --yellow: #b07d05;
  --gray: #8a909b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  margin-bottom: 30px;
  padding: 0 8px;
}
.brand span { color: var(--accent); }

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 12px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-btn:hover { background: var(--bg-card); color: var(--text); }
.nav-btn.active { background: var(--accent); color: var(--accent-ink); }

.logout-btn {
  margin-top: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); }

.content {
  flex: 1;
  padding: 30px 36px;
  max-width: 1200px;
}

h1 { font-size: 22px; margin-bottom: 20px; }

.tab { display: none; }
.tab.active { display: block; }

.server-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat-tile .value { font-size: 20px; font-weight: 600; margin-top: 4px; }

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.stream-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.stream-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.stream-card h3 { margin: 0; font-size: 16px; }

.status-badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.status-ONLINE { background: rgba(51,209,122,.15); color: var(--green); }
.status-OFFLINE { background: rgba(107,114,128,.2); color: var(--gray); }
.status-STARTING { background: rgba(255,204,77,.15); color: var(--yellow); }
.status-STOPPING { background: rgba(255,204,77,.15); color: var(--yellow); }
.status-ERROR { background: rgba(255,92,92,.15); color: var(--red); }

.stream-meta { font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.stream-meta b { color: var(--text); font-weight: 500; }
.stream-meta .err { color: var(--red); }

.card-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

button {
  font-family: inherit;
}

.btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: rgba(255,92,92,.12); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: var(--accent-ink); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.upload-row { display: flex; gap: 10px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.disk-space { font-size: 13px; color: var(--text-dim); }

.theme-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}
.theme-swatch:hover { border-color: var(--accent); }
.theme-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.swatch-dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.swatch-dark-blue { background: linear-gradient(135deg, #0b0e14 50%, #5b8cff 50%); }
.swatch-dark-red { background: linear-gradient(135deg, #0e1013 50%, #fa5d54 50%); }
.swatch-light { background: linear-gradient(135deg, #f4f5f7 50%, #2f6fed 50%); }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.progress-bar { flex: 1; height: 8px; background: var(--bg-panel); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width .2s; }

.video-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.video-table th, .video-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.video-table th { color: var(--text-dim); font-weight: 500; text-transform: uppercase; font-size: 11px; }

.muted { color: var(--text-dim); font-size: 13px; }

.playlist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 8px;
  margin: 6px 0;
}
.row-index { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 18px; }
.row-title { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.row-title small { display: block; color: var(--text-dim); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn { padding: 6px 10px; font-size: 12px; }

.check-label { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin: 10px 0 16px; }
.check-label input { width: 18px; margin: 0; }

.live-dot { color: var(--green); font-size: 10px; vertical-align: middle; }

input, select {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  margin: 6px 0 12px;
  font-size: 14px;
}

label { font-size: 12px; color: var(--text-dim); }

.form-msg { font-size: 13px; margin-top: 8px; }
.form-msg.error { color: var(--red); }
.form-msg.success { color: var(--green); }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }

.log-view {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
}
.login-logo { font-weight: 700; font-size: 24px; text-align: center; margin-bottom: 24px; }
.login-logo span { color: var(--accent); }
.login-error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 12px; }
  .brand { margin-bottom: 0; margin-right: 14px; white-space: nowrap; }
  nav { display: flex; }
  .logout-btn { margin-top: 0; margin-left: auto; white-space: nowrap; }
  .content { padding: 20px; }
}
