:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.10);
  --button: #0b0b0b;
  --button-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-wash: rgba(57, 135, 229, 0.16);
    --critical-wash: rgba(208, 59, 59, 0.18);
    --button: #f0efec;
    --button-text: #0b0b0b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
header h1 { font-size: 22px; margin: 0; flex: 1 1 auto; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
.dot.online { background: var(--good); }
.link-button { background: none; border: 0; color: var(--text-secondary); text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 16px; min-width: 0; }
.card h2 { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; }
.big-number { font-size: 40px; font-weight: 650; line-height: 1.1; }
.sub { color: var(--text-secondary); font-size: 14px; }
.muted { color: var(--text-muted); }

.meter { position: relative; height: 12px; border-radius: 0; background: var(--grid); margin: 14px 0 6px; overflow: visible; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0; background: var(--series-1); width: 0; transition: width 0.4s; }
.meter-mark { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--text-primary); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 0; font-weight: 600; font-size: 14px; }
.badge.full { background: var(--critical-wash); color: var(--text-primary); }
.badge.full .icon { color: var(--critical); }
.badge.ok { background: var(--series-1-wash); color: var(--text-primary); }
.badge.ok .icon { color: var(--good); }

.level-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.level-row input[type="range"] { flex: 1; accent-color: var(--series-1); min-width: 0; }
.level-value { font-size: 22px; font-weight: 650; min-width: 56px; text-align: right; }
button.primary { background: var(--button); color: var(--button-text); border: 0; border-radius: 0; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; }
button.primary:disabled { opacity: 0.4; cursor: default; }
.save-note { min-height: 20px; margin-top: 8px; }

.range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 24px 0 12px; }
.range-row h2 { margin: 0; font-size: 18px; flex: 1 1 auto; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 0; overflow: hidden; }
.segmented button { background: var(--surface); color: var(--text-secondary); border: 0; padding: 7px 12px; font: inherit; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.selected { background: var(--button); color: var(--button-text); font-weight: 600; }

.chart-card { margin-bottom: 16px; }
.chart-card .chart-title { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.chart { position: relative; width: 100%; height: 220px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.chart .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--series-1-wash); }
.chart .reference { stroke: var(--text-secondary); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .reference-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.hover { opacity: 0.75; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.chart .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .empty { fill: var(--text-muted); font-size: 13px; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 0; padding: 6px 10px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); white-space: nowrap; display: none; z-index: 2;
}
.tooltip strong { font-variant-numeric: tabular-nums; }

details summary { cursor: pointer; color: var(--text-secondary); font-size: 14px; margin-top: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-secondary); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; }

.login-box { max-width: 360px; margin: 12vh auto 0; }
.login-box input[type="password"] {
  width: 100%; padding: 10px 12px; border-radius: 0; border: 1px solid var(--axis);
  background: var(--page); color: var(--text-primary); font: inherit; margin: 8px 0 14px;
}
.error { color: var(--critical); font-weight: 600; }
