:root {
  color-scheme: light;
  --surface-0: #f4f6f7;
  --surface-1: #fcfcfb;
  --surface-2: #eef1f3;
  --line: #d9dfe3;
  --line-soft: #e8edf0;
  --text-primary: #10222e;
  --text-secondary: #4a5b67;
  --text-muted: #6d7d88;
  --accent: #1d5b79;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --chart-bad: #e34948;   /* the charted 'failed' hue; --bad stays reserved for error TEXT */
  --good: #1b7f4b;
  --warn: #9a6400;
  --bad: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 34, 46, .06), 0 8px 24px rgba(16, 34, 46, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121615;
    --surface-1: #1a1a19;
    --surface-2: #232826;
    --line: #363c3a;
    --line-soft: #2a302e;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9c95;
    --accent: #7db7d4;
    --accent-ink: #0b1418;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --chart-bad: #c2453f;
    --good: #5ec08a;
    --warn: #e0b055;
    --bad: #f08a84;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over any display rule below it — .signin sets display:grid, which silently
   re-showed the sign-in card on top of the signed-in page. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 72px; }
.wrap-tabs { padding-bottom: 0; }

/* ---------------------------------------------------------------- sign-in */
.signin {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.signin-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { color: var(--text-muted); font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--text-secondary); }
input[type="email"], input[type="text"] {
  width: 100%; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-1); color: var(--text-primary);
}
input:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.code-input { letter-spacing: .5em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }

button {
  font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: 11px 16px; font-weight: 600;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; margin-top: 16px; }
.btn-primary[disabled] { opacity: .55; cursor: progress; }
.btn-quiet { background: transparent; color: var(--text-secondary); border-color: var(--line); padding: 7px 12px; font-size: 13px; }
.btn-link { background: none; border: none; color: var(--accent); padding: 4px 0; font-size: 13px; }

.note { font-size: 13px; color: var(--text-muted); margin-top: 14px; }
.error { color: var(--bad); font-size: 13.5px; margin-top: 12px; font-weight: 500; }

/* ---------------------------------------------------------------- chrome */
header.top {
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.top-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }

nav.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 10px 0 0; }
nav.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); padding: 8px 14px; border-radius: 0; white-space: nowrap; font-size: 14px;
}
nav.tabs button[aria-current="page"] { color: var(--text-primary); border-bottom-color: var(--accent); }

h1 { font-size: 24px; letter-spacing: -.02em; margin: 26px 0 4px; }
h2 { font-size: 17px; letter-spacing: -.01em; margin: 34px 0 12px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-secondary); }
.sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 8px; }

/* ---------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.tile .k { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; text-transform: none; }
.tile .v { font-size: 30px; font-weight: 680; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.tile .u { font-size: 13px; color: var(--text-muted); }
.tile.hero .v { font-size: 40px; }
.tile.na .v { font-size: 19px; color: var(--text-muted); font-weight: 600; }

.card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin: 12px 0;
}
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-secondary);
  background: var(--surface-2);
}
.chip.live { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.chip.ended { color: var(--text-muted); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 12.5px; color: var(--text-secondary); font-weight: 650; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
caption { text-align: left; color: var(--text-muted); font-size: 13px; padding: 0 0 8px; }

/* ---------------------------------------------------------------- charts */
.chart { width: 100%; overflow: visible; display: block; }
.chart text { font-size: 11.5px; fill: var(--text-muted); }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .series-label { font-size: 12px; font-weight: 650; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 10px; font-size: 13px; color: var(--text-secondary); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 60; background: var(--surface-1);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 13px;
  box-shadow: var(--shadow); min-width: 140px; opacity: 0; transition: opacity .08s;
}
.tooltip .tt-title { font-weight: 650; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }

.footnote { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; }
.callout {
  border-left: 3px solid var(--accent); background: var(--surface-2);
  padding: 12px 14px; border-radius: 0 9px 9px 0; margin: 14px 0; font-size: 14px;
}
.callout.pending { border-left-color: var(--warn); }
.def-list dt { font-weight: 650; margin-top: 14px; font-size: 14px; }
.def-list dd { margin: 4px 0 0; color: var(--text-secondary); font-size: 13.5px; }
.skeleton { color: var(--text-muted); padding: 40px 0; text-align: center; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
@media (max-width: 640px) {
  /* A 720-wide viewBox squashed into 360px is unreadable; let the chart keep its proportions
     and scroll sideways instead. The table view underneath stays the non-scrolling route. */
  .card:has(> .chart) { overflow-x: auto; }
  .chart { min-width: 540px; }
  .tile .v { font-size: 26px; }
  .tile.hero .v { font-size: 32px; }
  h1 { font-size: 20px; }
}
