@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: oklch(0.17 0 0);
  --bg-1: oklch(0.225 0 0);
  --bg-2: oklch(0.275 0 0);
  --line: oklch(0.33 0 0);
  --line-hi: oklch(0.45 0 0);
  --fg: oklch(0.96 0 0);
  --fg-dim: oklch(0.80 0 0);
  --fg-mute: oklch(0.60 0 0);
  --signal: oklch(0.72 0.17 45);       /* burnt orange — brand accent */
  --signal-dim: oklch(0.50 0.12 45);
  --done: oklch(0.80 0.13 70);         /* amber-gold — completed */
  --good: oklch(0.78 0.15 155);        /* green — healthy/live */
  --good-dim: oklch(0.52 0.10 155);
  --warn: oklch(0.80 0.14 85);         /* yellow — attention */
  --fail: oklch(0.68 0.22 25);         /* red — error/stale */
  --cache: oklch(0.72 0.14 240);       /* blue — cache series */
  --cache-dim: oklch(0.50 0.10 240);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--fg); }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}
.num, .mono, code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.frame { width: min(1760px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 44px) clamp(16px, 4vw, 58px) 96px; }
a { color: inherit; }

/* ── Masthead ─────────────────────────────────────────────── */
.masthead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end;
  padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.masthead h1 { font-size: clamp(30px, 4.4vw, 54px); line-height: .95; letter-spacing: -0.045em; font-weight: 700; }
