:root {
  --bg: #f3f4f1;
  --panel: #ffffff;
  --panel-2: #f8f9f6;
  --ink: #1b221d;
  --ink-2: #4c554f;
  --muted: #7a827c;
  --line: #e1e4de;
  --line-2: #cfd4cc;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ea;
  --side: #17201b;
  --side-ink: #c9d1cb;
  --side-active: #2a3a30;
  --danger: #b43c32;
  --danger-soft: #fbe9e7;
  --warn: #a8660b;
  --warn-soft: #fdf1dc;
  --info: #2f5f8f;
  --info-soft: #e5eef7;
  --st-ontvangen: #2f5f8f;
  --st-bezig: #a8660b;
  --st-klaar: #2f7d4f;
  --st-opgehaald: #6b726c;
  --st-geannuleerd: #b43c32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 24, .06), 0 1px 1px rgba(20, 30, 24, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121513; --panel: #1b201c; --panel-2: #20261f; --ink: #e7ebe6; --ink-2: #b9c1ba; --muted: #8b938c;
    --line: #2b322d; --line-2: #39413b; --accent: #4fae76; --accent-ink: #0f1a13; --accent-soft: #1d3325;
    --side: #0d100e; --side-ink: #aeb7b0; --side-active: #1f2a22; --danger: #e0766b; --danger-soft: #3a1f1c;
    --warn: #e0a64e; --warn-soft: #3a2c15; --info: #7fb0e0; --info-soft: #1b2a3a;
    --st-ontvangen: #7fb0e0; --st-bezig: #e0a64e; --st-klaar: #4fae76; --st-opgehaald: #8b938c; --st-geannuleerd: #e0766b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121513; --panel: #1b201c; --panel-2: #20261f; --ink: #e7ebe6; --ink-2: #b9c1ba; --muted: #8b938c;
  --line: #2b322d; --line-2: #39413b; --accent: #4fae76; --accent-ink: #0f1a13; --accent-soft: #1d3325;
  --side: #0d100e; --side-ink: #aeb7b0; --side-active: #1f2a22; --danger: #e0766b; --danger-soft: #3a1f1c;
  --warn: #e0a64e; --warn-soft: #3a2c15; --info: #7fb0e0; --info-soft: #1b2a3a;
  --st-ontvangen: #7fb0e0; --st-bezig: #e0a64e; --st-klaar: #4fae76; --st-opgehaald: #8b938c; --st-geannuleerd: #e0766b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand svg { flex: none; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--side-ink); opacity: .8; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 12px; border-radius: 8px; font-size: 14.5px; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .sub { padding-left: 38px; font-size: 13.5px; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .sep { height: 1px; background: rgba(255,255,255,.07); margin: 10px 6px; }
.side .foot { margin-top: auto; padding: 8px 12px; font-size: 12px; opacity: .7; }
.side .foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; z-index: 30; }
.search-results a { display: block; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); text-decoration: none; }
.search-results .grp { padding: 6px 12px; font-size: 12px; color: var(--muted); background: var(--panel-2); }
.topbar .spacer { flex: 1; }
.content { padding: 24px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card > .hd h2 { flex: 1; }
.card > .bd { padding: 16px; }
.card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }

.stat { padding: 16px; }
.stat .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat .d { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
a.stat { color: inherit; display: block; }
a.stat:hover { text-decoration: none; border-color: var(--line-2); }

/* ---------- status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-ontvangen { color: var(--st-ontvangen); }
.st-bezig { color: var(--st-bezig); }
.st-klaar { color: var(--st-klaar); }
.st-opgehaald { color: var(--st-opgehaald); }
.st-geannuleerd { color: var(--st-geannuleerd); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.status-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.status-steps button { flex: 1; min-width: 110px; }
.status-steps button.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--panel-2); }
tr.inactive td { opacity: .55; }
tr.low td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--panel-2); text-decoration: none; }
.list-item .main-col { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; }
.list-item .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- forms ---------- */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.f > input, label.f > select, label.f > textarea, label.f > .row { margin-top: 5px; display: flex; font-weight: 400; }
label.f > input, label.f > select, label.f > textarea { display: block; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; min-height: 38px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.fgrid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fgrid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fgrid .full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.inline-radio { display: flex; gap: 14px; align-items: center; min-height: 38px; }
fieldset { border: 0; padding: 0; margin: 0; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; list-style: none; padding: 4px 0; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
.section-title { margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 38px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button.sm, .btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
button svg, .btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* price box */
.price-lines { display: grid; gap: 6px; font-size: 14px; }
.price-lines .pl { display: flex; justify-content: space-between; gap: 10px; }
.price-lines .pl span:last-child { font-variant-numeric: tabular-nums; }
.price-lines .total { font-size: 20px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.price-lines .margin { color: var(--accent); font-weight: 600; }
.price-lines .margin.neg { color: var(--danger); }

/* bar chart */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { background: var(--panel-2); border-radius: 4px; height: 16px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { height: 100%; background: var(--accent); border-radius: 3px 0 0 3px; }
.bar .fill.cost { background: var(--line-2); }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 12, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(760px, 100%); }
.modal .hd { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .hd h2 { flex: 1; }
.modal .bd { padding: 18px; }
.modal .ft { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); color: #fff; }

.notice { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips a { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--ink-2); font-size: 13.5px; font-weight: 600; background: var(--panel); }
.chips a.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips a:hover { text-decoration: none; }
.chips .n { opacity: .65; font-weight: 500; margin-left: 4px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 26px; }
.login h1 { margin: 12px 0 4px; }

/* ---------- responsive ---------- */
.bottom-nav { display: none; }
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .new-btn { display: none; }
  .content { padding: 16px 16px 90px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .fgrid, .fgrid.c3 { grid-template-columns: 1fr; }
  .fgrid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none !important; }
  th, td { padding: 8px 10px; }
  .bar { grid-template-columns: 80px 1fr 70px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; color: var(--muted); }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .status-steps button { min-width: calc(50% - 3px); }
}
@media print {
  .side, .topbar, .bottom-nav, .no-print { display: none !important; }
  .app { display: block; }
}

/* voorkomt dat lange regels de kolommen breder maken dan het scherm */
.split > *, .stack > *, .grid > * { min-width: 0; }
.nowrap { white-space: nowrap; }
td:first-child { white-space: nowrap; }
.list > * { min-width: 0; }

body.no-margin .mg { display: none !important; }

@media (min-width: 761px) { .tabs { flex-wrap: wrap; overflow: visible; } }
