:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #6b7280;
    --line: #e3e6ea;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --danger: #c0392b;
    --ok-bg: #e8f6ee;
    --ok-text: #1e6b3d;
    --err-bg: #fdecea;
    --err-text: #9b2c1f;
    --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1150px; margin: 0 auto; padding: 0 20px; }

/* Kopbalk */
.top { background: #1f2937; color: #fff; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 17px; }
.top nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.top nav a, .top nav .linkbtn { color: #d1d5db; padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.top nav a:hover, .top nav .linkbtn:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.top nav a.active { color: #fff; background: rgba(255,255,255,.14); }

main { padding: 28px 20px 60px; }
h1 { font-size: 24px; margin: 0 0 18px; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 22px 0 8px; }

/* Kaarten & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card.narrow { max-width: 480px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid.wide-left { grid-template-columns: 2fr 1fr; }
@media (max-width: 860px) { .grid, .grid.wide-left { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; margin-bottom: 14px; }
.row input { flex: 1; }
.inline { display: inline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* Formulieren */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea {
    font: inherit; padding: 8px 10px; border: 1px solid #cfd4da; border-radius: 6px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--accent); }
input[type=file] { font: inherit; }
textarea { resize: vertical; }

.btn {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
    background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 9px 16px; text-align: center;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: var(--danger); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; margin-left: 10px; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: var(--danger); }
.top .linkbtn { margin-left: 0; }

/* Ledenkiezer */
.picker { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
.picker legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
.picker-list { margin-top: 8px; }
.picker-items { max-height: 220px; overflow-y: auto; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.picker-items label { font-size: 14px; }
.picker-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin: 10px 0 4px; }
.picker-groups { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.picker-groups label { font-size: 14px; }
.tag.group { background: #ecfdf5; color: #065f46; }

/* Bijeenkomsten */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 999px; background: #e5e7eb; color: var(--text); font-size: 14px; }
.tabs a.active { background: var(--accent); color: #fff; }
.tabs a:hover { text-decoration: none; }
.tabs .spacer { flex: 1; }
.tabs select { width: auto; }
.meeting-list { list-style: none; margin: 0; padding: 0; }
.meeting-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.meeting-item:last-child { border-bottom: 0; }
.datebox { flex: 0 0 58px; text-align: center; border-radius: 8px; background: #eff6ff; color: #1e40af; padding: 6px 0; line-height: 1.1; }
.datebox.past { background: #f3f4f6; color: var(--muted); }
.datebox .d { display: block; font-size: 22px; font-weight: 700; }
.datebox .mo { display: block; font-size: 12px; text-transform: uppercase; font-weight: 600; }
.datebox .y { display: block; font-size: 11px; opacity: .8; }
.meeting-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meeting-title { font-weight: 600; font-size: 15px; }
.tag.type { background: #f3e8ff; color: #6b21a8; margin-left: 0; }
.tag.minutes { background: #fef9c3; color: #854d0e; }
.tag.topic { background: #f1f5f9; color: #334155; text-decoration: none; }
.tag.topic:hover { background: #e2e8f0; }
.tag.rsvp.yes { background: #dcfce7; color: #166534; }
.tag.rsvp.no { background: #fee2e2; color: #991b1b; }
.tag.rsvp.maybe { background: #fef3c7; color: #92400e; }
.tag.kind-agenda { background: #dbeafe; color: #1e40af; margin-left: 0; }
.tag.kind-bijlage { background: #f3f4f6; color: #374151; margin-left: 0; }
.tag.kind-notulen { background: #fef9c3; color: #854d0e; margin-left: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }
.file-list { list-style: none; padding: 0; margin: 0 0 12px; }
.file-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-list li:last-child { border-bottom: 0; }
.upload-box { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.minutes { background: #fffdf3; border: 1px solid #f5ecc4; border-radius: 8px; padding: 14px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 12px; }
.rsvp-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.yes { background: #16a34a; } .btn.yes:hover { background: #15803d; }
.btn.maybe { background: #d97706; } .btn.maybe:hover { background: #b45309; }
.btn.no { background: #dc2626; } .btn.no:hover { background: #b91c1c; }
.invitee-list { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow-y: auto; }
.invitee-list li { padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* Kennisbank */
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-form input[type=search] { flex: 1 1 280px; width: auto; }
.search-form select { width: auto; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag-cloud .tag { margin-left: 0; font-size: 12px; }
.kb-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kb-item:last-child { border-bottom: 0; }
.snippet { margin: 6px 0; font-size: 14px; color: #374151; }
mark { background: #fde68a; padding: 0 1px; border-radius: 2px; }

/* Groepen */
.group-list { list-style: none; padding: 0; margin: 0; }
.group-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.group-list li:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #f3f4f6; border-radius: 999px; padding: 2px 10px; font-size: 13px; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tr.inactive td { opacity: .55; }
.nowrap { white-space: nowrap; }

/* Berichten */
.news { padding: 14px 0; border-bottom: 1px solid var(--line); }
.news:first-of-type { padding-top: 0; }
.news:last-child { border-bottom: 0; }
.news h3 { margin: 0 0 2px; font-size: 16px; }
.news .body { margin-top: 6px; }

/* Overig */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: middle; }
.tag.warn { background: #fff4e5; color: #9a5b00; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.error { background: var(--err-bg); color: var(--err-text); }

/* Secretariaat */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 26px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.tile strong { font-size: 16px; color: var(--accent); }
.tile span { font-size: 13px; color: var(--muted); }
.tile:hover { text-decoration: none; border-color: var(--accent); box-shadow: 0 4px 14px rgba(37,99,235,.10); }
.tag.org { background: #fff7ed; color: #9a3412; }
.tag.public { background: #dcfce7; color: #166534; text-decoration: none; }
.org-cell { display: flex; align-items: center; gap: 12px; }
.org-logo-sm { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px; flex: 0 0 auto; }
.org-logo-lg { max-width: 220px; max-height: 110px; object-fit: contain; }
.post-thumb { width: 64px; height: 44px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.post-preview { max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: cover; }
.label-text { display: block; font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.faq-actions { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.faq-actions .linkbtn { margin-left: 0; }

/* Teksteditor */
.editor { border: 1px solid #cfd4da; border-radius: 6px; background: #fff; }
.editor:focus-within { outline: 2px solid rgba(37,99,235,.35); border-color: var(--accent); }
.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: #f9fafb; border-radius: 6px 6px 0 0; }
.editor-bar button { font: inherit; font-size: 13px; background: none; border: 1px solid transparent; border-radius: 4px; padding: 3px 8px; cursor: pointer; color: var(--text); }
.editor-bar button:hover { background: #e5e7eb; }
.editor-area { padding: 10px 12px; outline: none; overflow-wrap: anywhere; }
.editor-area p { margin: 0 0 10px; }
.editor-area img { max-width: 100%; }

/* Lange woorden (bestandsnamen, e-mailadressen) mogen afbreken i.p.v. de pagina te verbreden */
.card, .table td { overflow-wrap: anywhere; }
.linkbtn, .tag { white-space: nowrap; overflow-wrap: normal; }
.file-list li > :first-child { min-width: 0; }
.file-list li > :last-child:not(:first-child) { flex-shrink: 0; }
img, video { max-width: 100%; height: auto; }

/* Brede pagina's (grote overzichten): $wide = true vóór header.php */
body.wide .wrap { max-width: 1480px; }

/* Werkbalk met zoekveld en filterknoppen */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.search-field { position: relative; flex: 1 1 280px; max-width: 460px; }
.search-field svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input[type=search] { padding: 10px 14px 10px 38px; border-radius: 999px; background: #f9fafb; border-color: var(--line); }
.search-field input[type=search]:focus { background: #fff; }
.segmented { display: inline-flex; background: #f1f3f5; border-radius: 999px; padding: 3px; gap: 2px; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; color: #374151; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.segmented a:hover { text-decoration: none; background: rgba(255,255,255,.7); }
.segmented a.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.segmented a span { font-size: 12px; font-weight: 600; color: var(--muted); background: rgba(0,0,0,.05); border-radius: 999px; padding: 0 7px; }
.segmented a.active span { background: #eef2ff; color: var(--accent); }
.result-count { margin: 0 0 6px; }

/* Brede tabel: kop blijft staan bij scrollen, rijen lichten op */
.table-scroll { overflow: auto; max-height: calc(100vh - 250px); min-height: 240px; border-top: 1px solid var(--line); }
.table-scroll .table thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.table-scroll .table tbody tr:hover td { background: #f9fafb; }
.org-initial { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: #64748b; background: #f1f5f9; }

/* Modal (dialog) */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(16,24,40,.25); color: var(--text); }
.modal::backdrop { background: rgba(17,24,39,.45); backdrop-filter: blur(2px); }
.modal form { padding: 22px 24px 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) {
    .search-field { max-width: none; flex-basis: 100%; }
    .segmented { overflow-x: auto; max-width: 100%; }
    .table-scroll { overflow: visible; max-height: none; min-height: 0; border-top: 0; }
}

/* Menuknop (alleen zichtbaar op smalle schermen) */
.nav-toggle { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 860px) {
    main { padding: 20px 14px 48px; }
    .wrap { padding: 0 14px; }
    .card { padding: 18px; }
}

/* ---------- Mobiel ---------- */
@media (max-width: 760px) {
    /* Uitklapmenu (alleen met JavaScript; zonder JS blijft het menu gewoon zichtbaar) */
    .js .nav-toggle {
        display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
        width: 42px; height: 42px; padding: 0 10px; margin-right: -6px;
        background: none; border: 0; border-radius: 6px; cursor: pointer;
    }
    .js .nav-toggle:hover { background: rgba(255,255,255,.08); }
    .nav-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
    .nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
    .nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    .js .top nav { display: none; }
    .js .top.nav-open nav {
        display: flex; flex-direction: column; align-items: stretch; gap: 2px;
        flex-basis: 100%; padding: 4px 0 12px; border-top: 1px solid rgba(255,255,255,.1);
    }
    .top nav a, .top nav .linkbtn { padding: 11px 12px; font-size: 16px; }
    .top nav form.inline { display: block; }
    .top nav .linkbtn { width: 100%; text-align: left; }

    h1 { font-size: 21px; }
    .card { padding: 16px; }

    /* 16px voorkomt dat iOS inzoomt bij het typen */
    input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), select, textarea { font-size: 16px; }
    .btn { padding: 11px 16px; }

    .facts { grid-template-columns: 1fr; gap: 0; }
    .facts dt { margin-top: 8px; }
    .row { flex-wrap: wrap; }
    .search-form input[type=search] { flex-basis: 100%; }
    .tabs .spacer { flex-basis: 100%; height: 0; }

    /* Tabellen worden kaartjes: één blok per rij, met de kolomnaam als label */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
    .table tr:last-child { border-bottom: 0; }
    .table td { border: 0; padding: 2px 0; white-space: normal; }
    .table td[data-label]:not(:first-child)::before {
        content: attr(data-label) ": "; color: var(--muted); font-size: 13px;
    }
    .table td:first-child { font-weight: 500; padding-bottom: 4px; }
    .table td:last-child:not(:first-child) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding-top: 6px; }
    .table td:last-child .linkbtn { margin-left: 0; }
}
