:root {
  --bg: #06070a;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f5f9;
  --muted: #8b8f9e;
  --muted-dim: #5d616e;
  --accent: #0ea2ff;
  --accent-2: #7c5cff;
  --accent-soft: rgba(14, 162, 255, 0.16);
  --green: #3ddc97;
  --amber: #ffc24d;
  --radius: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient-a, .ambient-b { position: absolute; border-radius: 50%; filter: blur(110px); opacity: 0.36; }
.ambient-a { width: 46vw; height: 46vw; top: -20vw; right: -8vw; background: radial-gradient(circle, var(--accent), transparent 68%); }
.ambient-b { width: 42vw; height: 42vw; bottom: -22vw; left: -10vw; background: radial-gradient(circle, #2a6bff, transparent 70%); opacity: 0.22; }

/* ------------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: 11px; font-weight: 650; letter-spacing: 0.26em; font-size: 13px; text-transform: uppercase; }
.brand-logo { height: 24px; width: auto; display: block; flex: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; display: block; flex: none; box-shadow: 0 0 22px -6px var(--accent); }
.brand-x {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ------------------------------------------------------------------- auth */
.auth-overlay {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  background: rgba(12, 14, 20, 0.92);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 34px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(18px);
}
.auth-card .brand { justify-content: center; }
.auth-card .brand-logo { height: 60px; }
.auth-card h1 { font-size: 24px; margin: 26px 0 6px; letter-spacing: -0.02em; }
.auth-card .muted { margin-bottom: 22px; }
.auth-card form { display: grid; gap: 14px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.auth-foot a { color: var(--accent-2); }

.auth-tabs {
  display: flex; gap: 5px; margin: 20px 0 18px; padding: 5px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, 0.22);
}
.auth-tab {
  flex: 1; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--panel-strong); color: var(--text); }
.auth-card form[hidden] { display: none; }
.auth-check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 12.5px; line-height: 1.45; color: var(--muted);
}
.auth-check input { width: auto; margin-top: 2px; accent-color: var(--accent); }
.auth-check a { color: var(--accent-2); }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: rgba(8, 9, 14, 0.6);
  backdrop-filter: blur(12px);
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px; border: 1px solid transparent;
  background: none; color: var(--muted); cursor: pointer; text-align: left;
  font-size: 13.5px; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-soft); border-color: rgba(14, 162, 255, 0.32); color: var(--text); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #13080b;
}
.who-text { display: grid; min-width: 0; }
.who-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }

