:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #646b78;
  --accent: #1f4fd1;
  --accent-soft: #e6ecfc;
  --ok: #17803d;
  --ok-soft: #e3f4e8;
  --warn: #a15c00;
  --warn-soft: #fdf0dc;
  --danger: #c0282d;
  --danger-soft: #fbe6e7;
  --violet: #6b3fc4;
  --violet-soft: #efe8fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --sidebar: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1a1d23; --surface-2: #22262d; --border: #2e333b;
    --text: #e8eaee; --muted: #9aa1ad; --accent: #7c9cff; --accent-soft: #1f2a4a;
    --ok: #5cc98a; --ok-soft: #173424; --warn: #f0b458; --warn-soft: #3a2c15;
    --danger: #ff7a7f; --danger-soft: #3d1c1e; --violet: #b99bff; --violet-soft: #2c2342;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---------- Layout ---------- */
body:not(.bare) { padding-left: var(--sidebar); }
.topbar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem .8rem;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); padding: 0 .4rem; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 800; }
.logo-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.2rem; margin-bottom: 1rem; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.me { border-top: 1px solid var(--border); padding: .8rem .4rem 0; display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.me-name { font-weight: 600; }
.main { max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 4rem; }

@media (max-width: 900px) {
  body:not(.bare) { padding-left: 0; }
  .topbar { position: sticky; top: 0; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); z-index: 10; }
  .nav { order: 3; flex: 1 0 100%; flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem; }
  .nav a { flex: none; padding: .4rem .6rem; font-size: .9rem; }
  .nav a span { white-space: nowrap; }
  .me { margin-left: auto; border: 0; padding: 0; flex-direction: row; align-items: center; gap: .8rem; }
  .me-name .tag { display: none; }
  .main { padding: 1.25rem 1rem 3rem; }
}

