:root {
  --bg: oklch(97.5% 0.004 250);
  --surface: oklch(100% 0 0);
  --border: oklch(90% 0.006 250);
  --border-strong: oklch(80% 0.008 250);
  --ink: oklch(24% 0.02 260);
  --ink-muted: oklch(45% 0.02 260);
  --ink-faint: oklch(62% 0.015 260);
  /* Huisstijl Peacock: groen #74af27 en donkergroen #004431. Witte tekst op #74af27 haalt geen
     AA-contrast (2,6:1), dus knoppen, links en actieve navigatie gebruiken het donkergroen (9,9:1);
     het lichte groen is het merkteken, de tint en de accenten. */
  --brand: #74af27;
  --brand-dark: #004431;
  --accent: var(--brand-dark);
  --accent-hover: oklch(40% 0.085 162);
  --accent-ink: oklch(99% 0 0);
  --accent-tint: oklch(95% 0.045 135);
  --success: oklch(50% 0.15 150);
  --success-tint: oklch(94% 0.05 150);
  --warn: oklch(60% 0.14 80);
  --warn-tint: oklch(95% 0.06 85);
  --danger: oklch(54% 0.19 25);
  --danger-tint: oklch(94% 0.045 25);
  --radius-sm: 8px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px oklch(20% 0.02 260 / 0.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 1rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 0.75rem; }

/* Shell: zijbalk met iconen (desktop, inklapbaar), onderbalk met Meer-sheet
(mobiel). Opbouw in app.js renderShell(). Patroon overgenomen van het Lijmkam-
dashboard zodat de Spits-dashboards hetzelfde aanvoelen. */
.app-shell { display: flex; align-items: flex-start; min-height: 100vh; }
.icon { display: inline-flex; flex-shrink: 0; }
.icon svg { width: 18px; height: 18px; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 1.1rem 0.8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; transition: width 180ms ease-out; }
.sidebar.collapsed { width: 68px; padding-left: 0.6rem; padding-right: 0.6rem; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0 0.15rem 1.25rem; }
.sidebar.collapsed .sidebar-top { flex-direction: column; gap: 0.75rem; }
.brand { font-weight: 700; font-size: 0.95rem; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 0.55rem; white-space: nowrap; overflow: hidden; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--brand); display: inline-block; flex-shrink: 0; position: relative; }
.brand-mark::after { content: ''; position: absolute; right: -3px; bottom: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand-dark); border: 2px solid var(--surface); }
.sidebar.collapsed .brand-label { display: none; }
.sidebar-collapse-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 1.7rem; height: 1.7rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); cursor: pointer; padding: 0; }
.sidebar-collapse-btn:hover { background: var(--bg); color: var(--ink); }
.sidebar-collapse-btn svg { width: 15px; height: 15px; transition: transform 180ms ease-out; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 1.25rem; }
.sidebar-group { display: flex; flex-direction: column; gap: 0.1rem; }
.sidebar-group-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 0 0 0.4rem 0.6rem; white-space: nowrap; }
.sidebar.collapsed .sidebar-group-label { display: none; }
.sidebar-link { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); color: var(--ink-muted); text-decoration: none; font-weight: 500; white-space: nowrap; overflow: hidden; }
.sidebar-link:hover { background: var(--bg); color: var(--ink); }
.sidebar-link[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 0.55rem 0; }
.sidebar.collapsed .sidebar-link-label { display: none; }
.sidebar-bottom { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.1rem; }
.sidebar-user .sidebar-link-label { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-user-mail { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.72rem; color: var(--ink-faint); font-weight: 400; }
.sidebar-logout { display: flex; align-items: center; gap: 0.7rem; width: 100%; background: none; border: 0; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); color: var(--ink-muted); font-weight: 500; cursor: pointer; white-space: nowrap; overflow: hidden; text-align: left; }
.sidebar-logout:hover { background: var(--danger-tint); color: var(--danger); }
.sidebar.collapsed .sidebar-logout { justify-content: center; padding: 0.55rem 0; }
.sidebar.collapsed .sidebar-logout-label { display: none; }
.sidebar-version { font-size: 0.72rem; color: var(--ink-faint); text-decoration: none; padding: 0.3rem 0.6rem; }
.sidebar.collapsed .sidebar-version { text-align: center; padding: 0.3rem 0; }
.app-content { flex: 1; padding: 1.75rem 2rem; max-width: 1400px; min-width: 0; }
.page-title { display: flex; align-items: center; gap: 0.65rem; }
.page-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); background: var(--accent-tint); color: var(--accent); flex-shrink: 0; }
.page-icon svg { width: 19px; height: 19px; }
.bottom-nav, .bottom-sheet { display: none; }