.masthead h1 .dot {
  display: inline-block; width: .24em; height: .24em; border-radius: 50%;
  background: var(--good); margin-right: .34em; transform: translateY(-.22em);
  box-shadow: 0 0 18px oklch(0.7 0.15 155 / .5); animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.masthead h1 small {
  font-family: 'JetBrains Mono', monospace; font-size: clamp(11px, 1.2vw, 14px);
  color: var(--fg-mute); font-weight: 500; margin-left: 14px; letter-spacing: 0;
}
.lede { max-width: 900px; margin-top: 12px; color: var(--fg-mute); font-size: clamp(13px, 1.2vw, 15px); }
.meta { text-align: right; font-family: 'JetBrains Mono', monospace; color: var(--fg-mute); font-size: 13px; line-height: 1.75; white-space: nowrap; }
.meta strong { color: var(--fg-dim); font-weight: 600; }
.meta .live-tag { color: var(--good); }

/* ── Tab nav ──────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 26px; border: 1px solid var(--line); background: var(--line); width: fit-content; max-width: 100%; overflow: hidden; }
.tab {
  appearance: none; border: 0; cursor: pointer; background: var(--bg-1); color: var(--fg-mute);
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; padding: 13px clamp(18px, 3vw, 40px); transition: color .15s, background .15s; position: relative;
}
.tab:hover { color: var(--fg-dim); background: var(--bg-2); }
.tab.active { color: var(--fg); background: var(--bg-2); }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--signal); }
.tab .tab-sub { display: block; font-size: 10px; font-weight: 400; letter-spacing: .02em; text-transform: none; color: var(--fg-mute); margin-top: 3px; }

.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.loadbar { height: 2px; background: transparent; overflow: hidden; margin: -8px 0 18px; }
.loadbar.on { background: var(--line); }
.loadbar.on::after { content: ''; display: block; height: 100%; width: 35%; background: linear-gradient(90deg, transparent, var(--signal), transparent); animation: slide 0.9s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(390%); } }
.error-banner { background: var(--bg-2); border: 1px solid var(--fail); color: var(--fail); padding: 12px 16px; font-family: 'JetBrains Mono', monospace; font-size: 12px; margin-bottom: 20px; }
.tile-error { color: var(--fail); font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 10px 0; }

/* ── Section heads ────────────────────────────────────────── */
.section-head { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 20px; margin: 40px 0 16px; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 22px; letter-spacing: -.02em; font-weight: 700; }
.section-head .rule { height: 1px; background: var(--line); }
.section-head .count { font-family: 'JetBrains Mono', monospace; color: var(--fg-mute); font-size: 12px; letter-spacing: .04em; }

/* ── Toggle ───────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.toggle { display: inline-flex; border: 1px solid var(--line-hi); background: var(--bg-1); overflow: hidden; }
.toggle button {
  appearance: none; border: 0; cursor: pointer; background: transparent; color: var(--fg-mute);
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 26px; transition: color .15s, background .15s;
}
.toggle button.active { background: var(--signal); color: oklch(0.16 0 0); }
.toggle button:not(.active):hover { color: var(--fg); background: var(--bg-2); }
.toggle-note { color: var(--fg-mute); font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── Stat tiles ───────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.tile { min-width: 0; padding: clamp(18px, 2.2vw, 26px); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: color-mix(in oklch, var(--bg), var(--bg-1) 55%); position: relative; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--fg-mute); font-weight: 700; margin-bottom: 12px; }
.tile .v { font-family: 'JetBrains Mono', monospace; font-size: clamp(28px, 3.2vw, 44px); line-height: 1; letter-spacing: -.045em; }
.tile .v .unit { font-size: .42em; color: var(--fg-mute); margin-left: .3em; letter-spacing: 0; }
.tile .sub { margin-top: 12px; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-mute); line-height: 1.6; }
.tile.hl .v { color: var(--signal); }
.tile.gold .v { color: var(--done); }
.tile.blue .v { color: var(--cache); }
.tile.green .v { color: var(--good); }
.tile .bar { height: 4px; background: var(--line); margin-top: 14px; overflow: hidden; }
.tile .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--signal), var(--done)); width: 0; transition: width .5s ease; }
.tile.blue .bar span { background: linear-gradient(90deg, var(--cache-dim), var(--cache)); }

/* ── Generic cards ────────────────────────────────────────── */
.cards { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.cards.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cards.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card { background: var(--bg-1); padding: clamp(20px, 2.6vw, 30px); min-width: 0; }
.card .eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .2em; color: var(--fg-mute); font-weight: 700; }
.card .big-num { font-family: 'JetBrains Mono', monospace; font-size: clamp(30px, 3.4vw, 46px); line-height: 1; letter-spacing: -.05em; margin: 14px 0 6px; }
.card .big-num .unit { font-size: .4em; color: var(--fg-mute); margin-left: .3em; }
.card p { color: var(--fg-mute); font-size: 13px; margin-top: 8px; }

/* ── Cadence ──────────────────────────────────────────────── */
.cadence { display: grid; grid-template-columns: minmax(0,1fr) minmax(260px,.7fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 22px; }
.cadence > div { background: var(--bg-1); padding: clamp(20px,2.6vw,30px); min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 5px 12px; border: 1px solid var(--good-dim); color: var(--good); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); }
.run-lane { display: grid; grid-template-columns: auto 1fr; gap: 14px 20px; margin-top: 18px; }
.run-lane .lane-name { font-family: 'JetBrains Mono', monospace; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-dim); align-self: start; padding-top: 3px; }
.run-lane .lane-body { min-width: 0; }
.run-lane .lane-title { font-weight: 600; }
.run-lane .lane-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-mute); }
.run-lane .lane-stats b { color: var(--fg-dim); font-weight: 500; }
.next-run .big-num { color: var(--signal); }
.status-ok { color: var(--good); } .status-partial { color: var(--warn); } .status-bad { color: var(--fail); }

