:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f0f2f5; --border: #dfe3e8; --text: #1b2430;
  --muted: #66707d; --accent: #0b6bcb; --accent-ink: #ffffff; --accent-soft: #e6f0fb;
  --ok: #17794a; --ok-soft: #e3f4eb; --warn: #9a5b00; --warn-soft: #fdf1dc;
  --bad: #b3261e; --bad-soft: #fbe9e7; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b2129; --surface-2: #242b35; --border: #333c48; --text: #e8ecf1;
    --muted: #9aa5b3; --accent: #5aa9f5; --accent-ink: #0c1620; --accent-soft: #1d3147;
    --ok: #6dd3a0; --ok-soft: #173326; --warn: #f1b860; --warn-soft: #3a2c12;
    --bad: #f28b82; --bad-soft: #40201d; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

/* Layout */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; padding: .25rem .5rem 1rem; color: var(--text); }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .9rem; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .6rem; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .6rem .3rem; }
.who { margin-top: 1rem; padding: .75rem .6rem 0; border-top: 1px solid var(--border); font-size: .88rem; }
.who form { margin-top: .4rem; }
.main { padding: 1.4rem 1.6rem 4rem; max-width: 1280px; width: 100%; }
.topbar { display: none; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.head .sub { color: var(--muted); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

@media (max-width: 860px) {
  .shell { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding: .55rem .9rem; }
  .topbar .brand { padding: 0; }
  .side { display: none; position: fixed; inset: 49px 0 0 0; height: auto; z-index: 19; border-right: 0; }
  body.menu-open .side { display: block; }
  .side .brand { display: none; }
  .main { padding: 1rem .9rem 5rem; }
}

/* Bouwstenen */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: .9rem 1.1rem 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 1rem; }
.grid .card { margin-bottom: 0; }
.grid .wide { grid-column: 1 / -1; }
.field.bottom { align-self: end; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; color: var(--text); box-shadow: var(--shadow); display: block; }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile .label { color: var(--muted); font-size: .82rem; }
.tile .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile.alert .value { color: var(--bad); }
.tile.attn .value { color: var(--warn); }
.bigtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; }
.bigtile { display: flex; gap: .8rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); box-shadow: var(--shadow); }
.bigtile:hover { border-color: var(--accent); text-decoration: none; }
.bigtile .icon { font-size: 1.6rem; line-height: 1; }
.bigtile strong { display: block; }
.bigtile span { color: var(--muted); font-size: .86rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table-wrap { overflow-x: auto; }
td.empty { text-align: center; color: var(--muted); padding: 1.6rem; }
tr.dim td { color: var(--muted); }
tr.dim td .badge { opacity: .7; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.count { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .74rem; font-weight: 700; }
.neg { color: var(--bad); font-weight: 600; }
.low { color: var(--warn); font-weight: 600; }

.flash { padding: .7rem .9rem; border-radius: 8px; margin-bottom: .8rem; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.banner { background: var(--bad-soft); color: var(--bad); padding: .6rem .9rem; border-radius: 8px; margin-bottom: .8rem; }

/* Formulieren */
label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: .25rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .92rem; margin: 0; }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; min-height: 40px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.field { margin-bottom: .8rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.inline .field { margin: 0; flex: 1 1 150px; }
.inline .field.narrow { flex: 0 1 110px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; min-height: 30px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
form.plain { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; flex: 1 1 140px; max-width: 260px; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; border-radius: 999px; color: var(--muted); border: 1px solid transparent; }
.tabs a.on { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; padding: .7rem 1rem; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Zoekvak met resultaten */
.picker { position: relative; }
.picker-results { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 300px; overflow-y: auto; }
.picker-results li { padding: .5rem .6rem; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: .75rem; }
.picker-results li:hover, .picker-results li.on { background: var(--accent-soft); }
.picker-results li.none { color: var(--muted); cursor: default; background: none; }
.picker-results small { white-space: nowrap; }

/* Boekformulier */
.booking { max-width: 760px; }
.searchbar { display: flex; gap: .5rem; }
.searchbar .picker { flex: 1; }
.line { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .85rem; margin-top: .6rem; background: var(--surface); }
.line-head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.line-head strong { display: block; }
.line-body { margin-top: .6rem; }
.stepper { display: flex; align-items: center; gap: .35rem; }
.stepper input { width: 96px; text-align: center; font-size: 1.05rem; font-weight: 600; }
.stepper .btn { min-width: 44px; font-size: 1.15rem; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .2rem .3rem .2rem .65rem; font-size: .86rem; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .25rem; }
.serial-pick { max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; margin-top: .5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .25rem .75rem; }
.submitbar { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 1rem 0 .75rem; margin-top: 1rem; }
.error-box { background: var(--bad-soft); color: var(--bad); padding: .7rem .9rem; border-radius: 8px; margin-top: .75rem; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .55rem 1rem; border-radius: 999px; z-index: 60; font-weight: 600; max-width: 92vw; text-align: center; }
.toast.bad { background: var(--bad); color: #fff; }

/* Scanner */
.modal { position: fixed; inset: 0; background: rgba(8,12,18,.8); z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal-box { background: var(--surface); border-radius: 14px; padding: 1rem; width: min(520px, 100%); }
.modal-box header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
#scan-reader { width: 100%; border-radius: 10px; overflow: hidden; background: #000; min-height: 240px; }
.scan-last { margin: .6rem 0 0; min-height: 1.4em; font-weight: 600; }

/* Inloggen */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.75rem; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 1rem; font-size: 1.2rem; }
.demo { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.demo .btn { margin-top: .4rem; }
@media print { .side, .topbar, .actions, .filters, .submitbar { display: none !important; } .shell { display: block; } .main { padding: 0; } }
