:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #dde3e8;
  --text: #1e2a35;
  --muted: #64748a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
#login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
}
#login-box h1 { font-size: 20px; margin: 0 0 20px; }
#login-box input {
  width: 100%; padding: 10px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
#login-box button, .btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 16px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
#login-box button:hover, .btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #e5e9ed; color: var(--text); }
.btn.secondary:hover { background: #d7dce1; }
.btn.danger { background: var(--danger); }
#login-error { color: var(--danger); font-size: 13px; margin-top: -4px; margin-bottom: 8px; min-height: 16px; }

/* Zijbalk-navigatie (op smalle schermen een uitschuifmenu) */
#app-shell { display: none; min-height: 100vh; flex-direction: row; }
#sidebar {
  width: 230px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
#sidebar .brand { font-weight: 600; font-size: 16px; padding: 18px 18px 12px; word-break: break-word; }
#sidebar nav { flex: 1; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 1px; }
#sidebar nav a {
  padding: 8px 10px; border-radius: 6px; text-decoration: none;
  color: var(--text); font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
#sidebar nav a:hover { background: #eef1f4; }
#sidebar nav a.active { background: var(--accent); color: #fff; }
#sidebar nav .nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 14px 10px 4px; }
#sidebar .who { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
#sidebar .who-actions { display: flex; gap: 6px; margin-top: 8px; }
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#mobilebar { display: none; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
#mobilebar .brand { font-weight: 600; }
#sidebar-backdrop { display: none; }
@media (max-width: 900px) {
  #app-shell { flex-direction: column; }
  #mobilebar { display: flex; position: sticky; top: 0; z-index: 30; }
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-105%); transition: transform .2s; box-shadow: 4px 0 16px rgba(0,0,0,.15); }
  #sidebar.open { transform: none; }
  #sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  main { padding: 16px; }
}

main { flex: 1; padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.tbl-filter { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; margin-bottom: 10px; width: 260px; max-width: 100%; }
.import-map { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; align-items: center; }
.import-map label { font-size: 13px; }
.import-map select { padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 100%; }
.import-sample { overflow-x: auto; font-size: 12px; margin: 10px 0; }
.import-sample table { font-size: 12px; }
.warn { color: #92400e; font-size: 13px; }
.ok-text { color: #166534; }
.err-text { color: var(--danger); font-size: 13px; }
.page { display: none; }
.page.active { display: block; }
h2 { font-size: 20px; margin: 0 0 16px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #eef1f4; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f7f9fb; }
th.num, td.num { text-align: right; }
tfoot td { border-top: 2px solid var(--text); border-bottom: none; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  align-items: center; justify-content: center; z-index: 50;
}
.overlay.active { display: flex; }
.modal {
  background: var(--panel); border-radius: var(--radius); padding: 24px;
  width: 520px; max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.form-grid input, .form-grid select {
  width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 6px; font-size: 14px; opacity: 0; transition: opacity .2s;
  z-index: 100;
}
.toast.show { opacity: 1; }
.muted { color: var(--muted); font-size: 13px; }

/* ── Nieuwe modules: dashboard, berichten, CRM, rapporten ─────────────────── */
.form-grid textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; min-height: 70px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 20px; }
.grid-cards .panel { margin-bottom: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { background: #eef1f4; border-radius: var(--radius); padding: 12px; cursor: pointer; }
.tile:hover { background: #e3e8ed; }
.tile .n { font-size: 24px; font-weight: 600; }
.tile .l { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; text-align: center; margin-left: 4px; }
.badge:empty { display: none; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.chip { display: inline-block; background: #e6eefc; color: #1e40af; border-radius: 12px; padding: 2px 10px; font-size: 12px; margin: 2px 4px 2px 0; cursor: pointer; }
.chip.file { background: #eef1f4; color: var(--text); }
.chip .x { margin-left: 6px; cursor: pointer; font-weight: 700; }
.chat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; min-height: 480px; }
.chat-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-list .item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.chat-list .item:hover { background: #f7f9fb; }
.chat-list .item.active { background: #e6eefc; }
.chat-list .item .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; max-height: 420px; min-height: 280px; }
.msg { margin-bottom: 12px; }
.msg .meta { font-size: 12px; color: var(--muted); }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg.sys { text-align: center; color: var(--muted); font-size: 12px; font-style: italic; }
.msg .acts { display: none; font-size: 12px; margin-left: 8px; }
.msg:hover .acts { display: inline; }
.msg .acts a { cursor: pointer; color: var(--accent); margin-right: 6px; }
.composer { border-top: 1px solid var(--border); padding: 10px 14px; }
.composer textarea { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-family: inherit; font-size: 14px; resize: vertical; min-height: 54px; }
.composer .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.picker { position: relative; }
.picker .results { position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; max-height: 220px; overflow-y: auto; min-width: 320px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.picker .results div { padding: 6px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.picker .results div:hover { background: #f1f5f9; }
.task { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.task .t-title { font-weight: 600; }
.task .t-meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.task.overdue .t-meta .dl { color: var(--danger); font-weight: 600; }
.task .t-acts { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.row-actions { white-space: nowrap; }
.report-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.report-list .item { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.report-list .item:hover { background: #f7f9fb; }
.report-list .item.active { background: #e6eefc; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 12px; font-size: 13px; }
.check-grid label { display: flex; gap: 6px; align-items: center; color: var(--text); margin: 0; }
.check-grid input { width: auto; }
tr.total td { font-weight: 600; border-top: 2px solid var(--text); }
@media (max-width: 800px) { .chat-layout, .report-layout { grid-template-columns: 1fr; } }
@media print {
  #sidebar, #mobilebar, .toolbar, .modal-actions, .no-print, .toast, .overlay, .tbl-filter { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .panel { border: none; padding: 0; }
}
.no-perm { display: none !important; }
.qr-box { width: 190px; background: #fff; padding: 4px; flex: none; }
.qr-box svg { width: 100%; height: auto; display: block; }
