/* ==========================================================================
   plnr - groene stijl (bosgroen / smaragd / blauwgroen / limoen)
   Witte tekst staat alleen op vlakken die donker genoeg zijn (contrast >= 4.5:1).
   Rood = uitgave blijft betekenis dragen; inkomen blijft groen.
   ========================================================================== */

:root {
    /* Merkkleuren */
    --brand-deep: #065f46;
    --brand-mid: #047857;
    --brand-teal: #0f766e;
    --brand-lime: #bef264;
    --brand-gradient: linear-gradient(100deg, #064e3b 0%, #065f46 35%, #047857 70%, #0f766e 100%);
    --fresh-gradient: linear-gradient(90deg, #a3e635, #bef264 50%, #4ade80);
    --button-gradient: linear-gradient(135deg, #065f46, #047857);
    /* Accentstrepen op kaarten, in volgorde */
    --accent-1: #059669;
    --accent-2: #0d9488;
    --accent-3: #65a30d;
    --accent-4: #16a34a;

    --bg: #f3f8f4;
    --surface: #ffffff;
    --surface-2: #e8f3ec;
    --text: #10241a;
    --muted: #4f6b5c;
    --border: #d4e7da;
    --primary: #047857;
    --primary-text: #ffffff;
    --income: #15803d;
    --expense: #b91c1c;
    --pending: #b45309;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(10, 60, 30, .06), 0 4px 14px rgba(10, 60, 30, .06);
    /* Grafiekreeksen (gevalideerd op kleurenblindheid en contrast) */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --grid: #e1eee5;
    --title-gradient: linear-gradient(90deg, #065f46, #0f766e);
    --logo-gradient: linear-gradient(90deg, #065f46, #047857 60%, #0f766e);
    color-scheme: light;
}

/* Donkere modus: volgt het systeem (Automatisch), tenzij in Instellingen expliciet Licht of Donker gekozen is.
   Dezelfde waarden staan twee keer: één keer voor het systeem, één keer voor de keuze "Donker". */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1612;
        --surface: #14211b;
        --surface-2: #1b2c24;
        --text: #e8f3ec;
        --muted: #a3bdb0;
        --border: #26392f;
        --primary: #34d399;
        --primary-text: #052e1f;
        --income: #4ade80;
        --expense: #f87171;
        --pending: #fbbf24;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --series-1: #3987e5;
        --series-2: #d95926;
        --grid: #22342b;
        --title-gradient: linear-gradient(90deg, #4ade80, #2dd4bf 60%, #a3e635);
        --logo-gradient: linear-gradient(90deg, #4ade80, #2dd4bf 60%, #a3e635);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0d1612;
    --surface: #14211b;
    --surface-2: #1b2c24;
    --text: #e8f3ec;
    --muted: #a3bdb0;
    --border: #26392f;
    --primary: #34d399;
    --primary-text: #052e1f;
    --income: #4ade80;
    --expense: #f87171;
    --pending: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #22342b;
    --title-gradient: linear-gradient(90deg, #4ade80, #2dd4bf 60%, #a3e635);
    --logo-gradient: linear-gradient(90deg, #4ade80, #2dd4bf 60%, #a3e635);
    color-scheme: dark;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--expense); min-height: 1.2em; margin: .5rem 0 0; }
.income { color: var(--income); }
.expense { color: var(--expense); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spacer { flex: 1; }

h1, h2, h3 { margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.35rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; }

button, input, select, textarea { font: inherit; color: inherit; }

/* Knoppen */
button {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    padding: .45rem .9rem;
    cursor: pointer;
    transition: background .15s, transform .15s, box-shadow .15s, filter .15s;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
    background: var(--button-gradient); border-color: transparent; color: #fff; font-weight: 600;
    box-shadow: 0 2px 8px rgba(4, 120, 87, .25);
}
button.primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(4, 120, 87, .3); }
button.danger { color: var(--expense); }
button.ghost { background: transparent; }
button.small { padding: .22rem .6rem; font-size: .85rem; border-radius: 8px; }

input, select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent-1);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-1) 25%, transparent);
}
input[type=color] { padding: .1rem; height: 2.3rem; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent-1); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
label > input, label > select, label > textarea { margin-top: .25rem; color: var(--text); }

/* Logo */
.logo { font-weight: 800; letter-spacing: -.03em; font-size: 1.45rem; }
.logo::after {
    content: ''; display: inline-block; width: .42rem; height: .42rem; border-radius: 50%;
    background: var(--brand-lime); margin-left: 2px;
}

/* Inloggen */
.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 16px;
    background: radial-gradient(circle at 20% 15%, rgba(190, 242, 100, .35), transparent 45%),
                linear-gradient(135deg, #064e3b, #065f46 40%, #047857 75%, #0f766e);
}
.auth-card {
    width: 100%; max-width: 390px; background: var(--surface); padding: 2rem;
    border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 40, 20, .35);
    border-top: 5px solid var(--accent-1);
}
.auth-card form button[type=submit] { width: 100%; margin-top: .5rem; }
.auth-card .logo {
    font-size: 2.4rem; margin-bottom: .25rem;
    background: var(--logo-gradient);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.segmented { display: flex; gap: 0; margin: 1rem 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button { flex: 1; border: 0; border-radius: 0; white-space: nowrap; padding-left: .5rem; padding-right: .5rem; }
.segmented button.active { background: var(--button-gradient); color: #fff; font-weight: 600; }
.segmented button + button { border-left: 1px solid var(--border); }

/* Bovenbalk */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    padding: .55rem 16px; background: var(--brand-gradient); color: #fff;
    position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 12px rgba(0, 40, 20, .25);
}
.topbar::after { /* limoengroene streep onder de balk */
    content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--fresh-gradient);
}
.topbar .logo { color: #fff; }
#tabs {
    display: flex; gap: .2rem; flex: 1; min-width: 0;
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
    border: 0; background: transparent; color: rgba(255, 255, 255, .9); white-space: nowrap;
    padding: .38rem .75rem; border-radius: 999px; font-size: .9rem;
}
#tabs button:hover { background: rgba(255, 255, 255, .15); }
#tabs button.active { background: #fff; color: var(--brand-deep); font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.topbar-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.topbar .viewing { display: flex; align-items: center; gap: .4rem; margin: 0; color: rgba(255, 255, 255, .9); }
.topbar .viewing select {
    width: auto; margin: 0; background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .35);
}
.topbar .viewing select option { color: #10241a; background: #fff; }
.topbar button.ghost { color: #fff; border-color: rgba(255, 255, 255, .45); }
.topbar button.ghost:hover { background: rgba(255, 255, 255, .15); }

.banner {
    background: var(--fresh-gradient); color: #1a2e05; padding: .5rem 16px; font-weight: 600; margin-top: 4px;
}

main { padding: 1.6rem 16px 3rem; max-width: 1200px; margin: 0 auto; }

body.readonly .own-only { display: none !important; }

/* Kaarten en rasters */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar h2 { margin: 0 .5rem 0 0; }
main > .toolbar h2, main > div > .toolbar > h2 {
    background: var(--title-gradient);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.card {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.05rem 1.15rem; box-shadow: var(--shadow); min-width: 0;
}
/* Gekleurde streep bovenaan elke kaart, afwisselend smaragd / blauwgroen / limoen / groen */
.grid > .card::before, .card.section::before {
    content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--accent-1);
}
.grid > .card:nth-child(4n+2)::before { background: var(--accent-2); }
.grid > .card:nth-child(4n+3)::before { background: var(--accent-3); }
.grid > .card:nth-child(4n+4)::before { background: var(--accent-4); }
.card.section::before { background: var(--fresh-gradient); }
.card .label { color: var(--muted); font-size: .85rem; }
.card .big { font-size: 1.65rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Uitgelichte kaart (verwachte balans): volledig groen verloop */
.card.highlight {
    background: linear-gradient(135deg, #064e3b, #047857 65%, #0f766e); color: #fff; border-color: transparent;
    box-shadow: 0 6px 20px rgba(4, 120, 87, .3);
}
.card.highlight::before { background: var(--fresh-gradient) !important; }
.card.highlight .label, .card.highlight .stat-rows { color: rgba(255, 255, 255, .92); }
.card.highlight .income, .card.highlight .expense { color: #fff; }

.stat-rows { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin-top: .5rem; font-size: .9rem; }
.stat-rows .num { font-weight: 600; }
.section { margin-top: 1.5rem; }

/* Tabellen */
.table-wrap {
    overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th {
    font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
    background: var(--surface-2);
}
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: .25rem; }

.badge {
    display: inline-block; font-size: .74rem; padding: .12rem .55rem; border-radius: 999px; font-weight: 600;
    background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.done { background: color-mix(in srgb, var(--income) 15%, transparent); color: var(--income); }
.badge.pending { background: color-mix(in srgb, var(--pending) 18%, transparent); color: var(--pending); }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }

/* Voortgang */
.bar { height: .6rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .45rem 0; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #a3e635, #22c55e, #0d9488); border-radius: 999px; }
.bar.income > span { background: var(--income); }
.bar.expense > span { background: var(--expense); }

.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1rem; margin-bottom: .6rem; font-size: .9rem; }
.cat-row .bar { grid-column: 1 / -1; margin: 0; }

.items { list-style: none; padding: 0; margin: .5rem 0; font-size: .9rem; }
.items li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .25rem 0; border-bottom: 1px dashed var(--border); }
.items li.total { font-weight: 700; border-bottom: 0; }

.list-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; flex: 1; min-width: 160px; }

/* Dialoog */
dialog {
    border: 1px solid var(--border); border-radius: 18px; padding: 1.5rem; width: min(520px, calc(100vw - 32px));
    background: var(--surface); color: var(--text);
    box-shadow: inset 0 5px 0 0 var(--accent-1), 0 20px 60px rgba(0, 40, 20, .3);
}
dialog::backdrop { background: rgba(0, 30, 15, .45); backdrop-filter: blur(2px); }
dialog h2 { padding-top: .25rem; }
.dialog-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.preview {
    background: color-mix(in srgb, var(--accent-3) 12%, var(--surface)); border-left: 4px solid var(--accent-3);
    border-radius: 10px; padding: .6rem .85rem; margin-bottom: .85rem; font-size: .9rem;
}
.preview:empty { display: none; }
.item-editor .item-line { display: grid; grid-template-columns: 1fr 120px auto; gap: .4rem; margin-bottom: .4rem; }

/* Kalender */
#calendar {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem;
    box-shadow: var(--shadow);
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--surface);
    --fc-neutral-bg-color: var(--surface-2);
    --fc-today-bg-color: color-mix(in srgb, var(--accent-3) 14%, transparent);
    --fc-now-indicator-color: var(--accent-2);
    --fc-button-bg-color: var(--surface-2);
    --fc-button-border-color: var(--border);
    --fc-button-text-color: var(--text);
    --fc-button-hover-bg-color: var(--border);
    --fc-button-hover-border-color: var(--border);
    --fc-button-active-bg-color: var(--brand-mid);
    --fc-button-active-border-color: var(--brand-mid);
}
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 1.2rem; }
.fc .fc-event { border-radius: 6px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }

dialog.wide { width: min(860px, calc(100vw - 32px)); }

.button-link {
    display: inline-block; border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
    padding: .45rem .9rem; color: var(--text); text-decoration: none;
}
.button-link:hover { background: var(--surface-2); }

/* Saldoprognose */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-1 { stroke: var(--series-1); }
.chart .series-2 { stroke: var(--series-2); }
.chart .end-label { font-size: 11px; fill: var(--text); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart-tooltip {
    position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: .45rem .65rem; font-size: .8rem; box-shadow: 0 6px 20px rgba(0, 40, 20, .18);
    white-space: nowrap; transform: translate(-50%, -110%);
}
.legend-swatch { display: inline-block; width: .9rem; height: 2px; vertical-align: middle; margin-right: .35rem; }
.warning { color: var(--expense); font-weight: 600; }

/* Spaarplan */
.plan-kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.plan-kpis > div { background: var(--surface-2); border-radius: 12px; padding: .7rem .85rem; }
.plan-kpis .big { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.plan-kpis .label { color: var(--muted); font-size: .8rem; }
.plan-h { margin: 0 0 .5rem; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.plan-step { display: grid; grid-template-columns: minmax(150px, auto) 1fr auto; gap: .75rem; align-items: center; font-size: .9rem; margin-bottom: .35rem; }
.plan-step .bar { margin: 0; }

/* Budgetten */
.budget-row { margin-bottom: .75rem; font-size: .9rem; }
.budget-row .head { display: flex; justify-content: space-between; gap: 1rem; }
.budget-row .bar { position: relative; }
.budget-row .bar .expected { position: absolute; top: 0; bottom: 0; background: var(--border); border-radius: 999px; }
.budget-row .bar .actual { position: absolute; top: 0; bottom: 0; border-radius: 999px; }

/* Verdeling gedeelde kosten */
.split-row { display: grid; grid-template-columns: auto 1fr 120px; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.split-row input[type=number] { margin: 0; }
.check { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); margin: 0; font-size: .9rem; }

.import-table { max-height: 50vh; overflow: auto; }
.import-table table { font-size: .85rem; }

@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: .5rem; }
    #tabs { order: 3; flex-basis: 100%; }
}

@media (max-width: 640px) {
    .row2 { grid-template-columns: 1fr; }
    .card .big { font-size: 1.4rem; }
}

/* Inlogscherm: links, meldingen en kleine lettertjes */
button.linkish {
    background: none; border: none; padding: 0; color: var(--primary); text-decoration: underline;
    cursor: pointer; font-size: .9rem; box-shadow: none;
}
button.linkish:hover { background: none; filter: brightness(1.2); }
.center { text-align: center; }
.small-print { font-size: .82rem; margin: .6rem 0 0; }
.notice {
    background: var(--surface-2); border-left: 4px solid var(--accent-1); padding: .6rem .8rem; border-radius: 8px;
    font-size: .92rem;
}
.notice.error-notice { border-left-color: var(--expense); }

/* Melding bovenaan de app, bv. "bevestig je e-mailadres" */
.account-notice {
    background: var(--surface-2); border-bottom: 1px solid var(--border); padding: .5rem 16px; font-size: .92rem;
    display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
}

/* Tweestapsverificatie */
.qr-code { width: 200px; height: 200px; background: #fff; padding: 6px; border-radius: 10px; display: block; }
.secret-key { font-family: ui-monospace, monospace; word-break: break-all; user-select: all; }
.recovery-codes {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem .9rem; padding: .7rem .9rem;
    font-family: ui-monospace, monospace; background: var(--surface-2); border-radius: 10px; list-style: none; margin: .5rem 0;
}
.danger-zone { border-color: color-mix(in srgb, var(--expense) 45%, var(--border)); }
label.checkbox { display: flex; gap: .5rem; align-items: center; color: var(--text); }
label.checkbox > input { width: auto; margin: 0; }

/* Privacyverklaring */
.legal { max-width: 760px; margin: 0 auto; padding: 2rem 16px 4rem; line-height: 1.6; }
.legal h1 { margin-bottom: .25rem; }
.legal h2 { margin-top: 2rem; font-size: 1.15rem; }
.legal table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.legal th, .legal td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.legal .missing { color: var(--expense); font-weight: 600; }
.auth-card a, .legal a { color: var(--primary); }

/* Gewerkte uren groot bovenaan het overzicht */
.hours-hero { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 2rem; margin-bottom: 1rem; }
.hours-hero .hours-main { flex: 0 0 auto; }
.hours-hero .hero-number {
    font-size: 2.8rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
    color: var(--primary);
}
.hours-hero .hours-side { flex: 1 1 260px; font-size: .92rem; color: var(--muted); }
.hours-hero .hours-side strong { color: var(--text); }
.hours-hero .bar { margin: .45rem 0; }
.hours-jobs { display: flex; flex-wrap: wrap; gap: .2rem 1rem; font-size: .82rem; }
.hours-jobs .not-counted { opacity: .7; font-style: italic; }
@media (max-width: 600px) { .hours-hero .hero-number { font-size: 2.2rem; } }
