/* ==========================================================================
   VraagBas design system
   - 8pt spacing-ritme, semantische kleuren, één tabel- en knoppensysteem.
   - Kleurregel: rood is een signaal, geen standaard voor uitgaven.
   ========================================================================== */

:root {
    /* merk */
    --brand-900: #0e231b;
    --brand-800: #123528;
    --brand-600: #1d6a4e;
    --brand-500: #238b63;
    --brand-100: #e4f1ea;
    --brand-50: #f1f7f4;

    /* semantiek */
    --ink: #1f2933;
    --ink-soft: #3e4c59;
    --muted: #7b8794;
    --hairline: #e4e7eb;
    --bg: #f4f6f5;
    --surface: #ffffff;

    --positive: #1d6a4e;
    --negative: #b42318;
    --negative-bg: #fdf0ee;
    --warning: #b25e09;
    --warning-bg: #fdf4e7;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 1px rgba(16, 38, 30, 0.04), 0 2px 6px rgba(16, 38, 30, 0.07);
    --shadow-lift: 0 2px 4px rgba(16, 38, 30, 0.07), 0 6px 16px rgba(16, 38, 30, 0.09);
    --focus-ring: 0 0 0 3px rgba(35, 139, 99, 0.25);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 var(--space-4); }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; margin: var(--space-5) 0 var(--space-3); }
a { color: var(--brand-600); }

/* == Shell ================================================================ */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand-900), var(--brand-800));
    color: #e6ece9;
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.brand {
    font-size: 1.35rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
    padding: 0 var(--space-2);
}
.brand span { color: #7fc8a9; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #b7c6bf;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 120ms ease, color 120ms ease;
}
.sidebar nav a svg { flex-shrink: 0; opacity: 0.75; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active { background: linear-gradient(180deg, var(--brand-500), var(--brand-600)); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 3px rgba(0,0,0,0.25); }
.sidebar nav a.active svg { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    padding: var(--space-3) var(--space-2) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
}
.sidebar-footer a, .user-email { color: #8fa39a; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer a:hover { color: #fff; }
.link-button {
    background: none; border: none; padding: 0;
    color: #8fa39a; cursor: pointer; font-size: 0.8rem; text-align: left;
}
.link-button:hover { color: #fff; text-decoration: underline; }

.content {
    flex: 1;
    min-width: 0;
    padding: var(--space-5) var(--space-6);
    max-width: 1160px;
}

/* == Cards ================================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.card-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    justify-content: flex-end;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--hairline);
}
.card-actions .muted { margin-right: auto; }

.empty-state { text-align: center; padding: var(--space-6) var(--space-4); }
.empty-state p { color: var(--muted); max-width: 32rem; margin: var(--space-2) auto var(--space-4); }

/* == Stats & hero ========================================================= */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.stat-row .card { margin-bottom: 0; display: flex; flex-direction: column; gap: 6px; }

.stat-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.verdict {
    border-left: none;
    position: relative;
    overflow: hidden;
    padding-left: calc(var(--space-4) + 6px);
}
.verdict::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
}
.verdict-ruim::before { background: var(--positive); }
.verdict-krap::before { background: var(--warning); }
.verdict-letop::before { background: var(--negative); }
.verdict-ruim { background: linear-gradient(135deg, #f0f9f4, #fff 55%); }
.verdict-krap { background: linear-gradient(135deg, #fdf6ec, #fff 55%); }
.verdict-letop { background: linear-gradient(135deg, #fdf0ef, #fff 55%); }
.verdict-badge { font-size: 1.15rem; font-weight: 750; letter-spacing: -0.01em; }
.verdict-text { margin: var(--space-2) 0 0; max-width: 52rem; color: var(--ink-soft); }

.breakdown { margin-top: var(--space-2); font-size: 0.88rem; width: 100%; }
.breakdown td { padding: 3px 0; border: none; color: var(--ink-soft); }
.breakdown td.num { color: var(--ink); }
.breakdown .total td { border-top: 1px solid var(--hairline); font-weight: 650; padding-top: 6px; color: var(--ink); }
.margin-card { min-width: 0; }

.progress {
    height: 6px;
    background: var(--hairline);
    border-radius: 999px;
    overflow: hidden;
    margin: var(--space-1) 0;
}
.progress-fill { height: 100%; border-radius: 999px; background-image: linear-gradient(180deg, rgba(255,255,255,0.3), rgba(255,255,255,0) 55%); background-blend-mode: soft-light; }
.bar-ruim { background: var(--positive); }
.bar-krap { background: var(--warning); }
.bar-letop { background: var(--negative); }

/* == Advieslijst ========================================================== */

.advice-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.advice {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: 14px var(--space-3);
    margin-bottom: 0;
    color: var(--ink-soft);
    transition: box-shadow 140ms ease, transform 140ms ease;
}
.advice:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.advice-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--brand-50);
    color: var(--brand-600);
}
.advice-warn .advice-icon { background: var(--warning-bg); color: var(--warning); }
.advice-ok .advice-icon { background: var(--brand-100); color: var(--positive); }

.check-row { display: flex; gap: var(--space-2); align-items: center; margin: var(--space-2) 0 0; flex-wrap: wrap; }

.flow-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); }
.toggle-group { display: inline-flex; background: var(--bg); border: 1px solid var(--hairline); border-radius: 999px; padding: 2px; }
.toggle {
    border: none; background: transparent; cursor: pointer;
    padding: 5px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--muted);
}
.toggle.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 38, 30, 0.15); }

.outlook-line { margin: var(--space-2) 0; }
.outlook-numbers { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: baseline; color: var(--ink-soft); }
.outlook-spendable strong { font-size: 1.1rem; }

.explain { margin-top: var(--space-2); border-top: 1px dashed var(--hairline); padding-top: var(--space-2); }
.explain-toggle { align-self: flex-start; padding-left: 0; }
.check-row input { max-width: 12rem; }
.scenario-result { font-size: 1rem; font-weight: 650; margin: var(--space-3) 0 0; }

/* == Tabellen ============================================================= */

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
th {
    color: var(--muted);
    font-weight: 650;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--brand-50); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--negative); }
