/* Kleuren komen uit de gevalideerde referentiepalette; licht en donker zijn
   allebei apart gekozen, niet automatisch omgeklapt. */
:root {
  color-scheme: light;

  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #ececea;
  --border: #dedcd7;
  --border-strong: #c6c4bd;

  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;

  --series-1: #2a78d6; /* blauw: spanning, SOC */
  --series-2: #eb6834; /* oranje: vermogen, opbrengst */
  --series-3: #1baf7a; /* aqua: stroom */

  --good: #1a7f4b;
  --warn: #9a6400;
  --critical: #c0392b;

  --grid: #e6e5e1;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;

    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242423;
    --border: #35352f;
    --border-strong: #4a4a43;

    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    --good: #4cc38a;
    --warn: #e0a33c;
    --critical: #e66767;

    --grid: #2b2b28;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --border: #35352f;
  --border-strong: #4a4a43;

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --good: #4cc38a;
  --warn: #e0a33c;
  --critical: #e66767;

  --grid: #2b2b28;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

header.site .wrap {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 17px;
  color: var(--text-primary);
  text-decoration: none;
}

.spacer { flex: 1; }

.muted { color: var(--text-muted); font-size: 13px; }

button, .btn {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .btn:hover { border-color: var(--border-strong); }

button[aria-pressed='true'], .btn.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 620;
}

.card h2 a { text-decoration: none; color: inherit; }
.card h2 a:hover { text-decoration: underline; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

/* Kerngetallen: geen grafiek waar één getal het antwoord is. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.tile {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px 14px;
}

.tile .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.tile .value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tile .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 2px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.status-dot.ok { background: var(--good); }
.status-dot.stale { background: var(--warn); }
.status-dot.gone { background: var(--critical); }

.chart-block { margin-top: 20px; }

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
}

.chart {
  position: relative;
  width: 100%;
}

.chart svg { display: block; width: 100%; height: auto; }

.chart .axis text {
  font-size: 11px;
  fill: var(--text-muted);
}

.chart .grid line {
  stroke: var(--grid);
  stroke-width: 1;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity 0.1s;
}

.tooltip .t-label { color: var(--text-secondary); }
.tooltip .t-value { font-variant-numeric: tabular-nums; font-weight: 600; }

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

table.data th, table.data td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

table.data th { color: var(--text-secondary); font-weight: 600; }

.table-wrap { max-height: 320px; overflow: auto; }

.empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 0;
}

form.login {
  max-width: 340px;
  margin: 12vh auto;
}

form.login label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

form.login input {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  margin-bottom: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
}

form.login button { width: 100%; padding: 10px; }

.error {
  color: var(--critical);
  font-size: 13px;
  margin-bottom: 12px;
}
