: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);
  --series-1: #2a78d6;
  --critical: #d03b3b;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    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);
    --series-1: #3987e5;
  }
}
* { box-sizing: border-box; }
/* Author display rules (e.g. .login{display:grid}) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 var(--font); background: var(--page); color: var(--text-primary); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 24px 0 10px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; font-weight: normal; }
.error { color: var(--critical); margin: 0; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 12px; }
button[type=submit] { background: var(--series-1); color: #fff; border-color: transparent; }
button.ghost { background: transparent; }
select, input { border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 8px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; }

.login:not([hidden]) { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 24px; display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; color: var(--text-secondary); }

#app { max-width: 1200px; margin: 0 auto; padding: 16px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top #who { margin-left: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--text-secondary); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface-1); }
.seg button[aria-pressed=true] { background: var(--series-1); color: #fff; }
.params summary { cursor: pointer; color: var(--text-secondary); }
.param-list { position: absolute; z-index: 5; margin-top: 6px; max-height: 320px; overflow: auto; padding: 8px 12px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; display: grid; gap: 4px; min-width: 220px; max-width: calc(100vw - 32px); }
.param-list label { color: var(--text-primary); }
.status { min-height: 1.4em; color: var(--text-secondary); margin: 12px 0 0; }
.status.err { color: var(--critical); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { padding: 12px; }
.tile .name { color: var(--text-secondary); font-size: 12px; overflow-wrap: anywhere; }
.tile .value { font-size: 22px; margin-top: 2px; }
.tile .unit { font-size: 13px; color: var(--text-secondary); margin-left: 3px; }
.tile .when { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 12px; }
.chart { padding: 12px 12px 8px; transition: opacity .15s; }
.chart.loading { opacity: .5; }
.chart-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.chart-head h3 { font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.chart-head .meta { color: var(--text-muted); font-size: 12px; }
.chart-head button { margin-left: auto; padding: 2px 8px; font-size: 12px; }
.chart svg { display: block; width: 100%; height: 200px; touch-action: none; }
.chart svg text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .empty { color: var(--text-muted); padding: 40px 0; text-align: center; }
.table-wrap { overflow-x: auto; max-height: 240px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 12px; }
th, td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--grid); }
td.num { text-align: right; }

.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.12); font-size: 12px; }
.tooltip strong { font-size: 14px; display: block; }
.tooltip .key { display: inline-block; width: 12px; height: 2px; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.param-items { display: grid; gap: 4px; }
#param-filter { width: 100%; }