/* Panels & tables */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-body { padding: 1.1rem 1.25rem; }
.panel + .panel { margin-top: 1rem; }
.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .grow { flex: 1 1 260px; min-width: 220px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
tr.clickable.active td { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.85em; }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }

/* Forms */
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); margin-bottom: 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.input-inline { width: auto; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: white; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-group { display: inline-flex; gap: 0.35rem; }

/* Badges */
.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg); color: var(--ink-muted); white-space: nowrap; }
.badge.ok, .badge.proposed, .badge.accepted, .badge.done { background: var(--success-tint); color: var(--success); }
.badge.warn, .badge.queued, .badge.running, .badge.edited { background: var(--warn-tint); color: var(--warn); }
.badge.error, .badge.skipped { background: var(--danger-tint); color: var(--danger); }
.badge.accent { background: var(--accent-tint); color: var(--accent); }

/* Alerts & misc */
.alert { padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); margin-top: 0.75rem; font-size: 0.9rem; }
.alert-error { background: var(--danger-tint); color: var(--danger); }
.alert-success { background: var(--success-tint); color: var(--success); }
.alert-warn { background: var(--warn-tint); color: var(--warn); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1rem; }
.stat .label { font-size: 0.75rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 1.4rem; font-weight: 600; margin-top: 0.15rem; }
.progress { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; }
.progress > span { display: block; height: 100%; background: var(--success); }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; background: var(--ink); color: white; padding: 0.7rem 1rem; border-radius: var(--radius-sm); box-shadow: 0 6px 20px oklch(20% 0.02 260 / 0.25); z-index: 40; }
.pager { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; margin-top: 0.75rem; }
/* #5: selectie en bulkacties in de werkvoorraad */
th.sel, td.sel { width: 2rem; padding-right: 0; }
td.sel input, th.sel input { width: 1rem; height: 1rem; cursor: pointer; }
.bulk-bar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; background: var(--accent-tint); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.bulk-bar .count { font-weight: 600; color: var(--accent); }

/* Review */
.review-field { display: grid; grid-template-columns: 180px 1fr 1fr 190px; gap: 1rem; padding: 0.9rem 0; border-bottom: 1px solid var(--border); align-items: start; }
.review-field:last-child { border-bottom: 0; }
.review-field .label { font-weight: 600; }
.review-field .code { color: var(--ink-faint); font-size: 0.78rem; }
.review-field .val { white-space: pre-wrap; word-break: break-word; }
td.val { white-space: pre-wrap; word-break: break-word; }
.review-field .val.current { color: var(--ink-muted); }
.review-field .val.current.clamp { max-height: 11rem; overflow: hidden; position: relative; }
.review-field .val.current.clamp::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3rem; background: linear-gradient(transparent, var(--surface)); }
.review-field .val.proposed { background: var(--accent-tint); padding: 0.5rem 0.65rem; border-radius: var(--radius-sm); }
.review-field .val.proposed.decided { background: var(--success-tint); }
.review-field .val.proposed.skipped { background: var(--bg); text-decoration: line-through; color: var(--ink-faint); }
.review-field .source { font-size: 0.8rem; margin-top: 0.35rem; }
.review-field .source a { word-break: break-all; }
.review-field .actions { display: flex; flex-direction: column; gap: 0.35rem; }
.review-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.conf { display: inline-block; width: 46px; height: 5px; background: var(--bg); border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 0.35rem; }
.conf > span { display: block; height: 100%; background: var(--accent); }
.log-line { font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; padding: 0.2rem 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; }
.log-line.error { color: var(--danger); }
.log-line.warn { color: var(--warn); }
kbd { font: inherit; font-size: 0.75rem; padding: 0 0.35rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }

/* Responsive. Onder 880px: zijbalk weg, vaste onderbalk met de drie
belangrijkste taken en Meer (sheet met de rest,
profiel en uitloggen). Tabellen scrollen in hun paneel; op telefoon worden
tabellen met class "cards" kaarten. Reviewscherm valt terug op één kolom. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select { min-height: 40px; }
}
@media (max-width: 880px) {
  .sidebar { display: none; }
  .app-shell { display: block; }
  .app-content { width: 100%; padding: 1rem 1rem 6rem; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .toolbar .grow { flex-basis: 100%; min-width: 0; }
  .review-field { grid-template-columns: 1fr; gap: 0.5rem; }
  .review-field .actions { flex-direction: row; flex-wrap: wrap; }
  .review-head { flex-direction: column; align-items: stretch; }
  .btn-group { flex-wrap: wrap; }
  .form-row { grid-template-columns: 1fr !important; }
  .attr-list { columns: 1 !important; }
  .panel-body { padding: 0.9rem 1rem; }
  .table-wrap table:not(.cards) { min-width: 640px; }
  .panel > .panel-body[style*="padding:0"], .panel-body.table-wrap { overflow-x: auto; }
  dialog { max-width: calc(100vw - 2rem) !important; }
  kbd, .kbd-hint, .desktop-only { display: none !important; }

  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px oklch(20% 0.02 260 / 0.07); }
  .bottom-nav-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; background: none; border: 0; font: inherit; cursor: pointer; color: var(--ink-faint); text-decoration: none; font-size: 0.64rem; font-weight: 500; padding: 0.3rem 0; min-width: 0; }
  .bottom-nav-link span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav-link .icon svg { width: 22px; height: 22px; }
  .bottom-nav-link[aria-current="page"] { color: var(--accent); }

  .bottom-sheet:not([hidden]) { display: block; }
  .bottom-sheet-backdrop { position: fixed; inset: 0; background: oklch(20% 0.02 260 / 0.4); z-index: 30; }
  .bottom-sheet-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 0.9rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px oklch(20% 0.02 260 / 0.2); max-height: 85vh; overflow-y: auto; animation: sheet-up 180ms ease-out; }
  @keyframes sheet-up { from { transform: translateY(24px); } to { transform: none; } }
  .bottom-sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
  .bottom-sheet-header strong { font-size: 0.95rem; }
  .bottom-sheet-close { background: none; border: 0; color: var(--ink-faint); cursor: pointer; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; padding: 0; }
  .bottom-sheet-close svg { width: 16px; height: 16px; }
  .bottom-sheet-link { display: flex; align-items: center; gap: 0.85rem; width: 100%; background: none; border: 0; border-top: 1px solid var(--border); font: inherit; cursor: pointer; text-decoration: none; padding: 0.8rem 0.25rem; color: var(--ink); font-size: 0.92rem; font-weight: 500; text-align: left; }
  .bottom-sheet-link .icon svg { width: 20px; height: 20px; color: var(--ink-faint); }
  .bottom-sheet-link[aria-current="page"], .bottom-sheet-link[aria-current="page"] .icon svg { color: var(--accent); }
  .bottom-sheet-link > span { display: flex; flex-direction: column; min-width: 0; }
  .bottom-sheet-sub { font-size: 0.75rem; color: var(--ink-faint); font-weight: 400; }
  .bottom-sheet-logout, .bottom-sheet-logout .icon svg { color: var(--danger); }
  body.sheet-open { overflow: hidden; }
  .toast { left: 0.75rem; right: 0.75rem; bottom: 4.5rem; }
}
@media (max-width: 600px) {
  .app-content { padding: 0.75rem 0.75rem 6rem; }
  .stat .value { font-size: 1.1rem; }
  h1 { font-size: 1.15rem; }
  .page-icon { width: 1.8rem; height: 1.8rem; }
  .page-icon svg { width: 16px; height: 16px; }
  /* Tabellen als kaarten: elke rij een blok, celkoppen via data-label. */
  table.cards { min-width: 0; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards tr.clickable:hover td { background: transparent; }
  table.cards td { display: block; padding: 0; border: 0; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 6.5rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-right: 0.5rem; }
  table.cards td.card-title { order: -1; font-weight: 600; font-size: 1rem; margin-bottom: 0.15rem; }
  table.cards td.card-actions { padding-top: 0.5rem; }
  table.cards td.card-actions .btn-group { display: flex; }
  table.cards td.card-actions .btn { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-collapse-btn svg { transition: none; }
  .bottom-sheet-panel { animation: none; }
}
