/* Huishoudbudget – ontwerp­systeem. Minimalistisch, bank-achtig, responsive. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f2;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-700: #1d4ed8;
  --primary-soft: #dbeafe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info-soft: #e0f2fe;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --sidebar-w: 248px;
  --assistant-w: 360px;
  --topbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Variable", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #182236;
  --border: #243049;
  --text: #e5e9f2;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-700: #60a5fa;
  --primary-soft: #1e3a8a;
  --success-soft: #14532d;
  --danger-soft: #7f1d1d;
  --warning-soft: #78350f;
  --info-soft: #0c4a6e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
.h1 { font-size: 1.6rem; } .h2 { font-size: 1.2rem; } .h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--success); } .neg { color: var(--danger); } .warn { color: var(--warning); }
.inline { display: inline; }
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem } .mt-2 { margin-top: 1rem } .mt-3 { margin-top: 1.5rem } .mb-2 { margin-bottom: 1rem }
.flex { display: flex; gap: .75rem; align-items: center; } .flex-wrap { flex-wrap: wrap; } .grow { flex: 1 }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .75rem; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; }
.sidebar-close { display: none; margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: .4rem .7rem; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; font-size: .94rem; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-700); }
.nav-link svg { width: 18px; height: 18px; }
.sidebar-footer { margin-top: auto; padding: .8rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .3rem; }
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.menu-btn { display: none; }
.topbar-household { display: flex; gap: .5rem; align-items: center; }
.household-switch { font-weight: 600; max-width: 220px; }
.topbar-kpis { display: flex; gap: 1.4rem; margin-left: auto; }
.tk { display: flex; flex-direction: column; line-height: 1.15; }
.tk-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tk-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.topbar-search input { width: 180px; }
.topbar-profile { display: flex; align-items: center; gap: .5rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; cursor: pointer; list-style: none; }
.avatar::-webkit-details-marker { display: none; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 220px; padding: .4rem; display: flex; flex-direction: column; z-index: 40; }
.dropdown-menu a, .dropdown-menu button { padding: .5rem .7rem; border-radius: 6px; text-align: left; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-header { padding: .5rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; font-size: .9rem; }
.content-row { display: flex; flex: 1; min-height: 0; }
.content { flex: 1; min-width: 0; padding: 1.5rem; }
.assistant { width: var(--assistant-w); border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
.assistant.collapsed { display: none; }
.assistant-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
.assistant-head svg { width: 16px; height: 16px; vertical-align: -3px; }
.assistant-consent { padding: .6rem 1rem; border-bottom: 1px solid var(--border); font-size: .82rem; display: flex; flex-direction: column; gap: .4rem; }
.assistant-log { flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.msg { padding: .6rem .8rem; border-radius: 12px; font-size: .9rem; max-width: 95%; white-space: pre-wrap; }
.msg-bot { background: var(--surface-2); align-self: flex-start; }
.msg-user { background: var(--primary); color: #fff; align-self: flex-end; }
.assistant-suggest { display: flex; flex-wrap: wrap; gap: .3rem; padding: .4rem 1rem; }
.chip { font: inherit; font-size: .76rem; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--primary); }
.assistant-form { display: flex; gap: .4rem; padding: .7rem 1rem; border-top: 1px solid var(--border); }
.assistant-form .input { flex: 1; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); min-width: 0; overflow-x: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.kpi-sub { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }
.chart-box.short { height: 220px; }

/* Buttons, forms */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-700); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.btn-xs { padding: .2rem .45rem; font-size: .78rem; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--text); padding: .4rem; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.input, .select, textarea.input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.input:focus, .select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.input-sm, .select-sm { padding: .35rem .55rem; font-size: .88rem; width: auto; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field label { font-size: .86rem; font-weight: 600; }
.field .help { font-size: .78rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.radio-cards { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.radio-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; display: block; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { margin-right: .4rem; }
.slider { width: 100%; accent-color: var(--primary); }
.range-row { display: flex; align-items: center; gap: .75rem; }
.range-row output { min-width: 70px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tr:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions form { display: inline; }
.table tr.inactive td { opacity: .5; text-decoration: line-through; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--primary-700); border-color: transparent; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; }
.progress { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.ok > span { background: var(--success); } .progress.warn > span { background: var(--warning); } .progress.danger > span { background: var(--danger); }

/* Inline edit */
.editable { cursor: text; border-bottom: 1px dashed var(--border); }
.editable:hover { border-bottom-color: var(--primary); }
.editable:focus { outline: none; border-bottom: 1px solid var(--primary); background: var(--primary-soft); }
.saving { opacity: .6; }
.drag-handle { cursor: grab; color: var(--muted); }
.drop-target { outline: 2px dashed var(--primary); outline-offset: -4px; }
.dragging { opacity: .4; }

/* Category blocks */
.category { margin-bottom: 1rem; }
.category-head { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.category-head .cat-total { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.category-body { margin-top: .5rem; }
.collapsed .category-body { display: none; }

/* Flash & misc */
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error, .flash-danger { background: var(--danger-soft); color: var(--danger); }
.flash-warning { background: var(--warning-soft); color: var(--warning); }
.flash-info { background: var(--info-soft); color: var(--primary-700); }
.insight { border-left: 4px solid var(--primary); padding: .7rem .9rem; background: var(--surface-2); border-radius: 8px; margin-bottom: .6rem; }
.insight.warn { border-color: var(--warning); } .insight.danger { border-color: var(--danger); } .insight.ok { border-color: var(--success); }
.insight h4 { margin: 0 0 .2rem; font-size: .95rem; }
.insight p { margin: 0; font-size: .88rem; color: var(--muted); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.steps { display: flex; gap: .4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.step { flex: 1; min-width: 100px; padding: .5rem; border-radius: 8px; background: var(--surface-2); font-size: .8rem; text-align: center; color: var(--muted); border: 1px solid var(--border); }
.step.active { background: var(--primary-soft); color: var(--primary-700); border-color: transparent; font-weight: 600; }
.step.done { color: var(--success); }
.assumptions { font-size: .84rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.assumptions dt { font-weight: 600; } .assumptions dd { margin: 0 0 .3rem; color: var(--muted); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { padding: .5rem .8rem; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550; }
.tab.active, .tab:hover { color: var(--primary-700); border-color: var(--primary); text-decoration: none; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; font-size: .88rem; z-index: 100; box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .84rem; }
.diff-pos { color: var(--success); font-weight: 600; } .diff-neg { color: var(--danger); font-weight: 600; }
dialog.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; max-width: 560px; width: 94vw; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(15,23,42,.45); }

/* Auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 1280px) { .assistant { position: fixed; right: 0; top: var(--topbar-h); z-index: 25; box-shadow: var(--shadow); } .assistant:not(.open) { display: none; } }
@media (max-width: 1024px) { .topbar-kpis { display: none; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-close { display: inline-grid; }
  .menu-btn { display: inline-grid; }
  .content { padding: 1rem; }
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .topbar-search { display: none; }
  .assistant { width: 100vw; }
  .period-form { display: none; }
}
@media print { .sidebar, .topbar, .assistant, .btn, .actions { display: none !important; } .content { padding: 0; } .card { box-shadow: none; } }