/* ---------- Common ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.crumbs { margin: 0 0 .3rem; color: var(--muted); font-size: .9rem; }
.muted, .meta, .hint { color: var(--muted); }
.meta { font-size: .85rem; display: block; }
.hint { font-size: .85rem; font-weight: 400; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.5rem 0 .6rem; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; }
.empty.card { font-style: normal; text-align: center; padding: 2rem; }
.empty-page { max-width: 480px; margin: 12vh auto; text-align: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 500; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸ '; }
details[open] > summary::before { content: '▾ '; }
details[open] > summary { margin-bottom: .8rem; }
details.card > summary { margin: 0; }
details.card[open] > summary { margin-bottom: 1rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1.2rem; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Buttons ---------- */
.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: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0b1020; } }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.icon-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form.compact { gap: .6rem; }
.form label, .stack label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1 1 180px; }
:where(input:not([type=checkbox]):not([type=radio]), select, textarea) {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem;
}
.row > input, .row > select { width: auto; flex: 0 1 auto; }
.row > input.grow { flex: 1 1 200px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 4rem; }
textarea.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9rem; }
.check-label { flex-direction: row !important; align-items: center; gap: .5rem !important; flex-wrap: wrap; }
.form-actions { display: flex; gap: 1rem; align-items: center; }
.inline-form { display: flex; gap: .5rem; margin-top: .8rem; }
.seg { border: 0; padding: 0; margin: 0; display: flex; gap: .5rem; flex-wrap: wrap; }
.seg legend { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.seg label { flex-direction: row; align-items: center; gap: .4rem; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .8rem; cursor: pointer; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 240px; width: auto; }
.filters select { width: auto; }

/* ---------- Tags & status ---------- */
.tag, .status, .pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.tag-admin { background: var(--violet-soft); color: var(--violet); }
.tag-idee { background: var(--accent-soft); color: var(--accent); }
.tag-klacht { background: var(--danger-soft); color: var(--danger); }
.tag-vraag { background: var(--warn-soft); color: var(--warn); }
.tag-conf { background: var(--surface-2); color: var(--text); }
.status-nieuw { background: var(--accent-soft); color: var(--accent); }
.status-in_behandeling { background: var(--warn-soft); color: var(--warn); }
.status-bij_directie { background: var(--violet-soft); color: var(--violet); }
.status-afgerond, .status-afgerond { background: var(--ok-soft); color: var(--ok); }
.status-gepland { background: var(--accent-soft); color: var(--accent); }
h1 .status, h1 .tag { font-size: .8rem; position: relative; top: -3px; }
.count { font-size: .75rem; color: var(--muted); font-weight: 600; }
.due { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.due.late { color: var(--danger); font-weight: 600; }
.col-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; margin-right: .45rem; }
.col-todo { background: var(--muted); }
.col-bezig { background: var(--warn); }
.col-klaar { background: var(--ok); }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .65rem; font-weight: 700; flex: none; }
.avatar-lg { width: 40px; height: 40px; font-size: .85rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .55rem .8rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Lists & tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
.list-row form { margin: 0; display: flex; }
.list-row a.grow { color: var(--text); }
.done .grow, tr.done td:nth-child(2) { text-decoration: line-through; color: var(--muted); }
.check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; flex: none; padding: 0; position: relative; }
.check:hover { border-color: var(--ok); }
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on::after { content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem 1rem; border-top: 1px solid var(--border); vertical-align: middle; }
.table th { border-top: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table td form { margin: 0; }
.w-check { width: 40px; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; color: var(--muted); display: flex; flex-direction: column; box-shadow: var(--shadow); font-size: .9rem; }
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat-n { font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.2; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 1rem; }
.meeting-hero { display: flex; flex-direction: column; background: var(--accent-soft); border-radius: 8px; padding: .8rem 1rem; color: var(--text); margin-bottom: .8rem; }
.meeting-hero span { color: var(--accent); font-size: .9rem; font-weight: 500; }
.meeting-hero:hover { text-decoration: none; filter: brightness(.98); }
.agenda-mini { margin: 0; padding-left: 1.3rem; color: var(--muted); font-size: .9rem; }
@media (max-width: 900px) { .stats { grid-template-columns: 1fr 1fr; } .grid-2 { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 480px) { .list-row { flex-wrap: wrap; } .list-row .status { margin-left: auto; } }

/* ---------- Meetings ---------- */
.meeting-list { display: flex; flex-direction: column; gap: .6rem; }
.meeting-item { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; color: var(--text); }
.meeting-item:hover { border-color: var(--accent); text-decoration: none; }
.datebox { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: .75rem; text-transform: uppercase; font-weight: 600; flex: none; }
.datebox b { font-size: 1.3rem; line-height: 1; }
.grid-meeting { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 1rem; margin-top: 1rem; }
@media (max-width: 900px) { .grid-meeting { grid-template-columns: minmax(0,1fr); } }
.agenda { margin: 0; padding: 0; list-style: none; counter-reset: a; }
.agenda li { counter-increment: a; display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--border); }
.agenda li:first-child { border-top: 0; }
.agenda li::before { content: counter(a); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); display: inline-grid; place-items: center; font-size: .8rem; font-weight: 600; color: var(--muted); flex: none; }
.row-tools { display: flex; gap: 2px; opacity: .55; }
.agenda li:hover .row-tools { opacity: 1; }
.row-tools form { margin: 0; }

/* ---------- Prose (markdown) ---------- */
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.25rem; margin: 1.4rem 0 .5rem; }
.prose h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.prose ul, .prose ol { padding-left: 1.4rem; margin: 0 0 .8rem; }
.prose table { border-collapse: collapse; margin: .5rem 0 1rem; width: 100%; }
.prose th, .prose td { border: 1px solid var(--border); padding: .4rem .7rem; text-align: left; }
.prose th { background: var(--surface-2); }
.prose blockquote { margin: 0 0 .8rem; padding-left: 1rem; border-left: 3px solid var(--border); color: var(--muted); }

