:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --accent: #2a78d6; --accent-ink: #fff;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #262624;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #262624;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --accent: #3987e5;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; overflow-x: hidden; }
.hidden { display: none !important; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-word; }
.lead { font-size: 17px; font-weight: 600; margin: 12px 0 4px; }
.err { color: var(--crit); min-height: 1.4em; }

.top { display: flex; justify-content: space-between; align-items: flex-end; padding: calc(var(--safe-t) + 16px) 16px 8px; }
main { padding: 0 16px calc(84px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid2 .card { margin: 0; }
.row2, .row3 { display: grid; gap: 12px 16px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.kv { display: flex; flex-direction: column; min-width: 0; }
.kv span, .tile span { color: var(--muted); font-size: 12px; }
.kv b { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.tile { display: flex; flex-direction: column; gap: 2px; min-height: 92px; }
.tile b { font-size: 18px; line-height: 1.25; }
.tile small { font-size: 12px; }

.hero { display: flex; align-items: center; gap: 12px; }
#batt { width: 42%; max-width: 170px; flex: none; overflow: visible; }
.soc b { display: block; font-size: 40px; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.soc span { font-size: 14px; display: block; }
#batt .shell { fill: none; stroke: var(--ink-2); stroke-width: 5; }
#batt .cap { fill: var(--ink-2); }
#batt .empty { fill: var(--surface-2); }
#batt .liquid { fill: var(--s1); }
#batt .liquid.low { fill: var(--warn); }
#batt .level { transition: transform 1.2s cubic-bezier(.3,.7,.3,1); }
#batt .wave { animation: wave 4s linear infinite; }
#batt .chev { fill: none; stroke: rgba(255,255,255,.55); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .4s; }
#batt.charging .chev { opacity: 1; animation: up 1.6s linear infinite; }
#batt.discharging .chev { opacity: 1; animation: up 1.6s linear infinite reverse; }
#batt.charging .wave, #batt.discharging .wave { animation-duration: 1.8s; }
#batt .minline { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 6 5; opacity: .8; transition: transform 1.2s; }
#batt .mintext { fill: var(--ink-2); font-size: 13px; transition: transform 1.2s; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-100px); } }
@keyframes up { from { transform: translateY(40px); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { #batt .wave, #batt .chev { animation: none !important; } #batt .level { transition: none; } }
.flow svg { display: block; width: 100%; height: auto; overflow: visible; }
.flow .disc { fill: var(--surface-2); }
.flow .icon { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flow .fval { fill: var(--ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow .flab { fill: var(--muted); font-size: 12px; }
.flow .rail { stroke: var(--grid); stroke-width: 4; stroke-linecap: round; }
.flow .dots { stroke-width: 5; stroke-linecap: round; stroke-dasharray: 0 14; animation: flow 1.5s linear infinite; }
.flow .link.rev .dots { animation-direction: reverse; }
.flow .link.idle .dots { display: none; }
@keyframes flow { from { stroke-dashoffset: 14; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .flow .dots { animation: none; } }
#flowSub { margin: 12px 0 0; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; color: var(--ink-2); padding: 8px; border-radius: 8px; font: inherit; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.15); }

.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.chart .reflabel { fill: var(--ink-2); font-size: 11px; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart.loading { min-height: 120px; }
.chart.loading > * { opacity: .35; transition: opacity .2s; }
/* laad-indicator: draaiend rondje met "Laden…" midden in de grafiek */
.chart.loading::before { content: ""; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -24px 0 0 -14px;
  border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; z-index: 2; }
.chart.loading::after { content: "Laden…"; position: absolute; left: 0; right: 0; top: 50%; margin-top: 12px; text-align: center;
  font-size: 13px; color: var(--ink-2); z-index: 2; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chart.loading::before { animation-duration: 2.4s; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.tip { position: fixed; z-index: 30; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); min-width: 120px; }
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.tip .r i { width: 12px; height: 2px; border-radius: 1px; }
.tip .r b { font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; color: var(--ink); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.good::before { background: var(--good); } .chip.warn::before { background: var(--warn); } .chip.crit::before { background: var(--crit); }
details { margin-top: 12px; } summary { color: var(--accent); font-size: 13px; cursor: pointer; }

.bar { position: relative; height: 28px; background: var(--surface-2); border-radius: 8px; margin: 4px 0 26px; }
.bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: var(--s1); transition: width .6s; }
.bar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); }
.bar .mark span { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar .val { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 600; }

.phases { display: flex; list-style: none; padding: 0; margin: 0; gap: 4px; }
.phases li { flex: 1; text-align: center; font-size: 11px; color: var(--muted); padding: 8px 2px; border-radius: 8px; background: var(--surface-2); }
.phases li.done { color: var(--ink-2); }
.phases li.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.actions { display: grid; gap: 8px; }
button { font: inherit; cursor: pointer; }
.primary, .act { border: 0; border-radius: 12px; padding: 14px; font-weight: 600; background: var(--accent); color: var(--accent-ink); }
.act { background: var(--surface-2); color: var(--ink); text-align: left; border: 1px solid var(--border); }
.act.danger { background: var(--crit); color: #fff; border-color: transparent; }   /* stoppen/afbreken: gevuld rood = bedienbaar */
/* niet bedienbaar: altijd grijs en plat, ongeacht het type knop (primair, rood of secundair) */
.primary:disabled, .act:disabled, .ghost:disabled { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border); opacity: .7; cursor: not-allowed; box-shadow: none; }
.ghost { border: 1px solid var(--border); background: none; color: var(--ink); border-radius: 10px; padding: 8px 12px; }
.row-btn { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.row-btn button { flex: 1; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 10; }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; }
.login label { display: grid; gap: 4px; text-align: left; font-size: 13px; color: var(--ink-2); }
.login input { font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); }
.logo { width: 56px; margin: 0 auto; fill: none; stroke: var(--accent); stroke-width: 3; }
.logo .fill { fill: var(--accent); stroke: none; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: end center; padding: 16px 16px calc(16px + var(--safe-b)); z-index: 40; }
.modal .card { width: 100%; max-width: 480px; margin: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90vw; }

@media (max-width: 380px) { .row3 { grid-template-columns: 1fr 1fr; } .hero { flex-direction: column; } #batt { width: 50%; } }

/* PV */
.pv-total { display: flex; flex-direction: column; margin-bottom: 12px; }
.pv-total b { font-size: 34px; font-weight: 700; line-height: 1.1; }
.pv-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pv-table th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px 0; }
.pv-table th:first-child, .pv-table td:first-child { text-align: left; }
.pv-table td { text-align: right; padding: 8px 0 8px 8px; border-top: 1px solid var(--border); font-weight: 600; white-space: nowrap; font-size: 14px; }
.pv-table td:first-child { white-space: nowrap; padding-left: 0; }
.pv-table td:first-child { font-weight: 500; }
.pv-table small { font-weight: 400; display: block; margin-left: 18px; font-size: 11px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: baseline; }
.k1 { background: var(--s1); } .k2 { background: var(--s2); } .k3 { background: var(--s3); }
.share { display: flex; gap: 2px; height: 10px; margin-top: 12px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.share i { display: block; height: 100%; transition: flex-grow .6s; }
.tabs button { padding: 4px 2px; }
.pv-table tr.tot td { font-weight: 700; }
.pack-table { margin-top: 12px; }
.pack-table td { font-size: 13px; padding: 6px 0 6px 6px; }
.pack-table .chip { font-weight: 500; padding: 2px 8px; font-size: 11px; }
.legend i.dash { width: 20px; height: 2px; border: 0; background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 8px) !important; }
.legend i.hatch { width: 12px; height: 8px; border-radius: 2px; background: repeating-linear-gradient(45deg, var(--ink-2) 0 2px, transparent 2px 4px) !important; }
.sub2 { margin-top: 14px; }
#c-celld { margin-bottom: 14px; }
/* kijkmodus: geen bediening */
body.viewer .actions, body.viewer .bal-controls { display: none !important; }

/* kop-illustratie (cartoon): op elk tabblad achter de kopregel; grond in de paginakleur zodat de kaarten erin doorlopen */
#app { position: relative; }
.top, main { position: relative; z-index: 1; }
.top { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; }
.top h1, .top #conn { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.35); }
.top #conn { grid-column: 1 / -1; margin: 2px 0 0; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; color: #fff; border: 1px solid rgba(255,255,255,.55); background: rgba(0,0,0,.2); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn .ic-out { display: none; } body:not(.viewer) .iconbtn .ic-out { display: block; } body:not(.viewer) .iconbtn .ic-in { display: none; }
main .page { padding-top: 160px; }
.ev-head { display: flex; flex-direction: column; margin-bottom: 10px; } .ev-head b { font-size: 24px; line-height: 1.2; }
.tabs button { font-size: 10px; } .tabs svg { width: 22px; height: 22px; }
#c-evdays { margin-bottom: 12px; }
/* breed scherm (desktop): app als kolom van 720 px, illustratie even breed */
@media (min-width: 760px) {
  .scene-wrap { left: 50%; right: auto; width: 720px; height: 430px; transform: translateX(-50%); }
  main .page { padding-top: 300px; }
  .top { max-width: 720px; margin: 0 auto; }
  .tabs { max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0; }
}

.seg-nb { white-space: nowrap; }
#bl-sub:empty { display: none; }
.tom-note { margin: 0 4px 10px; }
#rte-bc, #rte-bd { font-size: 17px; white-space: nowrap; }
.chart .tick.unit { font-size: 9px; }
.chart .legend { margin-bottom: 18px; }   /* ruimte tussen legenda en wat eronder staat (waarden, details) */
.legend i.sw { width: 9px; height: 9px; border-radius: 2px; }
/* handmatig laden/ontladen (Sturing) */
.man-status { font-weight: 600; margin: 0 0 12px; }
.man-form .seg { margin-bottom: 12px; }
.man-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.man-fields input, .man-fields select { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--line, #333); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; }
.man-form .row-btn { display: flex; gap: 10px; } .man-form .row-btn button { flex: 1; text-align: center; }
body.viewer .man-form { display: none; }
.chart .tick.sm { font-size: 8.5px; }
#bl-blocks { font-size: 14px; line-height: 1.35; }
/* planning balanceerlading (Balanceren) */
.bp-fields { display: grid; grid-template-columns: 1fr; gap: 12px; }
.bal-plan input { box-sizing: border-box; padding: 10px; border-radius: 10px; border: 1px solid var(--line, #333); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; margin-top: 4px; }
.bal-plan input[type=date] { width: 100%; min-height: 44px; }
.stepper { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.stepper input { width: 3.2em; text-align: center; margin-top: 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button { min-width: 44px; min-height: 44px; font-size: 20px; padding: 0; }
.stepper .unit { color: var(--ink-2); font-weight: 400; }
.bal-plan .row-btn { flex-wrap: wrap; }
body.viewer .bal-plan .row-btn, body.viewer .stepper button { display: none; }
/* installatiehint (PWA) */
.install { border-color: var(--s1); }
.install h2 { margin-top: 0; }
.install p { margin: 0; line-height: 1.45; }
.install .ic { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; margin: 0 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install .row-btn { margin-top: 12px; }
.kv small { display: block; font-size: 12px; margin-top: 2px; }
/* uitleg fasen balanceerlading */
.phase-help { margin: 10px 0 0; line-height: 1.4; }
.phase-help dt { font-weight: 600; color: var(--ink); margin-top: 8px; }
.phase-help dd { margin: 2px 0 0; }
/* laden bedienen (Laadpaal) */
.ev-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.ev-btns button { min-height: 44px; text-align: center; }
.evc-soc input { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--line, #333); background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 600; }
body.viewer .ev-btns, body.viewer .evc-soc { display: none; }
/* laadplan Tibber (Laadpaal) */
.plan-list { list-style: none; padding: 0; margin: 8px 0 0; }
.plan-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px; }
.plan-list li:first-child { border-top: 0; }
.plan-list .muted { white-space: nowrap; }
.small-lead { font-size: 15px; }
.man-btns button { text-align: center; }
.man-check { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: 14px; color: var(--ink); min-height: 44px; }
.man-check input { width: 22px; height: 22px; accent-color: var(--accent); }
body.viewer .man-check { display: none; }
/* ---------- desktopoverzicht (31-10): vanaf 1100 px, body.desk-mode (desk.js) ---------- */
.top-btns { display: flex; gap: 8px; }
body.desk-mode .page, body.desk-mode .tabs { display: none !important; }
body.desk-mode { --sceneH: clamp(260px, 23vw, 380px); }
body.desk-mode .scene-wrap { left: 0; right: 0; width: auto; transform: none; height: var(--sceneH); }
body.desk-mode .top { max-width: 1640px; margin: 0 auto; padding: 18px 32px 8px; }
body.desk-mode main { max-width: 1640px; padding: calc(var(--sceneH) * .93 - 92px) 32px 48px; }   /* bomen en struiken helemaal zichtbaar */
body.desk-mode #install { max-width: 760px; margin: 0 auto 16px; }
.dgrid { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(240px, .85fr);
  grid-template-areas: "tibber loads crit side" "zaptec mp enph side" "sma bat mppt side"; column-gap: 104px; row-gap: 28px; }
.dside { grid-area: side; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }
.blk { position: relative; z-index: 1; display: flex; flex-direction: column; text-align: left; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 0; cursor: pointer; overflow: hidden; min-height: 168px; transition: border-color .15s, box-shadow .15s; }
.blk:hover, .blk:focus-visible { border-color: var(--accent); box-shadow: 0 4px 18px rgba(0,0,0,.25); outline: none; }
.blk .bh { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.blk .bi { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.blk .bn { flex: 1 1 auto; min-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk .bx { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.blk .bvrow { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 4px; }
.blk .bv { font-size: clamp(24px, 2vw, 32px); font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.blk .bu { font-size: 13px; color: var(--muted); }
.blk .bs { display: block; flex: 1 0 52px; min-height: 52px; margin: 0 -16px; position: relative; }
.blk .bs svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bsline { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.bsline.dash { stroke-dasharray: 4 3; }
.bsline.dot { stroke-dasharray: 1 3; stroke-width: 1.2; opacity: .9; }
.bsarea { opacity: .14; stroke: none; }
.bs0 { stroke: var(--axis); stroke-width: 1; vector-effect: non-scaling-stroke; }
.bsnow { stroke: var(--axis); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 2; }
.blk .bf { display: block; margin: 0 -16px; padding: 9px 16px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk.small { min-height: 0; padding-top: 9px; }
.blk.small .bvrow { margin: 2px 0 0; }
.blk.small .bv { font-size: 20px; }
.blk.small .bs { flex: 0 0 26px; min-height: 26px; }
.blk.small .bf { padding: 6px 16px; }
/* omvormer: klein blok in het midden; AC-in links, AC-out rechts en DC-bus onder, heel subtiel */
/* omvormer: even breed als de andere blokken, productfoto in het midden; AC-in/AC-out/DC-bus buiten het blok bij de lijnen */
.blk-mp { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.blk-mp .mpbox { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; justify-content: center; padding: 6px 0 10px; }
.blk-mp .mpsp { font-size: 13px; color: var(--ink-2); margin-top: -4px; text-align: center; }
.blk-mp .mpimg { height: clamp(96px, 8.5vw, 150px); width: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
.blk-mp .bv { font-size: 15px; font-weight: 600; text-align: center; }
.mplab { position: absolute; z-index: 2; font-size: 10px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; white-space: pre-line; text-align: center; pointer-events: none; }
.mplab-in { text-align: right; } .mplab-out { text-align: left; } .mplab-dc { text-align: left; }
/* stroomlijnen achter de blokken */
.dlinks { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.dl .rail { fill: none; stroke: var(--axis); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dl .dots { fill: none; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 0 14; animation: flow 1.5s linear infinite; }
.dl.rev .dots { animation-direction: reverse; }
.dl.idle .dots { display: none; }
/* popup met de kaarten van een blok */
body.noscroll { overflow: hidden; }
.detail { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 3vh 3vw; }
.dbox { width: min(1320px, 100%); max-height: 94vh; display: flex; flex-direction: column; background: var(--page); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); overflow: hidden; }
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 8px; }
.dhead h2 { font-size: 20px; color: var(--ink); margin: 0; }
.dclose { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font-size: 16px; }
.dclose:hover { border-color: var(--accent); }
.dtabs { margin: 4px 20px 8px; display: flex; gap: 8px; background: none; padding: 0; }
.dtabs .subbtn { flex: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.dtabs .subbtn:hover { border-color: var(--accent); }
.dbox.narrow { width: min(860px, 100%); }
.detail2 { z-index: 25; background: rgba(0,0,0,.45); }
.dbody { overflow: auto; padding: 8px 20px 20px; }
/* kaarten in kolommen (geen lege gaten onder korte kaarten); een periodekeuze loopt over de volle breedte */
.dpane { columns: 2 440px; column-gap: 12px; }
.dpane.one { columns: 1; max-width: 820px; }
.dpane > .card, .dpane > .grid2 { break-inside: avoid; margin: 0 0 12px; }
.dpane > .unit:not(.card):not(.grid2) { column-span: all; margin: 0 0 12px; }
.dpane .flow svg { max-height: 300px; }
/* vaste kolommen (blocks.js 'cols') */
.dpane.cols { columns: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: start; }
.dcol > .card, .dcol > .grid2 { margin: 0 0 12px; }
/* tabel in de stijl van het energiedashboard van Home Assistant */
.etable { margin-top: 12px; }
.etab { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.etab th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 0; }
.etab th:nth-child(2) { text-align: left; }
.etab td { padding: 9px 0 9px 10px; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
.etab td:nth-child(2) { text-align: left; white-space: normal; padding-left: 4px; }
.etab td.sw { width: 30px; padding-left: 0; } .etab td.sw i { display: inline-block; width: 24px; height: 14px; border-radius: 4px; vertical-align: middle; border: 1px solid rgba(255,255,255,.15); }
.etab tr.tot td { font-weight: 700; border-top: 1px solid var(--axis); }
.etab tr.tot + tr td { border-top: 2px solid var(--axis); }
.etab tr.sub td { color: var(--muted); font-size: 13px; padding-top: 4px; padding-bottom: 4px; } .etab tr.sub td:nth-child(2) { padding-left: 18px; }
/* laadsessie (zoals "Kosten tot nu toe" in de Tibber-app) */
.sess-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.sess-head b { font-size: 19px; } .sess-head small { display: block; font-size: 13px; margin-top: 2px; } .sess-cost { font-size: 22px !important; }
.ktab { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.ktab td { padding: 6px 0; color: var(--ink-2); } .ktab td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.ktab tr.tot td { color: var(--ink); font-weight: 700; } .ktab tr.sep td { border-top: 1px solid var(--border); padding-top: 12px; }
.es-pick { margin: 0 0 14px; } .es-pick select { margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font: inherit; }
/* voorlopige factuur (alleen beheerder) */
body.viewer .admin-only { display: none !important; }
.inv-pick select { margin-top: 4px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font: inherit; }
.inv-head { margin: 10px 0 2px; }
.ktab td small { display: block; font-size: 12px; margin-top: 1px; }
.ere-tab td, .ere-tab th { font-size: 13px; }
.ktab.inv tr.big td { font-size: 18px; padding-top: 10px; }
.inv-h { font-size: 15px; margin: 18px 0 2px; color: var(--ink); }
.pv-all th, .pv-all td { font-size: 13px; } .pv-all td { padding-left: 6px; }
.dpane .chart svg { max-height: 320px; }
/* kaartje met de positie van de auto (alleen beheerder) */
.carmap { height: 280px; border-radius: 12px; overflow: hidden; margin-top: 14px; background: var(--surface-2); }
.carpin svg { width: 34px; height: 34px; transition: transform .6s; overflow: visible; }
.carpin circle { fill: rgba(57,135,229,.28); stroke: #fff; stroke-width: 2; }
.carpin path { fill: #3987e5; stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; }
.carpin svg.still path { opacity: .85; }
.small-seg { margin: 12px 0 8px; }
/* ---------- Lynx Shunt en vier batterijpacks (31-10, v10) ---------- */
.dgrid { grid-template-areas: "tibber loads crit side" "zaptec mp enph side" "sma bat mppt side" "packs packs packs side"; }
.dpacks { grid-area: packs; display: flex; gap: 12px; position: relative; z-index: 1; margin-top: 28px; }
.blk-bat .lxbox { display: flex; align-items: center; gap: 14px; flex: 1; padding: 8px 0 6px; }
.blk-bat .lximg { width: 44%; max-width: 150px; height: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
.blk-bat .lxval { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.blk-bat .lxsub { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.blk-bat .bs { flex: 0 0 34px; min-height: 34px; }
.blk .bvrow .bimg { margin-left: auto; height: 44px; width: auto; max-width: 40%; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); align-self: center; }
/* pack: smalle tegel met geanimeerde batterij; rood bij storing, grijs als het pack uitschakelt */
.blk.pk { flex: 1 1 0; min-width: 0; min-height: 0; align-items: center; text-align: center; padding: 10px 8px 0; gap: 2px; }
.blk.pk .pkn { font-size: 12px; color: var(--ink-2); }
.blk.pk .pbatt { width: 52px; height: 86px; margin: 4px 0 2px; overflow: visible; }
.blk.pk .bv { font-size: 20px; }
.blk.pk .pkva { font-size: 11px; color: var(--ink-2); white-space: pre-line; font-variant-numeric: tabular-nums; line-height: 1.3; }
.blk.pk .bf { align-self: stretch; margin: 6px -8px 0; padding: 6px 6px; font-size: 10.5px; white-space: pre-line; text-align: center; }
.pbatt .pcap { fill: var(--ink-2); } .pbatt .pshell { fill: none; stroke: var(--ink-2); stroke-width: 3; } .pbatt .pempty { fill: var(--surface-2); }
.pbatt .pliquid { fill: var(--s3); } .pbatt.low .pliquid { fill: var(--warn); }
.pbatt .plevel { transition: transform 1.2s cubic-bezier(.3,.7,.3,1); }
.pbatt .pwave { animation: pwave 3.2s linear infinite; }
.pbatt .pchev { fill: none; stroke: rgba(255,255,255,.6); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.pbatt.charging .pchev { opacity: 1; animation: pup 1.4s linear infinite; }
.pbatt.discharging .pchev { opacity: 1; animation: pup 1.4s linear infinite reverse; transform-box: fill-box; }
.pbatt.discharging .pchev path { transform: scaleY(-1); transform-box: fill-box; transform-origin: center; }
.pbatt.charging .pwave, .pbatt.discharging .pwave { animation-duration: 1.6s; }
@keyframes pwave { from { transform: translateX(0); } to { transform: translateX(-20px); } }
@keyframes pup { from { transform: translateY(18px); } to { transform: translateY(0); } }
.blk.pk.alarm .pkn::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: 6px; vertical-align: middle; }
.blk.pk.fault { border-color: var(--crit); box-shadow: 0 0 0 1px var(--crit) inset; }
.blk.pk.fault .pliquid { fill: var(--crit); } .blk.pk.fault .pshell { stroke: var(--crit); } .blk.pk.fault .bf { color: var(--crit); }
.blk.pk.off { opacity: .45; filter: grayscale(1); }
.blk.pk.off .pliquid { fill: var(--muted); }
/* mobiel: packtabel met toestand */
.pack-table tr.pk-off td { color: var(--muted); }
.pack-table tr.pk-fault td:first-child { color: var(--crit); font-weight: 700; }
.packdet summary { margin-top: 4px; }
.cellbars { max-height: 180px; }

/* ===================== verwarming-app (03-11-2026) ===================== */

/* storing Nefit-cloud */
.warnbar { border-color: color-mix(in srgb, var(--warn) 60%, var(--border)); color: var(--ink); font-size: 14px; }
.warnbar b { color: var(--warn); }
.stale { opacity: .55; }

/* overzicht: tegels als knop */
button.tile { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.grid2 .tile.wide { grid-column: 1 / -1; }

/* productillustraties */
.ketelhead { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.prodimg { width: 72px; height: auto; flex: none; filter: drop-shadow(0 3px 8px rgba(0,0,0,.4)); }
.prodimg.wide { width: 110px; }
.room .prodimg { width: 120px; }
.kv.big b { font-size: 22px; }

/* ruimtekaart */
.room .rhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.room .rtemp { font-size: 38px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; }
.room .rsub { color: var(--muted); font-size: 13px; }
.room h3 { font-size: 13px; color: var(--ink-2); margin: 16px 0 8px; font-weight: 600; }

/* bediening (alleen beheerder) */
.ctl { margin-top: 12px; display: grid; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font-size: 20px; font-weight: 600; }
.stepper .sv { min-width: 84px; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper .go { width: auto; padding: 0 14px; font-size: 14px; background: var(--accent); color: var(--accent-ink); border: 0; }
.modes { display: flex; flex-wrap: wrap; gap: 6px; }
.modes button { border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.modes button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.ctl .lab { font-size: 12px; color: var(--muted); }
.ctl button:disabled { opacity: .45; cursor: not-allowed; }
.setrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.setrow label { font-size: 13px; color: var(--ink-2); }
.setrow input { width: 110px; font: inherit; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); }
.setrow .act { padding: 10px 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--ink-2); }

/* energiestromen (mobiel) */
.flow .node rect { fill: var(--surface-2); stroke: var(--border); }
.flow .nlab { fill: var(--muted); font-size: 11px; }
.flow .nval { fill: var(--ink); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow .link .rail { stroke: var(--grid); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.flow .link .dots { fill: none; }

/* desktop: raster van de verwarming-app */
.dgrid { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(240px, .85fr);
  grid-template-areas: "gas ketel woon airco side" "fornuis boiler slaap airco side" "jaar jaar bad net side"; column-gap: 72px; row-gap: 28px; }
.blk .bimg.room { height: 30px; max-width: 46%; }
.blk-ketel .bvrow .bimg { height: 64px; }
.blk-airco .bvrow .bimg { height: 56px; }
.blk-jaar .bs { flex: 1 0 70px; min-height: 70px; }
.blk.stale .bv { opacity: .55; }
/* waarde en eenheid op één regel; tekst (ketelstatus) kleiner */
.blk .bvrow { flex-wrap: nowrap; min-width: 0; }
.blk .bv { white-space: nowrap; }
.blk .bu { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.blk-ketel .bv, .blk-boiler .bv { font-size: clamp(18px, 1.5vw, 24px); white-space: normal; }
.blk .bvrow .bimg { flex: 0 1 auto; min-width: 0; }
@media (max-width: 520px) { .room .row3, #u-ketel .row3, #u-boiler .row3 { grid-template-columns: 1fr 1fr; } }
.kv b { hyphens: manual; overflow-wrap: break-word; }
.etab th { padding-left: 10px; } .etab th:first-child { padding-left: 0; }

/* 04-11: vijver en warmtepomp vijver (vierde rij), labels met vermogen bij de lijnen */
.dgrid { grid-template-areas: "gas ketel woon airco side" "fornuis boiler slaap airco side" "jaar jaar bad net side" "jaar jaar vijver wp side"; }
.dlab { position: absolute; z-index: 2; font-size: 11px; line-height: 1.2; color: var(--ink-2); background: var(--page); padding: 1px 5px; border-radius: 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; transform: translate(-50%, -50%); }
.dlab.idle { display: none; }
.flow .flab2 { fill: var(--ink-2); font-size: 10.5px; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.tabs button { font-size: 10px; }
@media (max-width: 520px) { #u-vijver .row3, #u-wp .row3, #u-net .row3 { grid-template-columns: 1fr 1fr; } }
.blk .bsub { font-size: 12.5px; color: var(--ink-2); margin: -2px 0 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ktab td small.muted { color: var(--muted); font-size: 11.5px; }