.main { min-width: 0; padding: 30px clamp(20px, 3.2vw, 48px) 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(24px, 2.6vw, 34px); letter-spacing: -0.025em; }
.page-head .muted { margin-top: 5px; }
.page-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--panel-strong); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; text-decoration: none; line-height: 1.1;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: rgba(255,255,255,0.11); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent; color: #190a0d; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel); }
.btn.danger { background: rgba(255, 77, 109, 0.14); border-color: rgba(255, 77, 109, 0.4); color: #ff8fa2; }
.btn.danger:hover { background: rgba(255, 77, 109, 0.22); }
.btn.small { padding: 7px 11px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1;
}
.icon-btn:hover { color: var(--text); background: var(--panel); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field > span small { text-transform: none; letter-spacing: 0; color: var(--muted-dim); font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.24);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(14, 162, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(14, 162, 255, 0.15);
}
.field-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.field.narrow input { min-width: 0; }
.form-error { color: #ff8fa2; font-size: 12.5px; min-height: 1em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.search { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); min-width: 240px; }
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search input { background: none; border: 0; outline: none; width: 100%; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .muted { margin-right: auto; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); margin-right: auto; }
.segmented button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.segmented button.active { background: var(--panel-strong); color: var(--text); }

/* --------------------------------------------------------------- overview */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); backdrop-filter: blur(8px);
}
.stat-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; }
.stat-hint { font-size: 12px; color: var(--muted-dim); margin-top: 4px; }
.stat-grid.compact .stat { padding: 14px; }
.stat-grid.compact .stat-value { font-size: 24px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; letter-spacing: -0.01em; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
.pill.live { color: var(--green); border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.09); }
.pill.draft { color: var(--amber); border-color: rgba(255, 194, 77, 0.35); background: rgba(255, 194, 77, 0.08); }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 9px 10px; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-dim); border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: rgba(255,255,255,0.03); }
.table .num { font-variant-numeric: tabular-nums; color: var(--muted); }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- stations */
.station-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.station-card {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.station-card:hover { border-color: var(--line-strong); background: var(--panel-strong); transform: translateY(-1px); }
.station-card img { width: 88px; height: 88px; border-radius: 12px; object-fit: cover; background: #12141c; }
.station-card .sc-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.station-card h3 { font-size: 15px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-card .sc-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-card .sc-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ------------------------------------------------------------------ editor */
.editor-back { margin-bottom: 14px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr); gap: 18px; align-items: start; }
.editor-col { display: grid; gap: 18px; }
.editor-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 18px; }
.editor-panel h2 { font-size: 15px; margin-bottom: 14px; }
.form-grid { display: grid; gap: 13px; }
.form-grid .split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.artwork-box { display: grid; gap: 12px; }
.artwork-preview {
  width: 100%; aspect-ratio: 1; border-radius: 14px; object-fit: cover;
  background: #10121a; border: 1px solid var(--line);
}
.artwork-actions { display: flex; gap: 8px; }
.artwork-actions .btn { flex: 1; }

.track-list { display: grid; gap: 8px; }
.track-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,0.18);
}
.track-row.dragging { opacity: 0.45; }
.track-row.drag-over { border-color: rgba(14, 162, 255, 0.6); }
.track-grip { color: var(--muted-dim); cursor: grab; text-align: center; font-size: 15px; user-select: none; }
.track-main { min-width: 0; display: grid; gap: 6px; }
.track-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.track-fields input { padding: 6px 8px; border-radius: 7px; font-size: 12.5px; border: 1px solid var(--line); background: rgba(0,0,0,0.25); outline: none; width: 100%; }
.track-fields input:focus { border-color: rgba(14, 162, 255, 0.55); }
.track-sub { display: flex; gap: 10px; color: var(--muted-dim); font-size: 11px; }
.track-actions { display: flex; gap: 4px; }
.track-actions .icon-btn { width: 28px; height: 28px; font-size: 14px; }
.track-actions .icon-btn:disabled { opacity: 0.25; cursor: default; }

.preview-box { display: grid; gap: 11px; }
.preview-cover { display: flex; gap: 12px; align-items: center; }
.preview-cover img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #10121a; }
.preview-cover .pv-title { font-weight: 600; font-size: 13.5px; }
.preview-cover .pv-artist { color: var(--muted); font-size: 12px; }
.preview-controls { display: flex; gap: 8px; }
.preview-controls .btn { flex: 1; }
.progress { height: 5px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s linear; }

/* ------------------------------------------------------------------ users */
.role-select { padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,0.25); font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--green); }
.status-dot.off { background: var(--muted-dim); }

/* ----------------------------------------------------------------- dialog */
.dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 20px;
  background: #0b0d13; color: var(--text); padding: 22px; box-shadow: 0 40px 100px -20px rgba(0,0,0,0.9);
}
.dialog::backdrop { background: rgba(2, 3, 6, 0.7); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 13px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dialog-head h2 { font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: rgba(14, 16, 23, 0.96); color: var(--text); font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 77, 109, 0.5); color: #ffb3bf; }

/* -------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 14px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .sidebar .brand { flex: none; }
  .nav { display: flex; margin: 0; flex: 1; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { margin: 0; display: flex; align-items: center; flex: none; }
  .who { display: none; }
  .sidebar-foot .btn { white-space: nowrap; }
  .main { padding-top: 22px; }
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sidebar .brand span:last-child { display: none; }
  .nav-item { padding: 9px; }
  .nav-item span { display: none; }
  .field-row, .form-grid .split, .track-fields { grid-template-columns: 1fr; }
  .station-card { grid-template-columns: 64px minmax(0, 1fr); }
  .station-card img { width: 64px; height: 64px; }
}
