:root {
  --bg: #10141b;
  --surface: #1a2028;
  --surface-2: #212936;
  --border: #2a3341;
  --text: #edebe6;
  --text-dim: #8891a0;
  --text-faint: #5b6472;
  --copper: #c97b4a;
  --copper-bright: #e2966a;
  --cyan: #4fd1c5;
  --amber: #e8a33d;
  --green: #11d16e;
  --violet: #a78bfa;
  --red: #e8615a;
  --r-sm: 6px;
  --r-md: 10px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(ellipse at top left, rgba(201, 123, 74, 0.06), transparent 45%),
    radial-gradient(ellipse at bottom right, rgba(79, 209, 197, 0.05), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  padding: 20px;
}
/* Filmkorrel in plaats van het rasterlijnen-patroon dat hier stond -- geeft
   de achtergrond diepte zonder een technisch patroon dat om aandacht vraagt.
   `fixed` + negatieve z-index: één korrellaag over de hele viewport, niet
   per element herhaald. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap { max-width: 980px; margin: 0 auto; }

header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; color: var(--copper-bright); text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.eyebrow .dot.live { background: var(--cyan); animation: pulse 2s infinite; }
.eyebrow .dot.err { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(79, 209, 197, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0); }
}
h1 { font-size: 26px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.iconbtn { width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s ease; }
.iconbtn:hover { color: var(--text); border-color: var(--copper); }
.iconbtn svg { width: 17px; height: 17px; }

/* Top nav: one pill per pagina (elk z'n eigen route, geen SPA), plus een
   ronde instellingen-knop uiterst rechts. Staat boven .brand/<h1>, niet
   ernaast -- zo blijft er ruimte voor de pillen zonder de titelregel te
   verdrukken. */
.topNav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.navPill { font-family: var(--sans); font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); cursor: pointer; text-decoration: none; transition: all .15s ease; }
.navPill:hover { color: var(--text); border-color: var(--copper); }
.navPill.active { background: var(--copper); border-color: var(--copper); color: #1a1108; }
.navGear { margin-left: auto; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s ease; }
.navGear:hover { color: var(--text); border-color: var(--copper); }
.navGear svg { width: 16px; height: 16px; }

/* Instellingen-popup: een gecentreerde rechthoek over een gedimde pagina.
   De overlay staat standaard op display:none en wordt met .open zichtbaar --
   het [hidden]-attribuut zou hier niet werken, want display:flex overschrijft
   het. */
.modalOverlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(6, 7, 9, 0.72); }
.modalOverlay.open { display: flex; }
.modal { width: min(520px, 100%); max-height: 85vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55); }
.modalHead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modalHead h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 0; font-weight: 600; }
.modalClose { width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--text-dim); font-size: 20px; line-height: 1; cursor: pointer; transition: all .15s ease; }
.modalClose:hover { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.modalBody { padding: 20px; }
.help { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; margin: 0; }
.help b { color: var(--text-dim); }
.errBox { display: none; margin-bottom: 18px; padding: 12px 14px; border-radius: var(--r-sm); background: rgba(232, 97, 90, 0.08); border: 1px solid rgba(232, 97, 90, 0.35); font-size: 12.5px; color: #f0a8a3; line-height: 1.6; }
.errBox.show { display: block; }
.errBox ul { margin: 6px 0 0 0; padding-left: 18px; }

/* Bovenste rij: de huisillustratie links, meter + saldo gestapeld rechts. */
.topRow { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 760px) { .topRow { grid-template-columns: 1fr; } }

.rightCol { display: flex; flex-direction: column; gap: 16px; }

.balanceCard { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; flex: 1; }
.balanceValue { font-family: var(--mono); font-size: 42px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; margin: 14px 0 8px; font-variant-numeric: tabular-nums; }
.balanceValue.plus { color: var(--green); }
.balanceValue.min { color: var(--copper-bright); }
.balanceSub { font-size: 12px; color: var(--text-faint); line-height: 1.6; }
@media (max-width: 520px) { .balanceValue { font-size: 36px; } }

.savedCard { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.savedValue { font-family: var(--mono); font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; margin: 10px 0 8px; font-variant-numeric: tabular-nums; color: var(--green); }
.savedSub { font-size: 12px; color: var(--text-faint); line-height: 1.6; }

.weatherCard { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.weatherValue { font-family: var(--mono); font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; margin: 10px 0 8px; font-variant-numeric: tabular-nums; color: var(--amber); }
.weatherSub { font-size: 12px; color: var(--text-faint); line-height: 1.6; }

.batteryCard { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.batteryState { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin-top: 10px; }
.batteryState.charging { color: var(--green); }
.batteryState.discharging { color: var(--copper-bright); }
.batterySoc { font-family: var(--mono); font-size: 34px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; margin: 6px 0; font-variant-numeric: tabular-nums; }
.batterySub { font-size: 12px; color: var(--text-faint); line-height: 1.6; }

/* Huis-illustratie: 4 tijdstip-afbeeldingen gestapeld en gekruisfaded, met een
   SVG-laag erbovenop voor de gloeiende energiestromen. Zie static/js/house-hero.js. */
.heroCard { padding: 0; overflow: hidden; position: relative; }
.heroStage { position: relative; width: 100%; aspect-ratio: 892 / 900; background: var(--bg); }
.heroStage img, .heroStage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.heroStage img { object-fit: cover; transition: opacity 1.2s linear; }

.flow, .flowCasing { fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .5s ease; }
.flow.active, .flowCasing.active { opacity: 1; }
.flowCasing { stroke: rgba(6, 8, 14, .6); }
.flowGlow { fill: none; filter: blur(3.5px); opacity: .6; }
.flow.solar, .flowGlow.solar { stroke: var(--amber); }
.flow.battery, .flowGlow.battery { stroke: var(--green); }
.flow.gridImport, .flowGlow.gridImport { stroke: var(--copper-bright); }
.flow.gridExport, .flowGlow.gridExport { stroke: var(--cyan); }
.flow.car, .flowGlow.car { stroke: var(--violet); }

/* font-size here is in SVG user units (the 892x900 viewBox), not screen
   pixels -- the whole hero typically renders at under half that width, so
   this needs to be much larger than a normal label to stay legible. */
.flowLabel { font-family: var(--mono); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .5s ease; }
.flowLabel.active { opacity: 1; }
.flowLabel .bg { fill: #0b0e13; opacity: .82; }
.flowLabel.solar text { fill: var(--amber); }
.flowLabel.battery text { fill: var(--green); }
.flowLabel.gridImport text { fill: var(--copper-bright); }
.flowLabel.gridExport text { fill: var(--cyan); }
.flowLabel.car text { fill: var(--violet); }

/* Alles onder deze streep is detail: nuttig, maar niet waar je als eerste kijkt. */
.detailHead { margin: 26px 0 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); border-top: 1px solid var(--border); padding-top: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 20px; }

/* .gaugeCard zit nu in .rightCol (flex-column, zie hierboven) -- geen
   align-self meer nodig zoals toen hij nog los in de .topRow-grid stond, dat
   liet 'm juist smaller trekken dan de kolom en halverwege afkappen. */
.gaugeCard { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
#gaugeSvg { width: 100%; max-width: 230px; height: auto; }
.readout { text-align: center; margin-top: -22px; }
.readoutValue { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.readoutLabel { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px; color: var(--text-dim); }

.statStack { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 8px; }
.stat .valRow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stat .valRow + .valRow { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); }

.btn { font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; transition: all .15s ease; }
.btn:hover { border-color: var(--copper); color: var(--copper-bright); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btnGhost { background: transparent; }
.stat .valRow .k { font-size: 12.5px; color: var(--text-faint); }
.stat .valRow .v { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.v.copper { color: var(--copper-bright); }
.v.cyan { color: var(--cyan); }

.traceCard { margin-top: 16px; }
.traceHead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.traceHead .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; color: var(--text-faint); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

#stackSvg { display: block; width: 100%; height: auto; touch-action: none; }
/* Live-tegels: dezelfde zes reeksen als de daggrafiek, maar dan de waarde van
   dit moment. Het gekleurde blokje draagt de identiteit; de tekst blijft in de
   gewone inktkleuren staan, zodat cijfers leesbaar blijven. */
.liveTiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.liveTile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; }
.liveTile .lk { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }
.liveTile .lk i { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.liveTile .lv { font-family: var(--mono); font-size: 19px; font-weight: 600; line-height: 1; }
.liveTile.idle .lv { color: var(--text-faint); }

/* De zelfvoorzienend-kaart volgt de opzet van de HomeWizard-app: dagtotalen
   naast de titel, de waarden van het aangewezen kwartier erboven, en de
   asgetallen rechts van de grafiek. */
.ssTop { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.ssTop .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.ssTotals { margin-top: 6px; font-family: var(--mono); font-size: 19px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.ssTotals .unit { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.dateNav { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 6px; }
.dateNavBtn { width: 28px; height: 28px; font-size: 15px; }
#dateSelect { font-family: var(--mono); font-size: 12px; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 8px; cursor: pointer; }
#dateSelect:hover { color: var(--text); border-color: var(--copper); }
.ssReadout { min-height: 42px; text-align: center; margin-bottom: 2px; }
.ssMoment { font-size: 13px; color: var(--text-dim); }
.ssVals { display: flex; justify-content: center; gap: 16px; font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 2px; flex-wrap: wrap; }
.ssCard #stackSvg { display: block; width: 100%; height: auto; touch-action: none; }

footer { margin-top: 16px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); }
