:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-7: #4a3aa7;
  --up: #006300;
  --down: #b42828;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --idle: #c3c2b7;
  --radius: 10px;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-7: #9085e9;
    --up: #0ca30c;
    --down: #e66767;
    --idle: #4a4a46;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-7: #9085e9;
  --up: #0ca30c;
  --down: #e66767;
  --idle: #4a4a46;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
button {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--axis); }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: min(340px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: grid; gap: 10px;
}
.login-card h1 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.01em; }
.login-card label { color: var(--ink-2); font-size: 13px; }
.login-card input {
  font: inherit; color: var(--ink); background: var(--page); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px;
}
.login-card button { background: var(--ink); color: var(--page); border: 0; padding: 9px; margin-top: 6px; }
.login-error { color: var(--critical); margin: 0; font-size: 13px; }

/* ---------- shell ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 64px; }
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
header.top h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; }
header.top .stamp { color: var(--muted); font-size: 13px; }
header.top .spacer { flex: 1; }
nav.jump { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
nav.jump a { text-decoration: none; }
nav.jump a:hover { color: var(--ink); }

section { margin-top: 32px; }
section > h2 { font-size: 15px; margin: 0 0 4px; letter-spacing: -0.005em; }
section > .sub { color: var(--ink-2); font-size: 13px; margin: 0 0 12px; max-width: 80ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.err { color: var(--critical); font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- KPI tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .foot { color: var(--muted); font-size: 12.5px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

/* ---------- status ---------- */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; color: var(--ink); }
.st i {
  font-style: normal; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff; flex: none;
}
.st-ok i, .st-OK i { background: var(--good); }
.st-failing i, .st-DRIFT i { background: var(--critical); }
.st-overdue i, .st-warn i { background: var(--serious); }
.st-BLOCKED i { background: var(--warning); color: #3a2a00; }
.st-running i { background: var(--series-1); }
.st-disabled i, .st-never i, .st-UNKNOWN i { background: var(--idle); color: var(--ink); }

.attention { display: grid; gap: 8px; }
.attention .row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.attention .why { color: var(--ink-2); font-size: 13px; }
.allclear { color: var(--ink-2); }

/* ---------- workflow table ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group td { background: transparent; color: var(--ink-2); font-weight: 600; font-size: 12px; padding-top: 16px; text-transform: uppercase; letter-spacing: 0.04em; }
.wfname { font-weight: 500; }
.wfname small { display: block; color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 11px; }
.sched { color: var(--ink-2); white-space: nowrap; }

.dots { display: flex; gap: 2px; align-items: center; }
.dots a { display: block; width: 8px; height: 16px; border-radius: 2px; background: var(--idle); }
.dots a.success { background: var(--good); }
.dots a.failure, .dots a.timed_out, .dots a.startup_failure { background: var(--critical); height: 20px; }
.dots a.cancelled { background: var(--serious); }
.dots a.running { background: var(--series-1); }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; cursor: pointer; }
.toggle input { accent-color: var(--series-1); }
.hide-healthy tr.healthy, .hide-healthy tr.group.allhealthy { display: none; }
.meter { width: 90px; height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.meter span { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.meter span.over { background: var(--serious); }
.chart .line.muted-line { stroke: var(--axis); stroke-width: 1.5; }
.dots a.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--axis); height: 10px; }
.dots a:hover { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- google grid ---------- */
.ggrid td.cell { text-align: center; padding: 6px 4px; }
.ggrid td.cell .st { justify-content: center; }
.ggrid th.run { text-align: center; }
.drift { margin-top: 12px; display: grid; gap: 6px; }
.drift div { font-size: 12.5px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; }
.gcols { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.ggrid td.mono { white-space: nowrap; }
@media (max-width: 760px) { .cols, .gcols { grid-template-columns: 1fr; } }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart h3 { font-size: 13px; margin: 0 0 2px; font-weight: 600; }
.chart .note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.partial { fill: var(--series-1); opacity: 0.45; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; }
.chart .line.s2 { stroke: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.on { opacity: 0.8; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .pt { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12px;
  padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px));
  z-index: 5; font-variant-numeric: tabular-nums;
}
.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar .track { height: 10px; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar .v { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 4ch; text-align: right; }

details.about summary { cursor: pointer; color: var(--muted); font-size: 12px; }
details.about p { margin: 6px 0 0; color: var(--ink-2); font-size: 12.5px; max-width: 70ch; }

/* ---------- channels & community ---------- */
.channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.chan { display: block; text-decoration: none; }
.chan:hover { border-color: var(--axis); }
.chan .label { color: var(--ink-2); font-size: 12.5px; }
.chan .ver { font-family: var(--mono); font-size: 20px; font-weight: 600; margin: 4px 0; letter-spacing: -0.01em; }
.chan .foot { color: var(--muted); font-size: 12.5px; }
.chan .change { color: var(--ink-2); font-size: 12.5px; margin-top: 6px; }
.listh { font-size: 13px; margin: 0 0 8px; display: flex; justify-content: space-between; }
.items { list-style: none; margin: 0; padding: 0; display: grid; }
.items li { padding: 8px 0; border-top: 1px solid var(--grid); }
.items li:first-child { border-top: 0; padding-top: 0; }
.items a { text-decoration: none; font-weight: 500; }
.items a:hover { text-decoration: underline; }
.items .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.items .meta .st { font-size: 12px; }

/* Channel identity: stable blue, nightly orange, canary purple. */
.ch-stable { --ch: var(--series-1); }
.ch-nightly { --ch: var(--series-2); }
.ch-canary { --ch: var(--series-7); }
.chan { border-top: 3px solid var(--ch); }
.chan .ver { color: var(--ch); }
.chan .label::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ch); margin-right: 6px; }
