/* Spaaroverzicht — mobiel eerst, schaalt naar tablet en desktop. Geen externe fonts of CDN's. */
:root {
  --bg: #f6f7f5; --surface: #ffffff; --surface-2: #f0f2ef; --line: #e3e7e1;
  --text: #121614; --muted: #66706a; --brand: #15803d; --brand-ink: #ffffff; --brand-soft: #dcf3e3;
  --up: #15803d; --down: #c2410c; --warn-bg: #fff4e0; --warn: #9a5b00; --ok-bg: #e2f5e8; --danger: #dc2626;
  --shadow: 0 1px 2px rgb(16 24 20 / .05), 0 4px 16px rgb(16 24 20 / .05);
  --r: 18px; --gap: 14px; --nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f0d; --surface: #141a17; --surface-2: #1b2320; --line: #26302b;
    --text: #e9eeeb; --muted: #8d9993; --brand: #22c55e; --brand-ink: #04210f; --brand-soft: #123622;
    --up: #4ade80; --down: #fb923c; --warn-bg: #3a2a0c; --warn: #fbbf24; --ok-bg: #11301d; --danger: #f87171;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f0d; --surface: #141a17; --surface-2: #1b2320; --line: #26302b;
  --text: #e9eeeb; --muted: #8d9993; --brand: #22c55e; --brand-ink: #04210f; --brand-soft: #123622;
  --up: #4ade80; --down: #fb923c; --warn-bg: #3a2a0c; --warn: #fbbf24; --ok-bg: #11301d; --danger: #f87171;
  --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
body.shield #root { visibility: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.lg { width: 30px; height: 30px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- knoppen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: transform .08s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: var(--surface-2); border-color: var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.link { background: none; color: var(--muted); min-height: 40px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--brand-ink); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.ghost.busy::after { border-color: var(--text); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row.end { justify-content: flex-end; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip .ic { width: 16px; height: 16px; }

/* ---------- formulieren ---------- */
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { font-size: 12px; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px; /* 16px voorkomt inzoomen op iOS */
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); flex: none; margin: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }

/* ---------- inlog / kluis ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--sat)) calc(20px + var(--sar)) calc(24px + var(--sab)) calc(20px + var(--sal)); }
.auth-card { width: 100%; max-width: 420px; display: grid; gap: 16px; text-align: center; }
.auth-card .stack, .auth-card .tips, .auth-card .check { text-align: left; }
.auth h1 { font-size: 28px; letter-spacing: -.02em; }
.logo { width: 64px; height: 64px; margin: 0 auto 4px; border-radius: 20px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.logo.sm { width: 40px; height: 40px; border-radius: 12px; margin: 0; }
.logo.sm .ic { width: 22px; height: 22px; }
.rcode { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px dashed var(--line);
  font: 600 17px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; user-select: all; -webkit-user-select: all; }
.rcode span { padding: 8px 0; border-radius: 8px; background: var(--surface-2); }
.tips { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }

/* ---------- app-schil: mobiel ---------- */
.shell { min-height: 100dvh; }
.side { display: none; }
.content { padding: calc(8px + var(--sat)) calc(16px + var(--sar)) calc(var(--nav-h) + 96px + var(--sab)) calc(16px + var(--sal)); max-width: 1360px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 10px; min-height: 56px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); margin: 0 -16px 8px; padding: 0 16px; }
.top h1 { font-size: 24px; letter-spacing: -.02em; flex: 1; }
.sync { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.sync[data-state="busy"]::before { background: var(--warn); }
.sync[data-state="err"] { color: var(--down); } .sync[data-state="err"]::before { background: var(--down); }

.bottom-nav { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px calc(8px + var(--sar)) calc(6px + var(--sab)) calc(8px + var(--sal)); background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.nav-item { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; min-height: 50px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 12px; cursor: pointer; }
.nav-item.active { color: var(--brand); }
.fab { position: fixed; z-index: 11; right: calc(18px + var(--sar)); bottom: calc(var(--nav-h) + 18px + var(--sab)); width: 58px; height: 58px; border-radius: 20px; border: 0;
  background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: 0 8px 24px rgb(21 128 61 / .35); cursor: pointer; }
.fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }

/* ---------- kaarten ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; letter-spacing: -.01em; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sub { font-size: 14px; margin-top: 4px; }
.hero { background: linear-gradient(145deg, var(--brand-soft), var(--surface) 70%); }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hero { container-type: inline-size; }
.big-num { white-space: nowrap; font-size: clamp(26px, 13cqi, 46px); font-weight: 700; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.up { background: var(--ok-bg); color: var(--up); } .pill.down { background: var(--warn-bg); color: var(--down); }
.pill.ok { background: var(--ok-bg); color: var(--up); } .pill.warn { background: var(--warn-bg); color: var(--warn); }

.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0 -8px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 10px 8px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; min-height: 56px; }
.row:hover:not(.static) { background: var(--surface-2); }
.row.static { cursor: default; }
.rows.compact .row { min-height: 44px; padding: 6px 8px; }
.row-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main strong, .row-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: grid; justify-items: end; gap: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.row-end .ic { color: var(--muted); width: 18px; height: 18px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

.pot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pot { display: grid; gap: 8px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); text-align: left; cursor: pointer; min-width: 0; }
.pot:hover { border-color: var(--muted); }
.pot-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pot-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pot { container-type: inline-size; }
.pot-sum { white-space: nowrap; font-size: clamp(14px, 13cqi, 19px); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.pot small { font-size: 12px; }
.bar { display: block; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; transition: width .4s; }

/* ---------- grafieken ---------- */
.chart-wrap { display: grid; gap: 6px; }
svg.line { width: 100%; height: 160px; display: block; overflow: visible; }
svg.line .stroke { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; }
svg.line .area { fill: var(--brand); opacity: .12; }
.xlabels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); font-size: 11px; color: var(--muted); text-align: center; }
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(2px, 1vw, 6px); height: 150px; align-items: end; }
.bar-col { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 6px; justify-items: center; }
.bar-v { width: 100%; max-width: 26px; align-self: end; border-radius: 6px 6px 3px 3px; background: var(--brand); opacity: .85; }
.bar-col small { font-size: 10px; color: var(--muted); max-width: 100%; overflow: hidden; }

