:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --panel: #11151d;
  --panel-2: #161b25;
  --line: rgba(255,255,255,.08);
  --text: #e8ebf2;
  --dim: #8b93a7;
  --muted: #5d6578;
  --grid: #222835;
  --axis: #383f4d;
  --ember: #ffb454;
  --ember-ink: #1a1206;
  --danger: #e66767;
  --success: #0ca30c;
  --warning: #fab219;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --seq: #3987e5;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.45; }
a { color: var(--ember); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ── nav ── */
.nav { display: flex; align-items: center; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.nav .brand { font-weight: 700; font-size: 16px; margin-right: 18px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.nav .brand .mark { color: var(--ember); }
.nav a.tab { padding: 6px 11px; border-radius: 8px; color: var(--dim); font-weight: 500; }
.nav a.tab:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.nav a.tab.active { background: var(--panel-2); color: var(--text); }
.nav .spacer { flex: 1; }
.nav .ai-badge { font-size: 11.5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.nav .ai-badge.on { color: var(--success); border-color: rgba(12,163,12,.35); }
.nav button.ghost { background: none; border: 1px solid var(--line); color: var(--dim); padding: 5px 10px; border-radius: 8px; cursor: pointer; margin-left: 10px; }
.nav button.ghost:hover { color: var(--text); }

/* ── layout ── */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.page h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page .sub { color: var(--dim); margin: 0 0 20px; font-size: 13px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 860px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .page { padding: 16px 16px 40px; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 0 0 10px; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card .head h2 { margin: 0; }

/* stat tile */
.stat .value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .delta { font-size: 12px; color: var(--dim); margin-top: 4px; }
.stat .delta.up { color: var(--success); }
.stat .delta.down { color: var(--danger); }
.stat .delta.warn { color: var(--warning); }

/* buttons */
.btn { background: var(--ember); color: var(--ember-ink); border: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: rgba(230,103,103,.15); color: var(--danger); border: 1px solid rgba(230,103,103,.3); }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* inputs */
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 13px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ember); }
label { display: block; font-size: 12px; color: var(--dim); margin: 10px 0 4px; }

/* messages */
.msg { margin-top: 10px; font-size: 12.5px; padding: 8px 10px; border-radius: 6px; }
.msg.error { background: rgba(230,103,103,.12); color: var(--danger); }
.msg.success { background: rgba(12,163,12,.12); color: var(--success); }
.msg.info { background: rgba(57,135,229,.12); color: #7fb3f0; }
.hidden { display: none !important; }
.muted { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: rgba(255,255,255,.02); }

/* pills */
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.pill.series { color: var(--text); border-color: transparent; background: color-mix(in srgb, var(--pc) 22%, transparent); }
.pill.series::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pc); margin-right: 6px; vertical-align: 1px; }
.pill.live { color: var(--s7); }
.pill.warn { color: var(--warning); border-color: rgba(250,178,25,.35); }
.pill.good { color: var(--success); border-color: rgba(12,163,12,.35); }
.pill.bad { color: var(--danger); border-color: rgba(230,103,103,.35); }

/* video list */
.vid { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vid:last-child { border-bottom: none; }
.vid img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--panel-2); }
.vid .t { font-weight: 500; }
.vid .m { color: var(--dim); font-size: 12px; margin-top: 2px; }
.vid .n { text-align: right; font-variant-numeric: tabular-nums; }
.vid .n b { font-size: 16px; display: block; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.chart .bar { }
.chart .bar:hover { filter: brightness(1.2); }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .dot { stroke: var(--panel); stroke-width: 2; pointer-events: none; }
.tooltip { position: absolute; pointer-events: none; background: #1c2230; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); }
.tooltip .tt-l { color: var(--dim); }
.tooltip .tt-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--dim); margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--lc); margin-right: 6px; vertical-align: -1px; }

/* markdown output */
.md { font-size: 13.5px; line-height: 1.55; }
.md h1, .md h2, .md h3 { margin: 16px 0 6px; line-height: 1.3; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15px; } .md h3 { font-size: 13.5px; color: var(--ember); }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md strong { color: #fff; }
.md blockquote { border-left: 3px solid var(--ember); margin: 8px 0; padding: 4px 12px; color: var(--dim); }

/* series page */
.series-row { display: grid; grid-template-columns: 36px 1fr 1.4fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); }
input[type=color] { width: 36px; height: 30px; padding: 2px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; }
.login-card .logo { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-weight: 700; font-size: 18px; }
.login-card .logo .mark { color: var(--ember); }

.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.section-title h2 { font-size: 15px; margin: 0; }
.section-title .pill { margin-left: auto; }

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--ember); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
