/* Onderzoekenplanner – basisstijl.
   Kleuren en maten als variabelen; licht en donker volgen het systeem. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --text: #1c2420;
  --muted: #5b665f;
  --border: #d6dcd7;
  --primary: #2f6b4f;
  --primary-hover: #255840;
  --primary-text: #ffffff;
  --focus: #1f6feb;
  --danger: #b42318;
  --info-bg: #e8f1fb;   --info-text: #164a7a;
  --success-bg: #e7f4ec; --success-text: #1d5e3a;
  --warning-bg: #fdf3e0; --warning-text: #7a4b07;
  --error-bg: #fdecea;  --error-text: #8f1d14;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211e;
    --surface-2: #232a26;
    --text: #e6ebe7;
    --muted: #a3ada6;
    --border: #343d38;
    --primary: #5fae86;
    --primary-hover: #74c19a;
    --primary-text: #0d1a13;
    --focus: #6ea8fe;
    --danger: #f97066;
    --info-bg: #13283d;    --info-text: #b6d4f5;
    --success-bg: #12291c; --success-text: #a6dbbb;
    --warning-bg: #33260b; --warning-text: #f3cf8e;
    --error-bg: #3a1512;   --error-text: #f6b5ae;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }
/* Het attribuut hidden wint altijd, ook van display-regels (zoals .tabs). */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; }
.skip-link:focus { left: 8px; background: var(--surface); padding: .5rem 1rem; border-radius: var(--radius); }

.muted { color: var(--muted); }

/* ---------- Knoppen ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .5rem 1rem;
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text);
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: var(--primary-text); }
.btn-quiet { background: transparent; border-color: var(--border); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-quiet { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }

/* ---------- Formulieren ---------- */

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field label { font-weight: 600; }
.field input, .field select, .field textarea, .daymonth select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .55rem .7rem; min-height: 42px; width: 100%;
}
.field textarea { min-height: auto; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--focus); }
.field-hint { margin: 0; color: var(--muted); font-size: .875rem; }
.form-narrow { max-width: 420px; }

