:root, [data-theme="licht"] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #1c2433;
  --text-muted: #66718a;
  --border: #d9dfe9;
  --primary: #1e6fd9;
  --primary-text: #ffffff;
  --danger: #c62828;
  --warn: #e65100;
  --soon: #b08900;
  --ok: #2e7d32;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
}

[data-theme="donker"] {
  --bg: #141821;
  --surface: #1d2330;
  --surface-2: #262e3e;
  --text: #e6eaf2;
  --text-muted: #9aa5bb;
  --border: #323b4e;
  --primary: #4d92ed;
  --primary-text: #0d1320;
  --danger: #ef6b5e;
  --warn: #ffa040;
  --soon: #e0c341;
  --ok: #6fc276;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); padding: 1rem 0.75rem;
}
.brand { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.5rem 1rem; }
.brand-mark {
  background: var(--primary); color: var(--primary-text); font-weight: 700;
  padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 0.9rem;
}
.brand-name { font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  padding: 0.45rem 0.6rem; border-radius: 8px; color: var(--text);
  display: flex; align-items: center; gap: 0.4rem;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary); color: var(--primary-text); }
.nav a.sub { padding-left: 1.4rem; font-size: 0.92rem; }
.nav-group {
  margin-top: 0.9rem; padding: 0 0.6rem; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
}
.badge {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.72rem; padding: 0.05rem 0.45rem; font-weight: 600;
}
.nav a.active .badge { background: rgba(255,255,255,0.3); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.25rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.quick-add { flex: 1; display: flex; gap: 0.5rem; max-width: 560px; }
.quick-add input { flex: 1; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-menu summary { cursor: pointer; list-style: none; font-weight: 600; padding: 0.3rem 0.5rem; border-radius: 8px; }
.user-menu summary:hover { background: var(--surface-2); }
.user-menu-panel {
  position: absolute; right: 0; top: 110%; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 0.5rem; min-width: 200px; display: flex; flex-direction: column; gap: 0.3rem; z-index: 20;
}
.content { padding: 1.25rem; max-width: 1280px; width: 100%; }

.page-header {
  display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem;
  justify-content: space-between;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card.narrow { max-width: 480px; }
.muted { color: var(--text-muted); }
.more { display: inline-block; margin-top: 0.5rem; font-size: 0.92rem; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="url"], select, textarea {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
label { display: block; margin: 0.6rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}

.btn {
  display: inline-block; padding: 0.45rem 0.9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; font: inherit; font-weight: 600; text-decoration: none;
}
.btn:hover { filter: brightness(0.96); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 1rem; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; padding: 0.3rem 0.55rem; color: var(--text); font: inherit;
}
.icon-btn.subtle { border: none; color: var(--text-muted); }
.link-btn {
  background: none; border: none; padding: 0; color: var(--primary);
  cursor: pointer; font: inherit; text-align: left;
}
.link-btn.danger { color: var(--danger); font-size: 0.9rem; }

.alert { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.8rem; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border: 1px solid var(--danger); }
.alert-info { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border: 1px solid var(--primary); }

.centered-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
}
.centered-page .card { width: 100%; max-width: 420px; }
.login-brand { padding-bottom: 0.5rem; }

/* Takenlijst */
.task-list, .inbox-list, .checklist, .link-list, .history, .stat-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.task-row:last-child { border-bottom: none; }
.task-row.is-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-title { color: var(--text); font-weight: 600; }
.task-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
.type-icon { width: 1.4rem; text-align: center; flex-shrink: 0; }

.check {
  width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 2px solid var(--border);
  background: transparent; cursor: pointer; flex-shrink: 0; padding: 0;
}
.check:hover { border-color: var(--ok); }
.check.checked { background: var(--ok); border-color: var(--ok); }

.chip {
  display: inline-block; font-size: 0.76rem; padding: 0.1rem 0.5rem;
  border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.chip.tag { color: var(--primary); }
.chip-inbox { border-style: dashed; }
.prio-kritiek { background: var(--danger); color: #fff; border-color: var(--danger); }
.prio-hoog { color: var(--warn); border-color: var(--warn); }
.prio-laag { opacity: 0.7; }
.deadline-overdue { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 700; }
.deadline-today { background: var(--warn); color: #fff; border-color: var(--warn); font-weight: 700; }
.deadline-soon { background: var(--soon); color: #fff; border-color: var(--soon); }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.dash-grid .card { margin-bottom: 0; }
.danger-title { color: var(--danger); }
.big-number { font-size: 2.6rem; font-weight: 700; margin: 0; }
.stat-list li { padding: 0.25rem 0; }
.stat-list a { color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.stat-list .badge { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* Filterbalk */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.filter-bar input[type="search"] { max-width: 220px; }
.filter-bar select { width: auto; }
.checkbox-label { display: flex; align-items: center; gap: 0.3rem; margin: 0; font-weight: 400; }

/* Formulieren */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-actions { margin-top: 1.2rem; display: flex; gap: 0.6rem; }
.task-form { max-width: 100%; }

/* Detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.checklist li, .link-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
.checklist li span { flex: 1; }
.checklist li.is-done span { text-decoration: line-through; color: var(--text-muted); }
.link-list li a { flex: 1; overflow-wrap: anywhere; }
.inline-add { display: flex; gap: 0.4rem; margin-top: 0.6rem; align-items: center; }
.inline-add input { flex: 1; }
.history li { padding: 0.3rem 0; border-bottom: 1px dashed var(--border); font-size: 0.9rem; }
.history li:last-child { border-bottom: none; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.danger-zone .link-btn.danger { margin-top: 0.9rem; display: inline-block; }

/* Inbox */
.inbox-row {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.inbox-row:last-child { border-bottom: none; }
.inbox-row .task-title { flex: 1; min-width: 180px; }
.inbox-sort { display: flex; gap: 0.4rem; align-items: center; }
.inbox-sort select { width: auto; }

/* Kanban */
.kanban { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.6rem; min-width: 240px; width: 240px; flex-shrink: 0;
}
.kanban-col h2 { font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; }
.kanban-col .badge { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.kanban-cards { min-height: 40px; display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.6rem; cursor: grab; box-shadow: var(--shadow);
  border-left-width: 4px;
}
.kanban-card a { color: var(--text); font-weight: 600; display: block; margin: 0.15rem 0; }
.kanban-meta { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.prio-border-kritiek { border-left-color: var(--danger); }
.prio-border-hoog { border-left-color: var(--warn); }
.prio-border-normaal { border-left-color: var(--primary); }
.prio-border-laag { border-left-color: var(--border); }
.drag-ghost { opacity: 0.4; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.table tr.is-archived td { opacity: 0.55; }
.table .inline-add { margin-top: 0; }

/* Responsief */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,0.3); }
  .menu-btn { display: inline-block; }
  .content { padding: 0.9rem; }
}
@media (max-width: 600px) {
  .quick-add button { display: none; }
  .task-meta { margin-left: 2rem; width: 100%; }
}