.pos { color: var(--positive); }
.nowrap { white-space: nowrap; }

.cell-main { font-weight: 550; color: var(--ink); display: block; }
.cell-sub {
    color: var(--muted);
    font-size: 0.8rem;
    max-width: 26rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.desc { max-width: 20rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }

.needs-input { background: var(--warning-bg); }
.needs-input:hover { background: var(--warning-bg); }

/* == Badges & chips ======================================================= */

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge.ok { background: var(--brand-100); color: var(--brand-600); }
.badge.error { background: var(--negative-bg); color: var(--negative); }
.badge.subtle { background: var(--bg); color: var(--ink-soft); }

/* == Knoppen ============================================================== */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
    color: #fff;
    border: 1px solid var(--brand-800);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(16, 38, 30, 0.25);
    transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.button:hover { filter: brightness(1.07); }
.button:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(16, 38, 30, 0.3); }
.button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.button:disabled { opacity: 0.55; cursor: default; }

.button.secondary {
    background: linear-gradient(180deg, #ffffff, #f3f5f4);
    color: var(--ink);
    border-color: #cbd2d9;
    box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(16, 38, 30, 0.08);
}
.button.secondary:hover { border-color: #9aa5b1; }
.button.secondary:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(16, 38, 30, 0.12); }

.button.ghost {
    background: transparent;
    color: var(--brand-600);
    border-color: transparent;
    padding: 6px 10px;
}
.button.ghost:hover { background: var(--brand-50); }

/* == Formulieren ========================================================== */

input[type="search"], input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], input:not([type]), select {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
    box-shadow: inset 0 1px 2px rgba(16, 38, 30, 0.06);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus-visible, select:focus-visible { outline: none; border-color: var(--brand-500); box-shadow: var(--focus-ring), inset 0 1px 2px rgba(16, 38, 30, 0.04); }

select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8794' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}

td select { max-width: 11rem; height: 30px; font-size: 0.82rem; }
td input[type="number"], td input[type="date"] { height: 30px; font-size: 0.82rem; }

label { font-weight: 550; font-size: 0.9rem; display: block; margin-bottom: var(--space-3); }
label input, label select { margin-top: 6px; display: block; }

.filter-row {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}
.filter-row input[type="search"] { flex: 1; min-width: 14rem; }
.filter-row .muted { margin-left: auto; font-variant-numeric: tabular-nums; }

.mini { max-width: 6rem; }
.mini.wide { max-width: 8.5rem; }
.tiny { font-size: 0.75rem; display: block; color: var(--muted); }
.tiny-date { font-size: 0.78rem; margin-top: 4px; display: block; }

/* == Upload-zone ========================================================== */

.upload-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    border: 2px dashed #c4d6cc;
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-4);
    background: var(--brand-50);
    cursor: pointer;
    text-align: center;
    transition: border-color 120ms ease, background 120ms ease;
    margin-bottom: 0;
}
.upload-zone:hover { border-color: var(--brand-500); background: var(--brand-100); box-shadow: var(--shadow-lift); }
.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.upload-title { font-weight: 650; color: var(--ink); }
.upload-sub { color: var(--muted); font-size: 0.85rem; font-weight: 400; margin: 0; }
.upload-zone svg { color: var(--brand-600); }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--brand-100);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    display: inline-block;
    vertical-align: -3px;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* == Diversen ============================================================= */

