/* dstargateway dashboard */
:root {
  --bg: #060a12;
  --bg-grid: rgba(56, 189, 248, 0.045);
  --panel: #0b1220;
  --panel-2: #0f1829;
  --line: #1a2740;
  --line-2: #24375a;
  --text: #e3ebf7;
  --muted: #7d8ca8;
  --faint: #4a5a78;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --accent-ink: #031418;
  --onair: #34f5a5;
  --onair-ink: #02160d;
  --onair-glow: rgba(52, 245, 165, 0.35);
  --warn: #fbbf24;
  --bad: #f87171;
  --lock: #a78bfa;
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef2f8;
  --bg-grid: rgba(8, 145, 178, 0.06);
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --line: #dbe3ef;
  --line-2: #c5d2e5;
  --text: #0d1726;
  --muted: #56657f;
  --faint: #8c9ab2;
  --accent: #0891b2;
  --accent-2: #0284c7;
  --accent-ink: #ffffff;
  --onair: #059669;
  --onair-ink: #ffffff;
  --onair-glow: rgba(5, 150, 105, 0.22);
  --warn: #b45309;
  --bad: #dc2626;
  --lock: #7c3aed;
  --shadow: 0 1px 2px rgba(15,23,42,0.06), 0 6px 18px rgba(15,23,42,0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font: 14px/1.45 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- top bar ---- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 60px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.08em; font-size: 13px; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.brand .logo svg { width: 18px; height: 18px; }
.brand small { display: block; font-weight: 500; letter-spacing: 0.04em; color: var(--muted); font-size: 11px; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a { padding: 7px 12px; border-radius: 7px; color: var(--muted); font-weight: 500; }
nav.tabs a:hover { color: var(--text); background: var(--panel-2); }
nav.tabs a.active { color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line-2); }
.top .spacer { flex: 1; }
.clock { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--onair); box-shadow: 0 0 8px var(--onair-glow); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  height: 34px; padding: 0 13px; border-radius: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text); font-weight: 500;
  white-space: nowrap; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--line); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--bad); }
.btn.on { background: var(--onair); border-color: var(--onair); color: var(--onair-ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

main { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 4px 0 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.stat .v { font: 600 26px/1.2 var(--mono); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat.live .v { color: var(--onair); }
.stat .sub { margin-top: 4px; font: 12px var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.stat .sub span { white-space: nowrap; }
.stat .sub b { color: var(--text); font-weight: 600; }

/* ---- on air ---- */
.onair { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-bottom: 18px; }
.onair:empty { display: none; }
.tx {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 14px 16px; background: var(--panel);
  border: 1px solid var(--onair); box-shadow: 0 0 0 1px var(--onair-glow), 0 0 28px var(--onair-glow);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.tx .label { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--onair); font-weight: 600; }
.tx .label .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--onair); animation: pulse 1.2s infinite; }
.tx .call { font: 700 24px/1.15 var(--mono); letter-spacing: 0.02em; }
.tx .call small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.tx .where { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.tx .timer { font: 600 18px var(--mono); color: var(--onair); font-variant-numeric: tabular-nums; text-align: right; }
.tx .msg { grid-column: 1 / -1; font-family: var(--mono); font-size: 12px; color: var(--text); opacity: .85; min-height: 1em; }
.tx .tx-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.btn .stop { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding-left: 8px;
  border-left: 1px solid color-mix(in srgb, currentColor 35%, transparent); font-size: 12px; opacity: .85; }
.btn .stop svg.i { width: 12px; height: 12px; }
.btn.listen-hint { color: var(--muted); }
.page-head > div { min-width: 0; max-width: 100%; }
#listen-state { max-width: 100%; }
#listen-state .lbl { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#listen-state .stop { flex: none; }
.tx canvas { grid-column: 1 / -1; width: 100%; height: 34px; display: block; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .35; transform: scale(.75);} }

/* ---- systems ---- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; gap: 12px; }
.section-title h2 { margin: 0; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.systems { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 14px; }
.sys { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.sys header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sys header .name { font: 700 16px var(--mono); letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys header .desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys header .grow { flex: 1; min-width: 96px; }
.badge { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 3px 7px; border-radius: 5px;
  border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.ref { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge.gw { color: var(--lock); border-color: color-mix(in srgb, var(--lock) 40%, transparent); }
.sys.offline { opacity: .62; }
.mods { display: flex; flex-direction: column; }
.mod { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); min-height: 52px; }
.mod:first-child { border-top: 0; }
.mod .letter { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font: 700 15px var(--mono);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.mod .body { min-width: 0; }
.mod .now { font: 600 14px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod .idle { color: var(--faint); font-weight: 500; font-family: var(--sans); font-size: 13px; }
.mod.active { background: linear-gradient(90deg, color-mix(in srgb, var(--onair) 11%, transparent), transparent 70%); }
.mod.active .letter { background: var(--onair); color: var(--onair-ink); border-color: var(--onair); box-shadow: 0 0 14px var(--onair-glow); }
.mod.active .now { color: var(--onair); }
.mod .acts { display: flex; gap: 6px; align-items: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--panel); }

/* ---- tables ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.call { font: 600 13px var(--mono); }
td.call small { color: var(--muted); font-weight: 400; margin-left: 4px; }
td .tag { font: 12px var(--mono); padding: 2px 6px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); }
td.msg { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12px; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
tr.playing td { background: color-mix(in srgb, var(--accent) 10%, transparent) !important; }

/* ---- forms ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px; border-bottom: 1px solid var(--line); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
input, select {
  height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font: 14px var(--sans); outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.mono { font-family: var(--mono); text-transform: uppercase; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; }

/* ---- player bar ---- */
.player {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  width: min(760px, calc(100% - 32px));
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line-2);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.player .meta { min-width: 0; }
.player .meta b { font-family: var(--mono); }
.player .meta div { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 6px; cursor: pointer; }
.player .bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.player .t { font: 12px var(--mono); color: var(--muted); }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(2,6,14,.6); backdrop-filter: blur(4px); padding: 16px; }
.dialog { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.dialog.wide { width: min(560px, 100%); }
.dialog header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
.dialog h3 { margin: 0; font-size: 17px; }
.dialog .content { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.dialog .row { display: flex; gap: 10px; }
.dialog .row > * { flex: 1; }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }
.note { font-size: 13px; color: var(--muted); }
.lock { color: var(--lock); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  border: 1px solid var(--line-2); color: var(--muted); }
.pill.paid { color: var(--onair); border-color: color-mix(in srgb, var(--onair) 45%, transparent); }
.pill.admin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.menu { position: absolute; right: 24px; top: 56px; z-index: 35; width: 260px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35); padding: 8px; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .who b { font-family: var(--mono); font-size: 15px; }
.menu button { width: 100%; display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--panel-2); }
.toast { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
  background: color-mix(in srgb, var(--lock) 9%, var(--panel)); border: 1px solid color-mix(in srgb, var(--lock) 35%, transparent); font-size: 13px; }
.banner .grow { flex: 1; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock { display: none; }
}
@media (max-width: 640px) {
  .top { padding: 0 12px; gap: 10px; height: auto; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .brand small, .conn span { display: none; }
  nav.tabs { order: 3; width: 100%; }
  nav.tabs a { flex: 1; text-align: center; }
  main { padding: 16px; }
  .systems { grid-template-columns: 1fr; }
  .menu { right: 12px; }
  .player { grid-template-columns: auto 1fr auto; }
  .player .t { display: none; }
}
