:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --seq-0: #f0efec;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;
  --seq-7: #0d366b;
  --meter-fill: #2a78d6;
  --meter-track: #cde2fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --seq-0: #262624;
    --seq-1: #104281;
    --seq-2: #184f95;
    --seq-3: #1c5cab;
    --seq-4: #256abf;
    --seq-5: #3987e5;
    --seq-6: #6da7ec;
    --seq-7: #9ec5f4;
    --meter-fill: #3987e5;
    --meter-track: #104281;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.06);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --seq-0: #262624;
  --seq-1: #104281;
  --seq-2: #184f95;
  --seq-3: #1c5cab;
  --seq-4: #256abf;
  --seq-5: #3987e5;
  --seq-6: #6da7ec;
  --seq-7: #9ec5f4;
  --meter-fill: #3987e5;
  --meter-track: #104281;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1040px; margin: 0 auto; padding: 32px 16px 48px; }
a { color: inherit; }
h1 { font-size: 28px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
.sub, .hint { color: var(--text-secondary); margin: 2px 0 0; }
.hint { font-size: 13px; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.ghost {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 8px; width: 36px; height: 36px; font-size: 16px; cursor: pointer;
}
.ghost:hover { background: var(--wash); }
.ghost:disabled { cursor: progress; opacity: 0.7; }
.ghost.wide { width: auto; padding: 0 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-primary); display: inline-flex; align-items: center; gap: 6px; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon { display: inline-block; }
.spinning .icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinning .icon { animation: none; } }
.status { color: var(--text-primary); font-size: 13px; margin: 6px 0 0; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }

.hero { padding: 24px 20px; }
.hero-label { color: var(--text-secondary); font-size: 14px; }
.hero-value { font-size: 56px; font-weight: 650; line-height: 1.1; letter-spacing: -0.02em; margin: 4px 0; }
.hero-note { color: var(--text-muted); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .note { color: var(--text-muted); font-size: 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button {
  border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 13px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--text-primary); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 14px 0 4px; font-size: 13px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
svg text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.hit { fill: transparent; cursor: default; }
.hit:hover, .hit.on { fill: var(--wash); }

.hbar { margin-top: 14px; }
.hbar-row { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.hbar-row .name { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.hbar-track { height: 14px; position: relative; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-row .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.badge {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
}
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 16px; }
.meter .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meter .name { color: var(--text-secondary); font-size: 13px; }
.meter .pct { font-size: 22px; font-weight: 600; }
.meter .track { height: 8px; border-radius: 4px; background: var(--meter-track); margin: 8px 0 6px; overflow: hidden; }
.meter .fill { height: 100%; border-radius: 4px; background: var(--meter-fill); min-width: 0; }
.meter .fill.warn { background: #fab219; }
.meter .fill.crit { background: #d03b3b; }
.meter .when { color: var(--text-muted); font-size: 12px; }
.meter .flag { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.meter.stale .pct, .meter.stale .track { opacity: 0.45; }
.extra { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); color: var(--text-secondary); font-size: 13px; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }
summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; color: var(--text-muted); font-size: 12px; }
details[open] summary::before { content: "▾"; }

.tip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 8px 10px; font-size: 12px; min-width: 150px;
}
.tip b { display: block; margin-bottom: 4px; font-size: 12px; }
.tip .row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.tip .row span:last-child { color: var(--text-primary); }
.tip .row i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

footer { color: var(--text-muted); font-size: 12px; margin-top: 24px; text-align: center; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2, .meters { grid-template-columns: 1fr; }
  .hero-value { font-size: 44px; }
  .hbar-row { grid-template-columns: 90px 1fr 56px; }
}
