
/* Layout: werkbank — modelnavigatie links, kaart of blok in het midden, herkomst als lade rechts */
:root {
  --bg: #eef1f4; --surface: #ffffff; --surface-2: #f5f7f9; --ink: #17212b; --muted: #5a6776; --line: #d6dde4;
  --accent: #0b6e69; --accent-ink: #ffffff; --accent-soft: rgba(11, 110, 105, .10);
  --calc: #6b4fbb; --calc-soft: rgba(107, 79, 187, .10);
  --master: #9a5f0c; --master-soft: #fbf0dc; --bad: #b42318; --bad-soft: #fdecea; --warn-soft: #fff4d6;
  --tint: #e9edf1; --shadow: 0 8px 28px rgba(20, 33, 45, .16);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1318; --surface: #151c23; --surface-2: #1b242d; --ink: #e5eaef; --muted: #95a2b0; --line: #2a3541;
    --accent: #3fb6ac; --accent-ink: #06201e; --accent-soft: rgba(63, 182, 172, .15);
    --calc: #a993ec; --calc-soft: rgba(169, 147, 236, .15);
    --master: #e3a64c; --master-soft: #2c2213; --bad: #f2786d; --bad-soft: #3a1f1c; --warn-soft: #33290f;
    --tint: #222c36; --shadow: 0 8px 28px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1318; --surface: #151c23; --surface-2: #1b242d; --ink: #e5eaef; --muted: #95a2b0; --line: #2a3541;
  --accent: #3fb6ac; --accent-ink: #06201e; --accent-soft: rgba(63, 182, 172, .15);
  --calc: #a993ec; --calc-soft: rgba(169, 147, 236, .15);
  --master: #e3a64c; --master-soft: #2c2213; --bad: #f2786d; --bad-soft: #3a1f1c; --warn-soft: #33290f;
  --tint: #222c36; --shadow: 0 8px 28px rgba(0, 0, 0, .5); color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.45; }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
#root { min-height: 100%; display: flex; flex-direction: column; }
.app { flex: 1; display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
.band { grid-column: 1 / -1; background: var(--master-soft); color: var(--master); font-size: 12.5px; padding-block: 6px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.topbar h1 { font-size: 20px; letter-spacing: -.01em; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumbs button { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; }
.spacer { flex: 1; }
.calc { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.calc.busy .dot { background: var(--master); animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .calc.busy .dot { animation: none; } .stale { transition: none !important; } }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.rolesel { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.rolesel select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 5px 8px; color: var(--ink); }

.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 12px 24px max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup > span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 8px 4px; }
.navitem { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; background: transparent; text-align: left; padding: 5px 8px; border-radius: 7px; cursor: pointer; }
.navitem:hover { background: var(--surface-2); }
.navitem[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.navitem small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.navitem.sub { padding-left: 20px; }
.kdot { width: 9px; height: 9px; border-radius: 3px; flex: none; border: 1.25px solid var(--muted); display: inline-block; }
.k-lijst { background: var(--tint); } .k-gedeeld { background: var(--tint); border-color: var(--master); } .k-aanname { border-style: dashed; }
.k-invoer { background: transparent; } .k-berekend { background: var(--calc-soft); border-color: var(--calc); } .k-uitvoer { background: var(--accent-soft); border-color: var(--accent); border-width: 2px; } .k-extern { border-style: dotted; border-color: var(--accent); }
.log { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.log b { color: var(--ink); font-weight: 500; }

.main { padding-block: 18px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.head .t { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.head h2 { font-size: 26px; letter-spacing: -.015em; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--master); }
.chip.master { background: var(--master-soft); border-color: transparent; color: var(--master); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 500; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); padding: 4px 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.pad { padding: 14px 16px; }
.linkchip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12.5px; }
.linkchip:hover { border-color: var(--accent); color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; max-width: 78ch; }
.notice { border-radius: 8px; padding: 8px 12px; font-size: 13px; background: var(--warn-soft); }

.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
table.grid thead th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--surface-2); }
table.grid .r { text-align: right; }
table.grid tfoot td, table.grid tr.sub td { font-weight: 600; background: var(--surface-2); }
table.grid tr.grand td { font-weight: 700; border-top: 2px solid var(--ink); }
table.grid tr.group td { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface); padding-top: 12px; }
table.grid tbody tr:hover td { background: var(--accent-soft); }
table.grid tr.locked td { color: var(--muted); }
table.grid td:first-child, table.grid th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.grid thead th:first-child, table.grid tfoot td:first-child, table.grid tr.sub td:first-child { background: var(--surface-2); }
.cellbtn { border: 0; background: transparent; cursor: pointer; padding: 2px 4px; border-radius: 4px; text-align: right; width: 100%; color: inherit; font: inherit; }
.cellbtn:hover { background: var(--accent-soft); color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cellin { width: 72px; text-align: right; border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 3px 5px; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.cellin.wide { width: 110px; }
.cellin.text { text-align: left; width: 170px; font-family: var(--font-body); }
.cellin:hover { border-color: var(--line); }
.cellin:focus { border-color: var(--accent); background: var(--surface); outline: none; }
select.inline { border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 4px; cursor: pointer; }
select.inline:hover { border-color: var(--line); }
select.inline:disabled { cursor: default; }
.stale { opacity: .38; transition: opacity .2s; }
.ic { width: 12px; height: 12px; flex: none; vertical-align: -1px; }
.ic.master { color: var(--master); }
.addrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.addrow select, .addrow input { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 5px 8px; color: var(--ink); }

.mapwrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.info .row { gap: 6px; }
.mapbox { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.mapbox svg { display: block; }
.node { cursor: pointer; }
.node:focus { outline: none; }
.node:focus-visible rect.frame { stroke: var(--accent); stroke-width: 3; }
.info { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.info h3 { font-size: 18px; }
.kv { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.kv > span { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); padding: 4px 8px 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi span { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi strong { font-family: var(--font-data); font-size: 21px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi.lead strong { color: var(--accent); }
.kpi small { color: var(--muted); font-size: 12px; }
.bars { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.barrow { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) 110px; gap: 10px; align-items: center; font-size: 13px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar > i.cost { background: var(--master); }
.bar > i.stel { background: var(--calc); }

.scrim { position: fixed; inset: 0; background: rgba(10, 16, 22, .35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); box-shadow: var(--shadow); z-index: 21; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) 18px; }
.drawer h3 { font-size: 20px; }
.formula { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.drill { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.drill > * { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; }
.drill > *:last-child { border-bottom: 0; }
.drill button { cursor: pointer; }
.drill button:hover { background: var(--accent-soft); }
.drill .lbl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drill .lbl small { color: var(--muted); font-size: 12px; white-space: normal; }
.drill .tot { background: var(--surface-2); font-weight: 600; }
.dialog { position: fixed; z-index: 31; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(820px, calc(100% - 24px)); max-height: calc(100% - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.scrim.top { z-index: 30; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
textarea#paste-input { width: 100%; min-height: 100px; border: 2px dashed var(--line); border-radius: 10px; background: var(--surface-2); padding: 12px; font-family: var(--font-data); font-size: 12.5px; resize: vertical; }
.toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: calc(100% - 32px); }
.lockbox { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 24px; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
  .navgroup { min-width: 160px; }
  .log { display: none; }
  .barrow { grid-template-columns: 110px minmax(0, 1fr) 90px; }
}

/* Inloggen */
.inlog { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.inlogkaart { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.inlogkaart h1 { font-size: 24px; letter-spacing: -.01em; }
.inlogkaart .btn { width: 100%; justify-content: center; }
.veld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.veld input { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.veld input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.qr { align-self: center; background: #fff; border-radius: 10px; padding: 6px; line-height: 0; }
.qr svg { width: 200px; height: 200px; }
.sleutel { display: block; margin-top: 4px; font-family: var(--font-data); font-size: 12.5px; color: var(--ink); }
.fout { margin: 0; color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.hint.klein { font-size: 12px; margin: 0; }

/* Accounts */
.stapel { display: flex; flex-direction: column; gap: 10px; }
.drawer section { border-top: 1px solid var(--line); padding-top: 14px; }
.drawer h4 { margin: 0; font-family: var(--font-display); font-size: 15px; }
.drawer.breed { width: min(520px, 100%); }
.veld select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.veld.rij { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; color: var(--ink); font-size: 14px; }
.vink { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; cursor: pointer; }
.vink input { margin-top: 3px; accent-color: var(--accent); }
.recht { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.recht summary { cursor: pointer; font-size: 13px; color: var(--accent); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; padding: 8px 0 4px; }
table.grid.effectief td { white-space: normal; }
table.grid.accounts td:first-child { font-weight: 500; }
.btn.gevaar { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.dialoog { position: fixed; z-index: 31; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px)); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialoog h3 { font-size: 18px; }
.tijdelijk { font-family: var(--font-data); font-size: 20px; letter-spacing: .04em; text-align: center; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; user-select: all; }

/* Installatie */
.stappen { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; font-size: 12px; color: var(--muted); counter-reset: stap; }
.stappen li { flex: 1; counter-increment: stap; border-top: 3px solid var(--line); padding-top: 6px; }
.stappen li::before { content: counter(stap) ". "; }
.stappen li.nu { border-color: var(--accent); color: var(--ink); font-weight: 500; }
.inlogkaart code { font-family: var(--font-data); font-size: 12px; }

/* Invoerschermen */
.cellin.text.breed { min-width: 180px; }
.btn.klein { font-size: 12px; padding: 2px 6px; }
h3.kop { font-size: 16px; margin-top: 6px; }
table.grid.smal { width: auto; min-width: 360px; }
.row.toevoegen { margin-top: 8px; }
table.grid select.inline { max-width: 150px; }
table.grid td .cellin.text.breed { min-width: 150px; width: 150px; }
.tablewrap.smal { width: fit-content; max-width: 100%; }