/* ---------- Signals ---------- */
.signal-list { display: flex; flex-direction: column; gap: .6rem; }
.signal-item { display: flex; flex-direction: column; gap: .3rem; color: var(--text); margin: 0; }
.signal-item:hover { border-color: var(--accent); text-decoration: none; }
.signal-top { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .2rem; }
.signal-top .status { margin-left: auto; }
.page-head .signal-top .status { margin-left: 0; }
.grid-side { display: grid; grid-template-columns: minmax(0,1fr) 290px; gap: 1rem; align-items: start; }
.side { position: sticky; top: 1rem; }
@media (max-width: 900px) { .grid-side { grid-template-columns: minmax(0,1fr); } .side { position: static; order: -1; } }
.timeline { list-style: none; margin: 0 0 1rem; padding: 0 0 0 1rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1rem .6rem; }
.timeline li::before { content: ''; position: absolute; left: calc(-1rem - 6px); top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .prose p:last-child { margin-bottom: 0; }

/* ---------- Kanban ---------- */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.board-tile { display: flex; flex-direction: column; gap: .5rem; color: var(--text); margin: 0; }
.board-tile:hover { border-color: var(--accent); text-decoration: none; }
progress.progress { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
progress.progress::-webkit-progress-bar { background: var(--surface-2); }
progress.progress::-webkit-progress-value { background: var(--ok); border-radius: 99px; }
progress.progress::-moz-progress-bar { background: var(--ok); }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 1rem; align-items: start; overflow-x: auto; padding-bottom: .5rem; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.kcol h2 { font-size: .9rem; margin: 0 .2rem; display: flex; align-items: center; }
.kcol h2 .count { margin-left: .4rem; }
.kcards { display: flex; flex-direction: column; gap: .5rem; min-height: 40px; border-radius: 8px; transition: background .15s; }
.kcards.over { background: var(--accent-soft); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem; box-shadow: var(--shadow); cursor: grab; }
.kcard.dragging { opacity: .45; }
.kcard-title { color: var(--text); font-weight: 500; display: block; }
.kcard-desc { font-size: .85rem; color: var(--muted); margin: .25rem 0 0; }
.kcard-foot { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; min-height: 24px; }
.kmove { margin-left: auto; display: flex; }
.kmove form { margin: 0; }
.kadd input { background: transparent; border-style: dashed; }
.kadd input:focus { background: var(--surface); }
.menu { position: relative; }
.menu > summary::before { content: none; }
.menu[open] > summary { margin: 0; }
.menu-body { position: absolute; right: 0; top: calc(100% + .4rem); width: 280px; z-index: 5; display: flex; flex-direction: column; gap: .6rem; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.menu-body form { margin: 0; }
@media (max-width: 900px) { .kanban { grid-template-columns: repeat(3, 82vw); scroll-snap-type: x mandatory; } .kcol { scroll-snap-align: start; } }

/* ---------- Members ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.member { margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.member.inactive { opacity: .6; }
.member-top { display: flex; align-items: center; gap: .75rem; }

/* ---------- Wiki ---------- */
.grid-wiki { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 1.5rem; align-items: start; }
.wiki-nav .section-title { margin-top: 0; }
.wiki-nav nav { display: flex; flex-direction: column; gap: 2px; }
.wiki-nav nav a { padding: .45rem .7rem; border-radius: 8px; color: var(--text); }
.wiki-nav nav a:hover { background: var(--surface); text-decoration: none; }
.wiki-nav nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.wiki-body { padding: 1.5rem 2rem; }
@media (max-width: 900px) {
  .grid-wiki { grid-template-columns: minmax(0,1fr); gap: .5rem; }
  .wiki-nav nav { flex-direction: row; overflow-x: auto; }
  .wiki-nav nav a { white-space: nowrap; }
  .wiki-body { padding: 1.1rem 1.25rem; }
}

/* ---------- Login ---------- */
.login { min-height: 90vh; display: grid; place-items: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem 2rem; width: min(400px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(16,24,40,.08); }
.login-card h1 { font-size: 1.4rem; }
.login-card .btn-block { margin-top: 1rem; padding: .7rem; }
.devlogin { margin-top: 1.5rem; text-align: left; border-top: 1px dashed var(--border); padding-top: 1rem; }
.devlogin summary { color: var(--warn); font-size: .9rem; }
.stack { display: flex; flex-direction: column; gap: .7rem; }

/* ---------- Print (notulen als PDF) ---------- */
@media print {
  body:not(.bare) { padding: 0; }
  .topbar, .no-print, .flash, details:not([open]) { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; margin-bottom: 1.2rem; }
  .grid-meeting { grid-template-columns: 1fr; }
  a { color: inherit; }
}