.muted { color: var(--muted); }
.page-meta { color: var(--muted); font-size: 0.85rem; }

.prompt { border-left: 4px solid var(--brand-600); }
.prompt-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

.chart { width: 100%; height: 220px; }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.invite-code {
    display: inline-block;
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    letter-spacing: 0.1em;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* == Auth ================================================================= */

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background:
        radial-gradient(60rem 30rem at 50% -10%, var(--brand-100), transparent),
        var(--bg);
}
.auth-brand { font-size: 1.8rem; font-weight: 750; letter-spacing: -0.02em; color: var(--brand-800); }
.auth-card { width: 100%; max-width: 25rem; padding: var(--space-5); }
.over-card { max-width: 44rem; }
.auth-card h1 { margin-bottom: var(--space-4); }
.auth-card label { margin-bottom: var(--space-3); }
.auth-card input { width: 100%; }
.auth-card .button { width: 100%; margin-top: var(--space-2); }
.auth-card p { margin: var(--space-3) 0 0; font-size: 0.9rem; }
.auth-error {
    color: var(--negative);
    background: var(--negative-bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.88rem;
    margin: 0 0 var(--space-3);
}
ul.auth-error { padding-left: 28px; }

#blazor-error-ui {
    color-scheme: light only;
    background: var(--warning-bg);
    border-top: 1px solid var(--warning);
    bottom: 0; left: 0;
    display: none;
    padding: 10px var(--space-4);
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 8px; }

/* == Responsief =========================================================== */

@media (max-width: 920px) {
    .content { padding: var(--space-4) var(--space-3); }
}

@media (max-width: 760px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: var(--space-2) var(--space-3);
        gap: var(--space-3);
        overflow-x: auto;
    }
    .sidebar nav { flex-direction: row; }
    .sidebar nav a { padding: 7px 10px; white-space: nowrap; }
    .sidebar nav a svg { display: none; }
    .sidebar-footer { display: none; }
    .content { padding: var(--space-3); }
    .card { padding: var(--space-3); }
    .table-wrap { margin: 0 calc(-1 * var(--space-3)); padding: 0 var(--space-3); }
    .stat-value { font-size: 1.25rem; }
    .cell-sub, .desc { max-width: 11rem; }
}
