:root {
  color-scheme: light dark;

  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* Series colours follow the entity, not the chart: grid is always blue,
     load always orange, battery always aqua. Validated for CVD in both
     modes; on this light surface aqua and yellow fall below 3:1, so every
     series carries a visible label. */
  --grid-series: #2a78d6;
  --load-series: #eb6834;
  --batt-series: #1baf7a;
  --batt-out-series: #eda100;

  --good: #0ca30c;
  --critical: #d03b3b;
  --accent: #2a78d6;

  /* sequential ramp for the outage heatmap, light→dark on a light surface */
  --heat-1: #f7dcdc;
  --heat-2: #eeb0b0;
  --heat-3: #e28080;
  --heat-4: #d35151;
  --heat-5: #b32e2e;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --grid-series: #3987e5;
    --load-series: #d95926;
    --batt-series: #199e70;
    --batt-out-series: #c98500;
    --accent: #3987e5;
    /* dark→light on a dark surface: its own steps, not a flip of the above */
    --heat-1: #3d1e1e;
    --heat-2: #5c2626;
    --heat-3: #8a3333;
    --heat-4: #b84040;
    --heat-5: #e05555;
  }
}
:root[data-theme="dark"] {
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --grid-series: #3987e5;
  --load-series: #d95926;
  --batt-series: #199e70;
  --batt-out-series: #c98500;
  --accent: #3987e5;
  --heat-1: #3d1e1e;
  --heat-2: #5c2626;
  --heat-3: #8a3333;
  --heat-4: #b84040;
  --heat-5: #e05555;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---- auth pages (setup / login) ---- */
body.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.01em; }
p.sub { margin: 0 0 20px; color: var(--text-secondary); font-size: 14px; }
label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text-primary);
  background: var(--plane);
  border: 1px solid var(--baseline);
  border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.card button {
  width: 100%;
  margin-top: 20px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.card button:hover { filter: brightness(1.07); }
.hint { margin-top: 8px; font-size: 12.5px; color: var(--text-secondary); }
.error {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--critical);
  border: 1px solid var(--critical);
  border-radius: 8px;
}
