/* Design tokens uit de handoff (README → Design Tokens) */
:root {
  --primary: #2f6fed;
  --primary-2: #1f4fc4;
  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1b2430;
  --text-2: #6b7280;
  --text-3: #9aa1ac;
  --seg-inactive: #5b6472;
  --border: #e2e5ea;
  --border-input: #dde1e7;
  --sep: #f1f2f4;
  --sep-2: #eef0f3;
  --track: #eceef2;
  --weekend: #f4f5f7;
  --ok: #22c55e;
  --alarm: #ef4444;
  --prio: #dc2626;
  --prio-bg: #fee2e2;
  --success: #16a34a;
  --dark: #1b2430;
  --shadow-card: 0 1px 2px rgba(20, 25, 35, .04);
  --shadow-toast: 0 6px 20px rgba(0, 0, 0, .2);
  --shadow-drawer: -8px 0 30px rgba(15, 20, 30, .15);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 12.5px; color: var(--text); background: var(--bg); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
code { font-family: Consolas, ui-monospace, monospace; font-size: 12px; }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(20, 25, 35, .18); border-radius: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Knoppen & velden ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; background: var(--bg); color: var(--text); text-decoration: none;
}
.btn:hover:not(:disabled) { background: #e7e9ee; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-danger { background: var(--prio-bg); color: var(--prio); }
.btn-danger:hover:not(:disabled) { background: #fdd0d0; }
.btn-ghost { background: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.link { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.select {
  width: 100%; font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--bg); border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.check, .check-inline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; }
.check { margin-top: 10px; }
.check input, .check-inline input { accent-color: var(--primary); margin: 0; }
.muted { font-size: 11.5px; color: var(--text-2); }

/* ---------- Shell ---------- */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.header {
  height: 64px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.h-left { display: flex; align-items: center; gap: 14px; min-width: 260px; }
.logo {
  width: 34px; height: 34px; flex: none; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 700; font-size: 14px;
}
.h-titles { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.h-title { font-size: 14px; font-weight: 600; line-height: 1.2; }
.sync-line { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); text-align: left; border-radius: 4px; }
.sync-line:hover { color: var(--text); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: none; }

.segmented { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; }
.seg { padding: 7px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--seg-inactive); }
.seg:hover { color: var(--text); }
.seg.active { background: var(--primary); color: #fff; }

.h-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 260px; }
#search {
  width: 240px; height: 34px; padding: 0 12px; border: 1px solid var(--border-input); border-radius: 8px;
  font: inherit; font-size: 12.5px; color: var(--text); outline: none;
}
#search:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.user-menu { display: flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--border); }
.user-name { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.row-disabled td { opacity: .55; }

.body { flex: 1; display: flex; overflow: hidden; }

/* ---------- Inloggen ---------- */
.auth-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
}
.auth-card {
  display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; margin: 16px;
  padding: 28px 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-card);
}
.auth-logo {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 17px; }
.auth-hint { margin: 0; font-size: 12.5px; color: var(--text-2); }
.auth-steps { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.auth-qr { display: flex; justify-content: center; padding: 8px 0; }
.auth-qr svg { width: 176px; height: 176px; border: 1px solid var(--border); border-radius: 8px; }
.auth-secret { display: block; width: fit-content; margin: 4px auto 0; padding: 4px 8px; background: var(--surface-2); border-radius: 6px; letter-spacing: .05em; font-size: 13px; }
.auth-credit { margin: 4px 0 0; text-align: center; font-size: 10.5px; color: var(--text-3); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 216px; flex: none; display: flex; flex-direction: column; gap: 20px; overflow-y: auto;
  padding: 18px 16px; background: var(--surface); border-right: 1px solid var(--border);
}
.side-h { margin: 0 0 8px; font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.side-list { display: flex; flex-direction: column; gap: 6px; }
.side-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 7px; text-align: left; opacity: .45; }
.side-row:hover { background: var(--bg); }
.side-row.active { background: var(--bg); opacity: 1; }
.side-row .lbl { flex: 1; font-size: 12.5px; }
.side-row .cnt { font-size: 11px; color: var(--text-3); }
.side-empty { font-size: 12px; color: var(--text-3); }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-credit { text-align: center; font-size: 10.5px; color: var(--text-3); }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] { width: 40px; height: 30px; padding: 2px; border: 1px solid var(--border-input); border-radius: 6px; background: none; }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sdot.lg { width: 9px; height: 9px; }
.sdot.sm { width: 7px; height: 7px; margin-left: 4px; }

/* ---------- Main ---------- */
.main { flex: 1; overflow: auto; padding: 20px 24px; position: relative; }
.banner {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  background: #eaf1ff; color: var(--text); border: 1px solid #d5e2fd;
}
.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar .range { margin-left: 8px; font-size: 13px; font-weight: 600; }
.toolbar .hint { margin-left: auto; font-size: 11px; color: var(--text-3); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 16px; align-items: flex-start; height: 100%; }
.k-col { width: 270px; flex: none; display: flex; flex-direction: column; gap: 10px; max-height: 100%; border-radius: 10px; }
.k-col.drop-over { background: rgba(47, 111, 237, .06); outline: 2px dashed rgba(47, 111, 237, .35); outline-offset: 4px; }
.k-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.k-title { font-size: 13px; font-weight: 600; }
.badge-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); background: var(--track); border-radius: 10px; padding: 1px 8px; }
.k-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding-bottom: 8px; min-height: 60px; }
.k-empty { padding: 16px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; font-size: 11.5px; color: var(--text-3); }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 12px; cursor: grab; touch-action: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-card);
}
.card:hover { border-color: #cfd4dc; }
.card.dragging { opacity: .4; }
.card-top { display: flex; align-items: center; gap: 8px; }
.ordernr { font-size: 12.5px; font-weight: 700; color: var(--primary); }
.prio { margin-left: auto; padding: 2px 6px; border-radius: 5px; font-size: 10px; font-weight: 600; background: var(--prio-bg); color: var(--prio); }
.card-item { font-size: 13px; font-weight: 600; line-height: 1.25; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 11px; color: var(--text-2); }
.progress { height: 5px; margin-top: 2px; border-radius: 3px; background: var(--track); overflow: hidden; }
.progress.lg { height: 6px; margin-top: 0; }
.progress > div { height: 100%; border-radius: 3px; }

/* ---------- Agenda ---------- */
.agenda { display: flex; flex-direction: column; gap: 18px; }
.days { display: flex; gap: 8px; }
.day {
  display: flex; flex-direction: column; align-items: center; width: 58px; padding: 10px 0; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
}
.day:hover { background: var(--bg); }
.day.today:not(.active) { border-color: var(--primary); }
.day.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.day .dow { font-size: 10.5px; opacity: .75; }
.day .num { font-size: 15px; font-weight: 700; }
.lanes { display: flex; flex-direction: column; gap: 14px; }
.lane { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.lane-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lane-name { font-size: 13px; font-weight: 600; }
.lane-count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.lane-empty { padding: 10px 0; font-size: 12px; color: var(--text-3); }
.cap { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.cap-bar { width: 70px; height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.cap-bar > div { height: 100%; border-radius: 3px; }
.cap-lbl { font-size: 10.5px; color: var(--text-3); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chip-wrap { display: flex; align-items: center; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 8px; min-width: 180px; padding: 8px 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
}
.chip:hover { background: var(--bg); }
.chip-txt { display: flex; flex-direction: column; gap: 1px; }
.chip-t { font-size: 12px; font-weight: 600; }
.chip-s { font-size: 10.5px; color: var(--text-2); }
.seq {
  width: 20px; height: 20px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700;
}
.arrow { color: #c3c8d1; font-size: 14px; }

/* ---------- Gantt ---------- */
.gantt-wrap { display: flex; flex-direction: column; gap: 14px; min-width: 1180px; }
.gantt { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.g-head { display: flex; border-bottom: 1px solid var(--border); }
.g-label { width: 160px; flex: none; background: var(--surface-2); }
.g-head .g-label { padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--text-2); }
.g-days { flex: 1; display: flex; }
.g-day { flex: 1 0 0; padding: 6px 2px; text-align: center; border-left: 1px solid var(--sep); }
.g-day.weekend { background: var(--weekend); }
.g-day.today { color: var(--primary); }
.g-day .dow { font-size: 9.5px; opacity: .7; }
.g-day .num { font-size: 11.5px; font-weight: 600; }
.g-row { display: flex; border-bottom: 1px solid var(--sep-2); }
.g-row:last-child { border-bottom: 0; }
.g-row .g-label { display: flex; align-items: center; gap: 8px; padding: 14px; font-size: 12.5px; font-weight: 600; }
.g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capdot { width: 7px; height: 7px; flex: none; border-radius: 50%; }
.g-track { flex: 1; position: relative; }
.g-grid { position: absolute; inset: 0; display: flex; pointer-events: none; }
.g-grid > div { flex: 1 0 0; border-left: 1px solid var(--sep); }
.g-grid > .weekend { background: #fafbfc; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); opacity: .5; z-index: 1; pointer-events: none; }
.g-bar {
  position: absolute; z-index: 2; height: 36px; display: flex; align-items: center; padding: 0 10px; touch-action: none;
  border: 1px solid; border-radius: 7px; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; cursor: grab;
}
.g-bar:hover { filter: brightness(.97); }
.g-bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.g-bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.g-bar.dragging { opacity: .5; }
.g-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.g-drop {
  position: absolute; top: 4px; bottom: 4px; z-index: 3; pointer-events: none;
  border: 2px dashed var(--primary); border-radius: 7px; background: rgba(47, 111, 237, .08);
}

/* ---------- Overlays: drawer & modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 30, .32); }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 41; width: 360px; height: 100vh; margin: 0;
  display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-drawer);
}
form.drawer { width: 440px; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px; border-bottom: 1px solid var(--border); }
.d-nr { font-size: 15px; font-weight: 700; color: var(--primary); }
.d-item { margin-top: 4px; font-size: 14px; font-weight: 600; }
.close-x { padding: 2px 6px; border-radius: 6px; font-size: 18px; line-height: 1; color: var(--text-3); }
.close-x:hover { background: var(--bg); color: var(--text); }
.drawer-body { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px; overflow-y: auto; }
.status-badge { width: fit-content; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.field-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 12.5px; border-bottom: 1px solid var(--sep); }
.field-row span:first-child { color: var(--text-2); }
.field-row span:last-child { font-weight: 600; text-align: right; }
.prog-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 11.5px; color: var(--text-2); }
.sync-note { font-size: 11px; color: var(--text-3); }
.sync-note.error { color: var(--prio); }
.drawer-foot { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }
.drawer-foot .btn { flex: 1; height: auto; padding: 10px; }

.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 11px; font-weight: 600; color: var(--text-2); }
.f .opt { font-weight: 400; color: var(--text-3); }
.f input, .f select, .tbl input:not([type=checkbox]) {
  height: 34px; padding: 0 10px; border: 1px solid var(--border-input); border-radius: 8px;
  font: inherit; font-size: 12.5px; color: var(--text); background: #fff; outline: none; width: 100%;
}
.f input:focus, .f select:focus, .tbl input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.f.err input, .f.err select, td:has(.errmsg) input { border-color: var(--prio); }
.errmsg { font-size: 11px; color: var(--prio); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; height: auto; padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }
.range-row input[type=number] { width: 72px; flex: none; }
.form-error { padding: 8px 10px; border-radius: 8px; font-size: 12px; background: var(--prio-bg); color: var(--prio); }

.modal {
  position: fixed; top: 50%; left: 50%; z-index: 41; transform: translate(-50%, -50%);
  width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 50px rgba(15, 20, 30, .25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; }
.modal-title { font-size: 15px; font-weight: 700; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.tab { margin-bottom: -1px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--seg-inactive); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.modal-body { padding: 16px 20px 20px; overflow: auto; }
.intro { margin: 0 0 12px; font-size: 12px; color: var(--text-2); }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  padding: 8px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 8px; vertical-align: middle; border-bottom: 1px solid var(--sep); }
.tbl tr:hover td { background: var(--surface-2); }
.tbl tr.editing td { background: #f5f8ff; vertical-align: top; }
.tbl input:not([type=checkbox]) { height: 30px; padding: 0 8px; border-radius: 6px; }
.tbl .num { width: 80px; }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .empty { padding: 16px 8px; color: var(--text-3); }
.tbl .errmsg { display: block; margin-top: 3px; }
.pill { padding: 2px 6px; border-radius: 5px; font-size: 10.5px; background: var(--track); color: var(--text-2); }
.pill.on { background: #e7f8ee; color: var(--success); }
.section { margin-bottom: 20px; }
.section:last-child { margin-bottom: 0; }
.section h4 { margin: 0 0 6px; font-size: 13px; }
.section p { margin: 0 0 10px; font-size: 12px; color: var(--text-2); }
.section .hint { font-size: 11px; color: var(--text-3); margin: 4px 0 0; }
.section .warn { font-size: 12px; color: var(--alarm); background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
.kv { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-2); }
.kv b { color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.audit { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.audit li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--sep); }
.audit time { width: 92px; flex: none; color: var(--text-3); }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 60; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 440px; padding: 10px 16px;
  border-radius: 8px; font-size: 12.5px; color: #fff; box-shadow: var(--shadow-toast);
}
.toast-success { background: var(--success); }
.toast-info { background: var(--dark); }
.toast-error { background: var(--prio); }
.spinner {
  width: 14px; height: 14px; flex: none; border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}

/* ---------- Smalle schermen ---------- */
@media (max-width: 900px) {
  .header { height: auto; flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .h-left, .h-right { min-width: 0; }
  .h-right { width: 100%; }
  #search { flex: 1; width: auto; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  form.drawer, .drawer { width: 100%; }
}