/* ---------- transacties ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input[type="search"] { grid-column: 1 / -1; }
.tx-list { display: grid; gap: 14px; }
.tx-month { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 4px 0; border-bottom: 1px solid var(--line); }
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx-main { flex: 1; min-width: 0; display: grid; }
.tx-main strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-main small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.inleg, .tx-amt.rente { color: var(--up); } .tx-amt.opname { color: var(--down); }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }

.grid-overzicht, .grid-settings { display: grid; gap: var(--gap); }

/* ---------- sheets ---------- */
dialog.sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--text); box-shadow: 0 -10px 40px rgb(0 0 0 / .25); overflow: auto; overscroll-behavior: contain; animation: up .22s ease-out; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 20px; background: var(--surface); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { padding: 4px 20px calc(20px + var(--sab)); }
.sheet-body .btn-row { margin-top: 4px; }
.sheet-body form > .btn-danger-ghost { justify-self: start; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

#toast { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 92px + var(--sab)); max-width: min(92vw, 440px);
  padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: 0 8px 30px rgb(0 0 0 / .25); text-align: center; }
#toast.bad { background: var(--danger); color: #fff; }

/* ---------- smalle telefoons ---------- */
@media (max-width: 360px) {
  .two { grid-template-columns: 1fr; }
  .rcode { grid-template-columns: repeat(2, 1fr); }
  .pot-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- tablet en groter: zijbalk ---------- */
@media (min-width: 768px) {
  .only-mobile, .bottom-nav { display: none !important; }
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
  .side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100dvh; padding: calc(20px + var(--sat)) 16px 20px calc(16px + var(--sal));
    border-right: 1px solid var(--line); background: var(--surface); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
  .brand > div:last-child { display: grid; line-height: 1.2; } .brand small { font-size: 12px; }
  .side-nav { display: grid; gap: 4px; margin-bottom: auto; }
  .side .nav-item { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 44px; font-size: 15px; justify-items: start; }
  .side .nav-item.active { background: var(--brand-soft); color: var(--brand); }
  .side .nav-item:hover:not(.active) { background: var(--surface-2); color: var(--text); }
  .content { padding: calc(12px + var(--sat)) calc(28px + var(--sar)) 40px 28px; }
  .top { margin: 0 -28px 12px; padding: 0 28px; min-height: 68px; }
  .top h1 { font-size: 28px; }
  .card { padding: 20px; }
  .grid-overzicht { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "hero chart" "pots pots" "accounts accounts" "interest interest"; }
  .hero { grid-area: hero; } .chart { grid-area: chart; } .pots { grid-area: pots; } .accounts { grid-area: accounts; } .interest { grid-area: interest; }
  .grid-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters input[type="search"] { grid-column: auto; }
  .tx-card { max-width: 900px; }
  dialog.sheet { margin: auto; width: min(560px, 92vw); max-height: 86dvh; border-radius: 22px; animation: pop .18s ease-out; }
  .sheet-body { padding-bottom: 22px; }
  #toast { bottom: 28px; }
  @keyframes pop { from { transform: scale(.97); opacity: 0; } }
}

@media (min-width: 1024px) {
  .grid-overzicht { grid-template-areas: "hero chart" "pots pots" "accounts interest"; }
}
.interest { container-type: inline-size; }
@container (max-width: 420px) { .bar-col small.alt { visibility: hidden; } }

/* ---------- desktop ---------- */
@media (min-width: 1200px) {
  .shell { grid-template-columns: 260px minmax(0, 1fr); }
  .grid-overzicht { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "hero chart chart" "accounts pots pots" "interest pots pots"; }
  .grid-settings { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pot-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (hover: none) { .row:hover:not(.static), .icon-btn:hover, .pot:hover { background: inherit; } .pot:hover { background: var(--surface-2); border-color: var(--line); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.badge-line { margin-top: 4px; }

/* ---------- import ---------- */
.mapping { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.mapping summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.mapping[open] summary { margin-bottom: 10px; }
.imp-list { display: grid; max-height: 46dvh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.imp-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.imp-row:last-child { border-bottom: 0; }
.imp-row.dup { opacity: .45; cursor: default; }
.imp-row .tx-amt { font-size: 14px; }