/* ── Tables ───────────────────────────────────────────────── */
.tbl-wrap { border: 1px solid var(--line); overflow-x: auto; background: var(--bg-1); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
table.data th { text-align: left; font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-mute); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); }
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--fg-dim); }
table.data td.num, table.data th.num { text-align: right; font-family: 'JetBrains Mono', monospace; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td, table.data tr:hover td { background: color-mix(in oklch, var(--bg-1), var(--bg-2) 60%); }
.chip { display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .06em; padding: 2px 7px; border: 1px solid var(--line-hi); color: var(--fg-dim); text-transform: uppercase; }
.chip.movies { border-color: var(--signal-dim); color: var(--signal); }
.chip.tv { border-color: var(--cache-dim); color: var(--cache); }

/* ── Weekly bar charts ────────────────────────────────────── */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.chart-card { background: var(--bg-1); padding: clamp(20px,2.4vw,28px); min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.chart-head .title { font-weight: 700; font-size: 16px; }
.chart-head .accent { width: 10px; height: 10px; display: inline-block; margin-right: 8px; vertical-align: middle; }
.chart-sub { color: var(--fg-mute); font-family: 'JetBrains Mono', monospace; font-size: 12px; margin-bottom: 16px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .bar-rect { transition: opacity .15s; }
.chart-svg .bar-rect:hover { opacity: .75; }
.chart-svg text { font-family: 'JetBrains Mono', monospace; }
.chart-empty { color: var(--fg-mute); font-family: 'JetBrains Mono', monospace; font-size: 13px; padding: 30px 0; text-align: center; }

/* ── Cache progress hero ──────────────────────────────────── */
.progress-hero { display: grid; grid-template-columns: minmax(0,1.4fr) repeat(2, minmax(150px,.6fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 22px; }
.progress-hero > div { background: var(--bg-1); padding: clamp(20px,2.6vw,32px); min-width: 0; }
.progress-hero .big-num { color: var(--done); }
.progbar { height: 8px; background: var(--line); overflow: hidden; margin: 16px 0 10px; }
.progbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--good-dim), var(--good)); width: 0; transition: width .6s ease; }

/* ── Worker health grid ───────────────────────────────────── */
.workers { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.worker { background: var(--bg-1); padding: 18px clamp(16px,1.6vw,20px); min-width: 0; border-top: 3px solid var(--line-hi); }
.worker.streaming, .worker.active { border-top-color: var(--good); }
.worker.idle { border-top-color: var(--warn); }
.worker.stale { border-top-color: var(--fail); }
.worker .whead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.worker .wname { font-size: 20px; font-weight: 700; letter-spacing: -.02em; text-transform: capitalize; }
.worker .wstate { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border: 1px solid currentColor; }
.worker.streaming .wstate, .worker.active .wstate { color: var(--good); }
.worker.idle .wstate { color: var(--warn); }
.worker.stale .wstate { color: var(--fail); }
.worker .wnow { margin-top: 12px; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-dim); min-height: 1.5em; }
.worker .wnow .muted { color: var(--fg-mute); }
.worker .wmetrics { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px 12px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-hi); }
.worker .wmetrics .m span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-mute); }
.worker .wmetrics .m b { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 500; color: var(--fg-dim); }

/* ── Loading skeletons ────────────────────────────────────── */
.loading .v, .loading .big-num { color: var(--fg-mute); opacity: .5; }
.skeleton { position: relative; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); border-radius: 2px; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, oklch(0.4 0 0 / .18), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ── Footer ───────────────────────────────────────────────── */
.foot { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; gap: 16px; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--fg-mute); letter-spacing: .04em; }
.foot div:nth-child(2) { text-align: center; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1180px) {
  .workers { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .charts, .cache-split { grid-template-columns: 1fr; }
  .progress-hero { grid-template-columns: 1fr 1fr; }
  .progress-hero > div:first-child { grid-column: 1 / -1; }
  .cadence { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .masthead { grid-template-columns: 1fr; align-items: start; }
  .meta { text-align: left; white-space: normal; }
  .cards.c2, .cards.c3 { grid-template-columns: 1fr; }
  .section-head { grid-template-columns: 1fr; gap: 6px; }
  .section-head .rule { display: none; }
}
@media (max-width: 560px) {
  .frame { padding-left: 12px; padding-right: 12px; }
  .workers { grid-template-columns: 1fr; }
  .progress-hero { grid-template-columns: 1fr; }
  .tab { padding: 11px 16px; }
  .foot { grid-template-columns: 1fr; }
  .foot div:nth-child(2) { text-align: left; }
}
