: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.10);
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  /* One fixed colour per metric, in the validated categorical order */
  --m-LAeq: #2a78d6;
  --m-LCeq: #eb6834;
  --m-LAmax: #1baf7a;
  --m-L01: #eda100;
  --m-L10: #e87ba4;
  --m-L90: #008300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --m-LAeq: #3987e5;
    --m-LCeq: #d95926;
    --m-LAmax: #199e70;
    --m-L01: #c98500;
    --m-L10: #d55181;
    --m-L90: #008300;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --m-LAeq: #3987e5;
  --m-LCeq: #d95926;
  --m-LAmax: #199e70;
  --m-L01: #c98500;
  --m-L10: #d55181;
  --m-L90: #008300;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top { padding: 16px 16px 8px; max-width: 1600px; margin: 0 auto; }
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
.conn { color: var(--ink-2); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 12px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.chip .sw { width: 12px; height: 3px; border-radius: 2px; }
.chip[aria-pressed="false"] { color: var(--muted); }
.chip[aria-pressed="false"] .sw { opacity: 0.25; }

.grid {
  display: grid; gap: 16px; padding: 8px 16px 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  max-width: 1600px; margin: 0 auto;
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h2 { font-size: 16px; margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.good .dot { background: var(--good); }
.pill.warning .dot { background: var(--warning); }
.pill.critical .dot { background: var(--critical); }

.hero { display: flex; align-items: flex-end; gap: 24px; margin: 12px 0 4px; flex-wrap: wrap; }
.hero-main .label, .hero-side .label { font-size: 12px; color: var(--ink-2); }
.hero-main .value { font-size: 44px; font-weight: 600; line-height: 1.05; }
.hero-main .unit, .hero-side .unit { font-size: 16px; font-weight: 400; color: var(--ink-2); margin-left: 2px; }
.hero-side .value { font-size: 22px; font-weight: 600; }
.over {
  display: none; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--ink); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--critical);
}
.over.show { display: inline-flex; }
.over .icon { color: var(--critical); }

.section-label { font-size: 12px; color: var(--ink-2); margin: 14px 0 4px; display: flex; justify-content: space-between; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.stat { border-left: 3px solid var(--sw); padding: 2px 0 2px 8px; }
.stat .k { font-size: 12px; color: var(--ink-2); }
.stat .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.hidden { display: none; }

.chart { width: 100%; min-height: 60px; }
.msg { color: var(--muted); font-size: 13px; padding: 16px 0; }
.err { color: var(--ink-2); font-size: 12px; margin-top: 6px; }

.foot { color: var(--muted); font-size: 12px; padding: 0 16px 24px; max-width: 1600px; margin: 0 auto; }

.tip {
  position: absolute; display: none; pointer-events: none; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); padding: 6px 8px; font-size: 12px; white-space: nowrap;
}
.tip .tt { color: var(--ink-2); margin-bottom: 2px; }
.tip .row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .row b { margin-left: auto; padding-left: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tip .sw { width: 10px; height: 3px; border-radius: 2px; }

/* uPlot chrome in theme colours */
.uplot { font-family: inherit; }
.u-legend { font-size: 12px; color: var(--ink-2); }
.u-legend .u-marker { width: 10px; height: 3px; border-radius: 2px; }
.u-legend th { font-weight: 500; }