fieldset.field { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.field legend { font-weight: 600; padding: 0; margin-bottom: .3rem; }
.daymonth-inputs { display: grid; grid-template-columns: 5.5rem 1fr; gap: .5rem; }
.form-grid { display: grid; gap: 0 1.25rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .25rem; }

/* ---------- Meldingen ---------- */

.alert { border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; }
.alert-info    { background: var(--info-bg);    color: var(--info-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-error   { background: var(--error-bg);   color: var(--error-text); }

/* ---------- Inloggen e.d. (zonder menu) ---------- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}
.auth-brand { color: var(--primary); font-weight: 700; margin-bottom: .25rem; }
.auth-help { color: var(--muted); font-size: .9rem; margin: 1.25rem 0 0; }

.page-loading { padding: 2rem; color: var(--muted); }

/* ---------- Raamwerk ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-height); display: flex; align-items: center; gap: 1rem;
  padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.user-link { display: flex; flex-direction: column; line-height: 1.2; text-align: right; text-decoration: none; color: var(--text); }
.user-role { font-size: .8rem; color: var(--muted); }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; color: var(--text); cursor: pointer; min-width: 40px; min-height: 40px; }

.layout { display: flex; min-height: calc(100vh - var(--topbar-height)); }

.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .5rem;
}
.sidebar { display: flex; flex-direction: column; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar-bottom { margin-top: auto !important; padding-top: 1rem !important; border-top: 1px solid var(--border) !important; }
.sidebar a {
  display: block; padding: .55rem .8rem; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { background: var(--surface-2); color: var(--primary); font-weight: 600; }

.content { flex: 1; min-width: 0; padding: 1.5rem; }
.content:focus { outline: none; }
.page { max-width: 1100px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.25rem; margin-bottom: 1.25rem;
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.5rem; margin: 0 0 1.5rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.card-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card a {
  display: block; height: 100%; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.card a:hover { border-color: var(--primary); }
.card h2 { color: var(--primary); }
.card p { color: var(--muted); margin-bottom: .5rem; }

.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.empty-state { border: 1px dashed var(--border); border-radius: 12px; padding: 2rem; color: var(--muted); text-align: center; }

.confirm-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }

/* ---------- Pagina-onderdelen ---------- */

.page-header, .section-header {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: .75rem 1rem; margin-bottom: 1rem;
}
.page-header h1 { margin-bottom: .25rem; }
.page-header p { margin: 0; }
.section-header { align-items: center; margin-top: 1.75rem; }
.section-header h2 { margin: 0; }
.section-header p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.btn-small { min-height: 32px; padding: .25rem .65rem; font-size: .875rem; }
.inline-field { margin: 0; min-width: 240px; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .9rem; color: var(--muted); margin-bottom: .75rem; }
.breadcrumbs a { color: var(--muted); }

.filters { display: grid; gap: 0 1rem; grid-template-columns: 2fr 1fr 1fr; align-items: end; margin-bottom: .5rem; }
.search-row { display: flex; gap: .5rem; }
.search-row input { flex: 1; }

.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-narrow { width: auto; min-width: 320px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: .4rem; }

.badge-ok { background: var(--success-bg); color: var(--success-text); }
.badge-warn { background: var(--warning-bg); color: var(--warning-text); }
.badge-error { background: var(--error-bg); color: var(--error-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab {
  font: inherit; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: .6rem 1rem; color: var(--muted); cursor: pointer; min-height: 44px;
}
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.panel h3 { font-size: 1.05rem; margin: 0 0 .75rem; }

/* ---------- Vinkjes, competenties, beschikbaarheid ---------- */

.checkbox { display: flex; align-items: center; gap: .45rem; margin: .25rem 0 1rem; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--primary); }
.checkbox-bottom { align-self: end; margin-bottom: 1.4rem; }
.filters-2 { grid-template-columns: 2fr 1fr; }
.section-header-tight { margin-top: 0; }
.inline-select .field { margin: 0; min-width: 120px; }

/* Panelen naast elkaar (bijv. Contact en Competenties); smal onder elkaar */
.panel-row { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; margin-bottom: 1.25rem; }
.panel-row > .panel { margin-bottom: 0; }
.competence-list { margin-bottom: 1rem; }
.species-choices { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
fieldset.field .checkbox { margin: .3rem 0; font-weight: 400; }
fieldset.field .checkbox input { min-height: 0; padding: 0; }

.slot-grid { border-collapse: separate; border-spacing: 3px; margin: .5rem 0 1rem; font-size: .85rem; }
.slot-grid th { font-weight: 600; color: var(--muted); padding: 0 .3rem; text-align: left; }
.slot-grid thead th { text-align: center; }
.slot { width: 32px; height: 22px; border-radius: 4px; }
.slot-on { background: var(--success-bg); outline: 1px solid var(--border); }
.slot-off { background: var(--error-bg); outline: 1px solid var(--danger); }

.slot-picker button.slot { display: block; border: 0; padding: 0; cursor: pointer; }
.slot-picker button.slot:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.period-slots { margin: .5rem 0 1rem; }
.period-slots h4 { margin: .25rem 0; font-size: .95rem; }
.period-slots .slot-grid { margin-bottom: .4rem; }
.field-label { font-weight: 600; margin: .75rem 0 .25rem; }
.panel-inner { margin-top: .75rem; background: var(--surface-2); box-shadow: none; }
.panel-inner h3, .panel-inner h4 { margin-top: 0; }

.row-details > td { background: var(--surface-2); }
.availability h3 { margin-top: .75rem; }

/* ---------- Dialoog ---------- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 45%);
  display: grid; place-items: center; padding: 1rem;
}
.dialog {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow); padding: 1.5rem;
  max-height: calc(100vh - 2rem); overflow-y: auto; box-sizing: border-box;
}
/* Knoppen altijd in beeld, ook bij een lange dialoog. */
.dialog-actions {
  display: flex; flex-wrap: wrap; gap: .75rem;
  position: sticky; bottom: -1.5rem; margin: 0 -1.5rem -1.5rem; padding: .75rem 1.5rem 1.5rem;
  background: var(--surface); border-top: 1px solid var(--border);
}
.countdown { font-variant-numeric: tabular-nums; }

/* ---------- Smal scherm ---------- */

@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { gap: .5rem; padding: 0 .5rem; }
  .user-link { display: none; }
  .brand { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar {
    position: fixed; top: var(--topbar-height); bottom: 0; left: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .15s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .content { padding: 1rem; }
  .filters, .filters-2 { grid-template-columns: 1fr; }
  .checkbox-bottom { margin-bottom: 1rem; }
  .inline-field { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Toewijzen van beschikbaarheidsperiodes in het overzicht */
.checkbox-inline { display: inline-flex; margin: 0; }
.period-cell { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }

/* W4: projecten en clusters */
.filters-4 { grid-template-columns: 2fr 1fr 1fr 1fr; }
@media (max-width: 720px) { .filters-4 { grid-template-columns: 1fr; } }
.header-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.pre-wrap { white-space: pre-wrap; }
.progress { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.progress-bar { display: inline-block; width: 70px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress-fill { display: block; height: 100%; background: var(--primary); }
.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: .5rem 0 1rem; }
.inline-form .field { margin: 0; min-width: 220px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.plain-list li { padding: .25rem 0; }
/* Bevindingen bij een geweigerde planning, per onderwerp. */
.finding-group .plain-list { margin-bottom: .25rem; }
.finding-heading { margin: .5rem 0 0; font-weight: 600; }
.finding-group.is-warning { color: var(--muted); }
.finding-group.is-warning .finding-heading { font-weight: 500; }
/* Voorstelvenster: kader per bezoeknummer. */
fieldset.field.visit-box { border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .75rem .5rem; margin: 0 0 .75rem; }
fieldset.field.visit-box legend { padding: 0 .35rem; margin-bottom: 0; }
fieldset.field.visit-box.is-blocked { border-style: dashed; color: var(--muted); }
fieldset.field.visit-box .plain-list { margin: 0; }
/* Reacties op een oproep voor een telling. */
.call-responses .call-group { margin: .4rem 0 .15rem; }
.call-responses .call-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
/* Vraag "toch inplannen?" (medewerker afwezig / niet beschikbaar). */
.confirm-unavailable p { margin: 0 0 .5rem; }
.confirm-unavailable .confirm-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.cluster-detail h3 { font-size: 1.05rem; margin: .5rem 0; }
.obligation-group { margin-bottom: 1rem; }
.obligation-group h4 { margin: .75rem 0 .35rem; font-size: .95rem; }
.table-compact td, .table-compact th { padding-top: .3rem; padding-bottom: .3rem; }
.table-compact { table-layout: fixed; width: 100%; }
.table-compact th:nth-child(1) { width: 4.5rem; }
.table-compact th:nth-child(2) { width: 13rem; }
.table-compact th:nth-child(3) { width: 7rem; }
.table-compact th:nth-child(5) { width: 7rem; }
.table .inline-select label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.table .inline-select .field { margin: 0; }
.nowrap { white-space: nowrap; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .25rem 0 .5rem; }
.small { font-size: .875rem; }
.text-error { color: var(--danger); align-self: center; }

/* Soort × functie (clusterformulier) */
.selection-table { width: auto; min-width: 320px; }
.selection-table th[scope="row"] { font-weight: 400; white-space: nowrap; }
.selection-table th[scope="row"] .checkbox { margin: 0; }
.selection-table .center { text-align: center; vertical-align: middle; }
.selection-table thead th { vertical-align: bottom; }
/* Functienamen een kwartslag gedraaid: smalle kolommen, geen horizontale scrollbalk. */
.selection-table thead th.rotated { vertical-align: bottom; text-align: center; white-space: nowrap; padding: .5rem .25rem; width: 2.25rem; }
.selection-table thead th.rotated span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); max-height: 14rem; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.selection-table td.center { padding: .35rem .25rem; }
.link-table td:first-child, .link-table th:first-child { width: 2.5rem; }
.link-table td input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); }
.link-table label { cursor: pointer; font-weight: 600; }
.selection-table td input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); cursor: pointer; }
.selection-table td input:disabled { cursor: not-allowed; opacity: .4; }

/* ---------- Planbord (W5) ---------- */
.page.page-wide { max-width: none; }
.inline-label { font-weight: 600; margin-right: .5rem; }
.select-inline { min-height: 36px; padding: .25rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
:root {
  --tl-name: 190px;
  --tl-part: 84px;
  --tl-fixed: calc(var(--tl-name) + var(--tl-part));
  --tl-off-bg: rgb(28 36 32 / 5%);
  --tl-absence-bg: rgb(234 170 60 / 22%);
  --tl-bar-bg: #dceee3;
  --tl-bar-border: #8fbfa3;
  --tl-bar-planned-bg: #e9ecea;
  --tl-bar-planned-border: #b8c2bc;
  --tl-bar-done-bg: #c9e7d4;
  --tl-today: rgb(31 111 235 / 45%);
  --tl-grid: rgb(28 36 32 / 9%);
  --tl-grid-week: rgb(28 36 32 / 22%);
  --tl-hover-bg: rgb(47 107 79 / 12%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --tl-off-bg: rgb(255 255 255 / 4%);
    --tl-absence-bg: rgb(234 170 60 / 16%);
    --tl-bar-bg: #1f3a2c;
    --tl-bar-border: #3f7a5b;
    --tl-bar-planned-bg: #2a302d;
    --tl-bar-planned-border: #4a544e;
    --tl-bar-done-bg: #24503a;
    --tl-today: rgb(110 168 254 / 55%);
    --tl-grid: rgb(255 255 255 / 8%);
    --tl-grid-week: rgb(255 255 255 / 20%);
    --tl-hover-bg: rgb(95 174 134 / 16%);
  }
}
.planning-layout { display: flex; gap: .75rem; align-items: flex-start; }
.planning-layout > .tl-scroll { flex: 1 1 auto; min-width: 0; }
.tl-scroll { overflow: auto; max-height: calc(100vh - 260px); min-height: 240px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* Planbord vult het scherm (besluit Ron 25-11-2026): op een gewoon scherm
   scrollt de pagina niet; kop, filters, tabbladen, meldingen en legenda
   nemen hun eigen hoogte en het bord krijgt de rest. Zo is er maximaal één
   horizontale en één verticale scrollbalk (in het bord), altijd in beeld.
   Alleen CSS: de pagina is de .page met een .planning-layout erin. Op een
   smal of laag scherm scrollt de pagina gewoon (zie onder). */
@media (min-width: 761px) and (min-height: 560px) {
  .layout:has(> .content > .page > .planning-layout) {
    height: calc(100vh - var(--topbar-height));
    height: calc(100dvh - var(--topbar-height));
    min-height: 0;
  }
  .layout:has(> .content > .page > .planning-layout) > .sidebar { overflow-y: auto; }
  .content:has(> .page > .planning-layout) {
    display: flex; flex-direction: column; min-height: 0;
    padding-bottom: 1rem; box-sizing: border-box;
    /* Vangnet als er echt te weinig hoogte is (lange melding). */
    overflow: auto;
  }
  .page:has(> .planning-layout) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .page:has(> .planning-layout) > * { flex: none; }
  .page:has(> .planning-layout) > .page-header { margin-bottom: .5rem; }
  .page:has(> .planning-layout) > .planning-layout { flex: 1 1 auto; min-height: 220px; align-items: stretch; }
  .page:has(> .planning-layout) .tl-scroll { max-height: none; min-height: 0; }
  .page:has(> .planning-layout) .tl-palette { position: static; max-height: none; min-height: 0; }
}
.tl { position: relative; font-size: .8rem; }
.tl-head { position: sticky; top: 0; z-index: 5; display: flex; background: var(--surface); border-bottom: 1px solid var(--border); }
.tl-corner { position: sticky; left: 0; z-index: 6; flex: none; width: var(--tl-fixed); display: flex; flex-direction: column; justify-content: space-between; padding: .3rem .5rem; background: var(--surface); border-right: 1px solid var(--border); font-weight: 600; box-sizing: border-box; }
.tl-corner-labels { display: flex; justify-content: space-between; align-items: flex-end; }
.tl-hover-info { min-height: 2.2em; font-size: .72rem; font-weight: 600; color: var(--primary); line-height: 1.1; }
.tl-head-track { position: relative; flex: none; height: 60px; }
.tl-h-month, .tl-h-week, .tl-h-day { position: absolute; box-sizing: border-box; border-left: 1px solid var(--border); overflow: clip; white-space: nowrap; }
.tl-h-month { top: 0; height: 20px; padding: 2px 6px; font-weight: 600; }
.tl-h-month span { position: sticky; left: calc(var(--tl-fixed) + 6px); }
.tl-h-week { top: 20px; height: 20px; padding: 2px 4px; color: var(--muted); border-top: 1px solid var(--border); }
.tl-h-day { top: 40px; height: 20px; width: 24px; text-align: center; padding-top: 2px; color: var(--muted); border-top: 1px solid var(--border); }
.tl-h-day.is-off { background: var(--tl-off-bg); }
.tl-body { position: relative; }
.tl-bg { position: absolute; top: 0; bottom: 0; left: var(--tl-fixed); pointer-events: none; z-index: 0; }
.tl-bg { background-image: repeating-linear-gradient(to right, transparent 0 23px, var(--tl-grid) 23px 24px); }
.tl-off { position: absolute; top: 0; bottom: 0; width: 24px; background: var(--tl-off-bg); }
.tl-week-line { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--tl-grid-week); }
.tl-hover { position: absolute; top: 0; bottom: 0; width: 24px; background: var(--tl-hover-bg); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--tl-today); }
.tl-row { position: relative; display: flex; border-bottom: 1px solid var(--border); }
.tl-name { position: sticky; left: 0; z-index: 3; flex: none; width: var(--tl-name); box-sizing: border-box; padding: .3rem .5rem; background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.tl-name-main { font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.tl-name-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name-main.is-cluster { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-parts { position: sticky; left: var(--tl-name); z-index: 3; flex: none; width: var(--tl-part); background: var(--surface); border-right: 1px solid var(--border); }
.tl-part { box-sizing: border-box; padding: 0 .4rem; display: flex; align-items: center; color: var(--muted); border-bottom: 1px dotted var(--border); }
.tl-part:last-child { border-bottom: 0; }
.tl-track { position: relative; flex: none; z-index: 1; }
.tl-lane-row { position: absolute; left: 0; right: 0; border-bottom: 1px dotted var(--border); pointer-events: none; }
.tl-lane-row:last-of-type { border-bottom: 0; }
.tl-bar { position: absolute; height: 20px; margin-top: 2px; box-sizing: border-box; border: 1px solid var(--tl-bar-border); border-radius: 4px; background: var(--tl-bar-bg); color: var(--text); overflow: clip; white-space: nowrap; padding: 1px 6px; line-height: 16px; }
.tl-bar span { position: sticky; left: calc(var(--tl-fixed) + 4px); }
.tl-bar.is-planned { background: var(--tl-bar-planned-bg); border-color: var(--tl-bar-planned-border); color: var(--muted); }
.tl-bar.is-done { background: var(--tl-bar-done-bg); border-style: dashed; color: var(--muted); }
.tl-visit { position: absolute; z-index: 2; width: 22px; height: 18px; margin: 3px 1px 0; padding: 0; border: 1px solid var(--primary); border-radius: 4px; font: inherit; font-size: .65rem; font-weight: 700; line-height: 16px; text-align: center; overflow: hidden; cursor: pointer; background: var(--surface); color: var(--primary); }
.tl-visit.status-gepland { background: var(--primary); color: var(--primary-text); }
.tl-visit.status-uitgevoerd { background: var(--muted); border-color: var(--muted); color: var(--surface); }
.tl-visit.status-afgewezen, .tl-visit.status-geannuleerd { border-style: dashed; border-color: var(--danger); color: var(--danger); background: var(--surface); }
.tl-visit.is-deviation { background: var(--warning-bg); border: 2px solid var(--warning-text); color: var(--warning-text); line-height: 14px; }
.tl-visit-code { font-size: .6rem; }
.tl-absence { position: absolute; top: 0; z-index: 0; background: var(--tl-absence-bg); pointer-events: auto; }
.tl-absence.kind-overig { background: repeating-linear-gradient(135deg, var(--tl-absence-bg) 0 6px, transparent 6px 10px); }
.avatar { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--surface-2); color: var(--text); font-size: .7rem; font-weight: 700; }
/* Medewerkerslijst: compact, twee kolommen met initialen (besluit Ron
   25-11-2026); eigen verticale scrollbalk als de lijst niet past. */
.tl-palette { flex: none; width: 112px; position: sticky; top: calc(var(--topbar-height) + 1rem); max-height: calc(100vh - 260px); overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .4rem; box-sizing: border-box; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; align-content: start; }
.tl-palette-title { grid-column: 1 / -1; font-size: .8rem; margin: 0 0 .15rem; }
.tl-palette > p { grid-column: 1 / -1; }
.tl-chip { display: flex; align-items: center; justify-content: center; gap: .2rem; padding: .1rem .25rem; min-height: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: grab; font-weight: 700; font-size: .75rem; line-height: 1.2; user-select: none; overflow: hidden; white-space: nowrap; }
.tl-chip .tl-chip-icon { display: none; }
.tl-chip:active { cursor: grabbing; }
.tl-chip-icon { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--primary); stroke-width: 2; }
.tl-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; padding: 0; margin: 0 0 .5rem; font-size: .8rem; color: var(--muted); }
.tl-legend li { display: flex; align-items: center; gap: .35rem; }
.tl-sw { position: static; display: inline-block; width: 18px; height: 12px; margin: 0; }
.tl-sw.tl-visit { width: 14px; height: 12px; cursor: default; }
.tl-off-sw { background: var(--tl-off-bg); border: 1px solid var(--border); }
.tl-sw.tl-absence { position: static; }
@media (max-width: 720px) {
  :root { --tl-name: 120px; --tl-part: 64px; }
  .planning-layout { flex-direction: column-reverse; }
  .tl-palette { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: .35rem; max-height: none; }
  .tl-palette-title { width: 100%; }
}

/* Methodiekoverzicht: naam breed, soorten smaller (één regel, rest in de tooltip). */
.methodology-table { table-layout: fixed; }
.methodology-table th:nth-child(1) { width: 34%; }
.methodology-table th:nth-child(2) { width: 16%; }
.methodology-table th:nth-child(3) { width: 7%; }
.methodology-table th:nth-child(4) { width: 11%; }
.methodology-table th:nth-child(5) { width: 21%; }
.methodology-table th:nth-child(6) { width: 11%; }
.methodology-table .species-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .methodology-table { table-layout: auto; }
  .methodology-table .species-cell { white-space: normal; }
}
/* Tellingen: één plusje per dag waarop een onderzoek met tellingen loopt. */
.tl-count { position: absolute; z-index: 1; width: 24px; height: 24px; line-height: 24px; text-align: center; font-weight: 700; color: var(--primary); pointer-events: auto; cursor: default; }
/* Medewerkerweergave, rij Inzet: per week één cel over alle dagen. De cel
   is dekkend, zodat de daglijnen en weekendvlakken hier wegvallen; alleen
   de weekgrens blijft als lijn. Tekst gecentreerd. */
.tl-week-load { position: absolute; z-index: 1; box-sizing: border-box; height: 24px; display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--muted); background: var(--surface); border-left: 1px solid var(--tl-grid-week); white-space: nowrap; overflow: hidden; cursor: default; }
/* Lijn van vandaag ook over de Inzet-cellen. */
.tl-today-cell { bottom: auto; z-index: 2; pointer-events: none; }
.tl-week-load.is-full { color: var(--text); font-weight: 700; }
.tl-week-load.is-over { color: var(--danger); font-weight: 700; }
/* Medewerker, Details: afkorting (smal) links naast het telefoonnummer. */
.form-grid.form-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.tl-visit.is-movable { cursor: grab; }
.tl-visit.is-movable:active { cursor: grabbing; }
/* Planbord: filters van de clusterweergave. */
.filters-5 { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
@media (max-width: 720px) { .filters-5 { grid-template-columns: 1fr; } }
.filters-4b { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
@media (max-width: 720px) { .filters-4b { grid-template-columns: 1fr; } }

/* Bezoekvoorwaarde: sectie "Andere onderzoeken" (10-11). */
.form-section { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .75rem; }
.form-section h4 { margin: 0 0 .25rem; font-size: 1rem; }
.form-section > .field-hint { margin-bottom: .75rem; }

/* Tellingen (10-11): plusje is een knop; telling als bezoekje in de rij
   Tellingen (baan 0 = plusjes). */
button.tl-count { padding: 0; border: 0; background: transparent; font: inherit; font-weight: 700; color: var(--primary); }
.tl-count.is-clickable { cursor: pointer; border-radius: 4px; }
.tl-count.is-clickable:hover, .tl-count.is-clickable:focus-visible { background: var(--primary); color: var(--primary-text); }
.tl-visit.is-count { border-radius: 50%; }

/* W6 Berichten: menu-teller, inbox (twee kolommen), gesprek, ontvangers. */
.nav-badge { display: inline-block; min-width: 1.4em; margin-left: .4rem; padding: 0 .4em; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.4em; text-align: center; vertical-align: middle; }
.inbox { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1rem; align-items: start; }
.inbox-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .75rem; max-height: calc(100vh - 220px); overflow-y: auto; }
.inbox-filters { display: grid; gap: .5rem; margin-bottom: .75rem; }
.inbox-filters input[type=search] { width: 100%; }
.inbox-conversations { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.inbox-conversation { display: grid; gap: .1rem; width: 100%; text-align: left; padding: .5rem .6rem; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.inbox-conversation:hover { background: var(--surface-2); }
.inbox-conversation.is-selected { border-color: var(--primary); background: var(--surface-2); }
.inbox-conversation.is-unread .inbox-conv-name { font-weight: 700; }
.inbox-conv-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.inbox-conv-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-thread { min-width: 0; }
.thread { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .75rem 1rem; display: grid; gap: .75rem; }
.thread-title { margin: 0; font-size: 1.15rem; }
.thread-messages { display: flex; flex-direction: column; gap: .5rem; max-height: calc(100vh - 380px); overflow-y: auto; padding-right: .25rem; }
.thread-older { align-self: center; }
.msg { max-width: 80%; padding: .5rem .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.msg.from-planning { align-self: flex-end; background: var(--surface); border-color: var(--primary); }
.msg.from-employee { align-self: flex-start; }
.msg.is-system { border-style: dashed; color: var(--muted); }
.msg-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin-bottom: .2rem; }
.msg-body { margin: 0; }
.msg-visit { margin: .35rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.thread-compose textarea { width: 100%; }
.recipient-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .25rem 0 .5rem; }
.recipient-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: .25rem .5rem; columns: 2 200px; }
.recipient-list .checkbox { break-inside: avoid; }
.team-add-title { font-size: 1rem; margin: 1rem 0 .25rem; }
.team-list { columns: 3 200px; max-height: 300px; }
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox-list, .thread-messages { max-height: none; }
  .msg { max-width: 100%; }
}
/* Mijn berichten (medewerker): eigen berichten rechts. */
.msg.mine { align-self: flex-end; background: var(--surface); border-color: var(--primary); }
.msg.theirs { align-self: flex-start; }
.thread-compose .h4 { font-size: 1rem; margin: .25rem 0 .5rem; }
.filters-2 { grid-template-columns: minmax(0, 260px) auto; justify-content: start; }
@media (max-width: 720px) { .filters-2 { grid-template-columns: 1fr; } }
/* Menu: persoonlijke items ("Mijn …") boven, gescheiden door een lijn. */
.sidebar .nav-divider { height: 0; margin: .5rem .75rem; border-top: 2px solid var(--border); border-radius: 1px; }

/* Resultaat van een bezoek */
.visit-result { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .5rem; }
.result-section h3 { font-size: 1rem; margin: .75rem 0 .5rem; }
.result-facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 .75rem; }
.result-facts dt { color: var(--muted); }
.result-facts dd { margin: 0; }
.result-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.reasons { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
.outcome { border-top: 1px solid var(--border); padding: .5rem 0; }
.outcome p { margin: 0 0 .25rem; }
.progress-visits { list-style: none; padding: 0; margin: 0; }
.progress-visits button { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; text-align: left; }

/* W7: voortgang per project en printpagina voor de klant */
.progress-summary tfoot th, .progress-summary tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.report-cluster { margin-top: 1.5rem; }
.report-cluster h2 { break-after: avoid; }
.report-table, .progress-summary { table-layout: auto; }
.report-table thead th, .progress-summary thead th { white-space: normal; }
.report-table .badge { white-space: nowrap; }
.report-table tr { break-inside: avoid; }
.report-sub { font-size: 1rem; margin: 1rem 0 .4rem; break-after: avoid; }
.report-note { margin-top: 1.5rem; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  :root { color-scheme: light; }
  body { background: #fff !important; color: #000 !important; font-size: 9.5pt; }
  .topbar, .sidebar, .skip-link, .no-print, .dialog-backdrop { display: none !important; }
  .layout { display: block; min-height: 0; }
  .content { padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  .table th, .table td { color: #000 !important; background: #fff !important; padding: .2rem .35rem; }
  thead { display: table-header-group; }
  .badge { background: none !important; color: #000 !important; border: 1px solid #888; }
  .details dt, .details dd, .muted { color: #000 !important; }
}

/* Locatie cluster (B7) */
.cluster-location { margin-top: 1rem; }
.lookup-row { display: flex; gap: .75rem; align-items: flex-start; }
.lookup-row .field { flex: 1; }
.lookup-row .btn { margin-top: 1.9rem; }
.lookup-results, .nearest { list-style: none; padding: 0; margin: 0 0 1rem; }
.lookup-results li, .nearest li { padding: .2rem 0; }

/* ---------- Voorstelplanning (W8): vergelijken met de planning ---------- */

.pv-scroll { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; }
.pv-grid { display: grid; width: max-content; font-size: .75rem; }
.pv-corner, .pv-name { position: sticky; left: 0; z-index: 2; background: var(--surface); padding: .25rem .5rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-corner { top: 0; z-index: 3; font-weight: 600; display: flex; align-items: flex-end; }
.pv-day { position: sticky; top: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; background: var(--surface); border-bottom: 1px solid var(--border); color: var(--muted); padding: .1rem 0; line-height: 1.2; }
.pv-week { height: 1.1em; font-size: .6rem; white-space: nowrap; overflow: visible; }
.pv-cell { min-height: 1.9rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 2px 0; }
.pv-weekend { background: var(--bg, #f6f7f6); }
.pv-monday { border-left: 1px solid var(--border); }
.pv-mark { display: block; width: 1.2rem; height: 1rem; border-radius: 3px; font-size: .6rem; font-weight: 700; line-height: 1rem; text-align: center; cursor: default; }
.pv-existing { background: var(--muted); color: var(--surface); }
.pv-existing.pv-own { outline: 2px solid var(--primary); outline-offset: -2px; }
.pv-proposed { background: var(--primary); color: var(--primary-text); }
.pv-proposed.pv-off { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 3px, var(--border) 3px, var(--border) 6px); color: var(--muted); }
.pv-table td, .pv-table th { padding-top: .3rem; padding-bottom: .3rem; }
.pv-table td:first-child, .pv-table th:first-child { width: 3rem; }

/* ---------- W9: impact, herplannen en bedreigde verplichtingen ---------- */

.impact { border-top: 1px solid var(--border); margin-top: .75rem; padding-top: .5rem; }
.impact h3 { font-size: 1rem; margin: .25rem 0 .5rem; }
.impact h4 { font-size: .95rem; margin: .75rem 0 .35rem; }
.impact-obligations li { margin-bottom: .25rem; }
.impact-alternative { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px dotted var(--border); }
.impact-alternative:last-child { border-bottom: 0; }
.tl-name-main.is-threatened { color: var(--warning-text); }
.tl-threat { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-right: .3rem; border-radius: 50%; background: var(--warning-text); color: var(--surface); font-size: .7rem; font-weight: 700; vertical-align: 1px; }
.tab .nav-badge { margin-left: .25rem; }
/* W9: bedreigde verplichtingen bij Planning in het menu. */
.nav-badge.nav-badge-warn { background: var(--warning-text); color: var(--surface); }

/* B11: foto's bij het resultaat van een bezoek */
.photo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.photo-card { display: flex; flex-direction: column; gap: .35rem; }
.photo-thumb-link { display: block; }
.photo-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2, #f3f4f6); }
.photo-thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }

/* B12 Auditlog. */
.audit-table td { vertical-align: top; }
.audit-table .nowrap { white-space: nowrap; }
.audit-details summary { cursor: pointer; color: var(--muted); }
.audit-details pre { max-width: 40rem; max-height: 20rem; overflow: auto; margin: .25rem 0 0; }
