:root {
    --bg: #f5f6f4;
    --surface: #ffffff;
    --text: #1f2a2e;
    --muted: #5d6b70;
    --line: #dfe4e1;
    --accent: #2f6f6a;
    --accent-dark: #245853;
    --accent-soft: #e4f0ee;
    --danger: #a63a2e;
    --danger-soft: #fbeae7;
    --ok-soft: #e3f3e6;
    --ok: #256a36;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }

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

a { color: var(--accent-dark); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; text-wrap: balance; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Bovenbalk */
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
    padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--accent-dark); text-decoration: none; }
.mainnav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.mainnav a, .tabs a {
    padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--text);
}
.mainnav a:hover, .tabs a:hover { background: var(--bg); }
.mainnav a[aria-current], .tabs a[aria-current] { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: 16px; font-size: .9rem; }
.usermenu .who { text-align: right; line-height: 1.25; }
.usermenu .who small { display: block; color: var(--muted); }

/* Pagina */
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.narrow { max-width: 640px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px 24px; text-align: center; color: var(--muted); }

/* Aanmelden */
body.centered { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { color: var(--accent-dark); }
.login .muted { margin: 4px 0 20px; }

.belowform { margin: 16px 0 0; text-align: center; font-size: .9rem; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 16px; }
.qr { margin: 12px 0 4px; }
.qr img { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.codes code { display: block; text-align: center; padding: 8px; font-size: 1.05rem; }

/* Meldingen */
.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 6px; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #c5e3cb; }
.flash-warn { background: #fdf0d8; color: #6f4800; border-color: #f0d9a8; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f1cfc9; }

/* Knoppen */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #b9c2bd; background: #fafbfa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-small { padding: 4px 10px; font-size: .85rem; font-weight: 500; }
.btn-block { width: 100%; }
:focus-visible { outline: 3px solid #7fb5b0; outline-offset: 2px; }

/* Formulieren */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search] {
    width: 100%; padding: 8px 10px; border: 1px solid #b9c2bd; border-radius: 6px;
    font: inherit; color: var(--text); background: #fff;
}
.field-check > label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.field-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.help { margin: 4px 0 0; font-size: .875rem; color: var(--muted); }
.errors { margin: 4px 0 0; padding: 0; list-style: none; font-size: .875rem; color: var(--danger); font-weight: 500; }
.field-invalid input { border-color: var(--danger); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 0; margin: 8px 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
fieldset > .help { margin: 0 0 12px; }
.formactions { display: flex; gap: 8px; margin-top: 8px; }

/* Lijsten */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 320px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfa; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; }
td.actions form { margin: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: #eceeed; color: var(--muted); }

.badge-warn { background: #fdf0d8; color: #8a5a00; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; max-width: 320px; color: var(--muted); }
td.wrap:not(:empty) { min-width: 160px; }
td.actions form { display: inline-block; margin: 0 4px 0 0; }
.sortlink { color: inherit; text-decoration: none; }
.sortlink:hover { color: var(--accent-dark); }
th[aria-sort] .sortlink { color: var(--accent-dark); }
.listfoot, .summary { color: var(--muted); margin: 12px 2px; }
.summary strong { color: var(--text); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; color: var(--muted); }
.listgap { margin-top: 16px; }

/* Kruimelpad, koppen, acties */
.crumb { margin: 0 0 6px; font-size: .9rem; color: var(--muted); }
h1 small { font-size: .95rem; font-weight: 500; color: var(--muted); margin-left: 8px; }
h2 { font-size: 1.1rem; margin: 28px 0 12px; }
.card h2 { margin-top: 20px; }
.card h2.first { margin-top: 0; }
.headactions { display: flex; flex-wrap: wrap; gap: 8px; }
.headactions form { margin: 0; }
.pagehead.sub { margin: 28px 0 12px; }
.pagehead.sub h2, .pagehead.sub .summary { margin: 0; }

/* Dossier */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; margin: 0; }
.details dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.details dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.notes { margin: 0; white-space: normal; overflow-wrap: anywhere; }

/* Filters */
.filters {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; align-items: end;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 0; margin-bottom: 4px;
}
.filteractions { display: flex; gap: 8px; margin-bottom: 16px; }
select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #b9c2bd; border-radius: 6px;
    font: inherit; color: var(--text); background: #fff;
}
textarea { resize: vertical; }
.money { display: flex; align-items: center; gap: 8px; }
input[type=number] { width: 100%; padding: 8px 10px; border: 1px solid #b9c2bd; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
.grid3 { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(140px, 2fr) minmax(140px, 2fr); gap: 0 16px; }
.inlineform { display: flex; align-items: flex-end; gap: 12px; }
.inlineform .field { flex: 1; margin-bottom: 0; }
.tabs-left { margin-left: 0; }
.tablewrap.narrow { max-width: 640px; }
.btn-danger { color: var(--danger); border-color: #e6bdb6; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.dangerzone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border: 1px dashed #e6bdb6; border-radius: var(--radius); color: var(--muted); font-size: .9rem; }

@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }

/* Keuzeveld cliënt */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid #b9c2bd; border-radius: 6px; box-shadow: 0 6px 20px rgba(31, 42, 46, .14); max-height: 280px; overflow-y: auto; }
.picker-list li { padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.picker-list li[aria-selected=true], .picker-list li[role=option]:hover { background: var(--accent-soft); color: var(--accent-dark); }
.picker-list .picker-empty { color: var(--muted); cursor: default; }

/* Opvolging */
.followup { margin-bottom: 16px; }
.followup .pagehead { margin-bottom: 8px; }
.followup .amount { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.plainlist { margin: 0 0 16px; padding: 0; list-style: none; color: var(--muted); }
.plainlist li { padding: 2px 0; }

/* Agenda */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.day-today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day-weekend { background: #fafbfa; }
.day header { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 8px; }
.day h2 { font-size: .9rem; margin: 0; }
.day h2 small { color: var(--muted); font-weight: 500; }
.dayempty { font-size: .85rem; margin: 0; }
.slot { display: block; padding: 6px 8px; margin-bottom: 6px; border-radius: 6px; background: var(--accent-soft); border-left: 3px solid var(--accent); color: var(--text); text-decoration: none; font-size: .85rem; overflow-wrap: anywhere; }
.slot:hover { background: #d6e8e5; }
.slot strong, .slot span { display: block; }
.slot .badge { display: inline-block; margin-top: 2px; }
.slot-cancelled, .slot-no_show { background: #f1f2f1; border-left-color: #b9c2bd; }
.slot-cancelled > span:first-of-type, .slot-no_show > span:first-of-type { text-decoration: line-through; }
.slot-done { border-left-color: var(--ok); }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } .day { min-height: 0; } }

/* Statistieken en diversen */
.autowidth { width: auto; }
.barcol { width: 28%; min-width: 80px; }
.bar { display: block; height: 10px; border-radius: 5px; background: var(--accent); min-width: 0; }
.totalrow td { font-weight: 700; border-top: 2px solid var(--line); }
.statgrid { gap: 0 24px; align-items: start; }
.narrowfield { max-width: 200px; }
.note { margin-top: 12px; }
.note header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.note header .btn { margin-left: auto; }
.inlineitem { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.inlineitem input[type=text] { width: 130px; }
input[type=file], input[type=datetime-local] { width: 100%; padding: 7px 10px; border: 1px solid #b9c2bd; border-radius: 6px; font: inherit; background: #fff; }

/* Overzicht */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: inherit; }
a.tile:hover { border-color: var(--accent); }
.tile-value { display: block; font-size: 2rem; font-weight: 700; color: var(--accent-dark); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); }

@media (max-width: 640px) {
    .topbar { padding: 10px 16px; }
    .page { padding: 16px; }
    .usermenu { width: 100%; justify-content: space-between; }
    .usermenu .who { text-align: left; }
    .tabs { margin-left: 0; }
}
