/* Dark-first; the light block below only swaps tokens. Series colours are
   the validated dataviz reference palette (dark/light steps). */
:root {
  color-scheme: dark;
  --page: #0d0f10;
  --surface: #17191a;
  --surface-2: #1f2223;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.08);
  --accent: #e0a53b;          /* brand chrome only, never data */
  --accent-ink: #1a1306;
  --good: #0ca30c;
  --critical: #d03b3b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --other: #6b6a65;
  --seq-0: #1f2a38; --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5;
  --seq-4: #6da7ec; --seq-5: #b7d3f6;
  --empty: #202324;
  --glow-a: rgba(57, 135, 229, 0.16);
  --glow-b: rgba(25, 158, 112, 0.12);
  --glow-c: rgba(224, 165, 59, 0.08);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --page: #f4f3ef;
    --surface: #fcfcfb;
    --surface-2: #f3f2ee;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #7a7873;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --ring: rgba(11, 11, 11, 0.10);
    --accent: #a8700f;
    --accent-ink: #ffffff;
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
    --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
    --other: #a9a79f;
    --seq-0: #e6eefa; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #5598e7;
    --seq-4: #256abf; --seq-5: #104281;
    --empty: #ecebe6;
    --glow-a: rgba(42, 120, 214, 0.10);
    --glow-b: rgba(27, 175, 122, 0.08);
    --glow-c: rgba(168, 112, 15, 0.06);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 40vh at 10% -10%, var(--glow-a), transparent 70%),
    radial-gradient(50vw 40vh at 95% 0%, var(--glow-b), transparent 70%),
    radial-gradient(70vw 50vh at 50% 110%, var(--glow-c), transparent 70%);
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
.wrap { max-width: 1280px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top, 0px);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: color-mix(in srgb, var(--page) 72%, transparent);
  border-bottom: 1px solid var(--ring);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-logo { display: block; width: auto; height: 48px; flex: none; }
@media (max-width: 480px) { .brand-logo { height: 36px; } }
.brand-title { display: block; font-weight: 650; font-size: 17px; letter-spacing: 0.01em; }
.brand-sub { display: block; color: var(--muted); font-size: 12.5px; }
.status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--ring); font-size: 13px; max-width: 100%;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill.on .dot { background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .pill.on .dot { animation: none; } }
.updated { color: var(--muted); font-size: 12.5px; }
.refresh {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--ring); background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.refresh:hover, .refresh:focus-visible { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 55%, var(--ring)); outline: none; }
.refresh:active { transform: scale(0.96); }
.refresh.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .refresh-label { display: none; } .refresh { padding: 6px 8px; } }

/* clickable tiles */
a.kpi { display: block; }
.tile-link { text-decoration: none; color: inherit; position: relative; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease; }
.tile-link:hover, .tile-link:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--ring)); outline: none; }
.tile-link .label { padding-right: 18px; }
.tile-link .go { position: absolute; top: 10px; right: 12px; color: var(--muted); font-size: 13px; opacity: 0.6; transition: transform 0.15s ease, opacity 0.15s ease; }
.tile-link:hover .go, .tile-link:focus-visible .go { opacity: 1; color: var(--accent); transform: translateX(2px); }
.card { scroll-margin-top: 96px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent), var(--shadow); } 100% { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) {
  .tile-link, .tile-link .go { transition: none; }
  .tile-link:hover, .tile-link:focus-visible { transform: none; }
  .flash, .refresh.spin svg { animation: none; }
}
.more-link { color: var(--ink-2); font-size: 12.5px; text-decoration: none; margin-left: auto; }
.more-link:hover { color: var(--ink); text-decoration: underline; }
.who.plain { text-decoration: none; font-weight: 500; }
.who.plain:hover { text-decoration: underline; }

/* ---------- filters ---------- */
.filters {
  display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap;
  padding-block: 18px 6px;
}
.presets { display: inline-flex; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 3px; }
.presets button {
  border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2);
}
.presets button:hover { background: var(--surface-2); }
.presets button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.range { flex: 1 1 320px; min-width: 0; }
.range-track { position: relative; height: 28px; }
.range-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--grid);
}
.range-fill { position: absolute; top: 12px; height: 4px; border-radius: 2px; background: var(--accent); }
.range-track input {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none; height: 28px;
}
.range-track input::-webkit-slider-runnable-track { background: none; height: 28px; }
.range-track input::-moz-range-track { background: none; }
.range-track input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; margin-top: 5px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); cursor: grab;
}
.range-track input::-moz-range-thumb {
  pointer-events: auto; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); cursor: grab;
}
.range-track input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.range-label { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }

/* ---------- layout ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-top: 16px; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
@media (max-width: 980px) { .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; } }

.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 16px;
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card h2 { font-size: 14.5px; font-weight: 620; margin: 0; letter-spacing: 0.01em; }
.card .hint { color: var(--muted); font-size: 12.5px; }
.chart { position: relative; width: 100%; overflow: hidden; }
.chart svg { display: block; overflow: visible; }
.empty-state { color: var(--muted); padding: 32px 0; text-align: center; }

/* ---------- tiles ---------- */
.tiles { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 3fr); margin-top: 12px; }
@media (max-width: 980px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
.hero { display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.hero::after {
  content: "ᚱ"; position: absolute; right: -6px; bottom: -40px; font-size: 160px; line-height: 1;
  color: var(--accent); opacity: 0.07; pointer-events: none;
}
.hero .label { color: var(--ink-2); font-size: 13px; }
.hero .value { font-size: 52px; font-weight: 650; line-height: 1.05; letter-spacing: -0.02em; margin: 4px 0; }
.hero .value small { font-size: 22px; font-weight: 550; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.hero .sub { color: var(--muted); font-size: 12.5px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--ring); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 24px; font-weight: 620; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- legend / chips ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .ln { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--ring); background: var(--surface-2); border-radius: 999px; padding: 3px 10px;
  font-size: 12.5px; cursor: pointer; color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.seg-scale { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.seg-scale .bar { display: flex; gap: 2px; }
.seg-scale .bar span { width: 18px; height: 10px; border-radius: 2px; }

/* ---------- tables ---------- */
.search {
  width: min(260px, 100%); padding: 7px 12px 7px 32px; border-radius: 10px; border: 1px solid var(--ring);
  background: var(--surface-2) no-repeat 10px 50% / 14px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.table-wrap { overflow-x: auto; margin-inline: -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 8px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 12px; border-bottom: 1px solid var(--grid); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
td { border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
td.r, th.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover, tbody tr.click:focus-visible { background: var(--surface-2); outline: none; }
.who { display: inline-flex; align-items: center; gap: 8px; font-weight: 560; }
.who .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.share { display: inline-block; width: 80px; height: 6px; border-radius: 3px; background: var(--grid); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.share > span { display: block; height: 100%; border-radius: 3px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.on::before { background: var(--good); }
details.tv { margin-top: 10px; }
details.tv summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.tv[open] summary { margin-bottom: 6px; }
.more { margin-top: 10px; }
.more button { border: 1px solid var(--ring); background: var(--surface-2); border-radius: 8px; padding: 5px 12px; cursor: pointer; color: var(--ink-2); }

/* ---------- event feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 2px; border-bottom: 1px solid var(--grid); }
.feed .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; }
.feed .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what a { font-weight: 560; text-decoration: none; }
.feed .what a:hover { text-decoration: underline; }
.feed time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- player detail ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; margin-top: 14px; font-size: 13px; }
.back:hover { color: var(--ink); }
.phead { display: flex; align-items: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.avatar {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex: none;
  font-size: 24px; font-weight: 700; color: #fff;
}
.phead h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.phead .meta { color: var(--muted); font-size: 13px; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(70px, 140px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); text-decoration: none; }
.hbar a.name:hover { color: var(--ink); text-decoration: underline; }
.hbar .track { height: 10px; }
.hbar .fill { height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- tooltip ---------- */
.tt {
  position: fixed; z-index: 50; pointer-events: none; max-width: 300px;
  background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--ring);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.tt .t { color: var(--muted); margin-bottom: 4px; }
.tt .row { display: flex; align-items: center; gap: 8px; }
.tt .row b { font-weight: 650; font-variant-numeric: tabular-nums; }
.tt .row span { color: var(--ink-2); }
.tt .k { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tt .note { color: var(--ink-2); margin-top: 2px; }

/* svg chrome */
.ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ax-ink { fill: var(--ink-2); font-size: 12px; }
.gl { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.bl { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.xh { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.hov { cursor: pointer; }
.hov:hover, .hov:focus-visible { filter: brightness(1.18); outline: none; }
.lane-link { cursor: pointer; }
.lane-link:hover { text-decoration: underline; }

.foot { color: var(--muted); font-size: 12px; padding-block: 28px 36px; }
