/* ============================================================
   Balans — Web Cockpit design system (desktop-first)
   ============================================================ */

:root {
    --brand: #0e7c66;
    --brand-strong: #0b5f4e;
    --brand-soft: #e6f2ee;

    --bg: #eef2f1;
    --surface: #ffffff;
    --surface-muted: #f3f6f5;
    --sidebar: #10231e;
    --sidebar-muted: #7d938c;

    --text: #17241f;
    --muted: #58685f;
    --border: #e0e7e4;

    --danger: #c0392b;
    --danger-soft: #fdecea;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 30px rgba(16, 40, 34, 0.10);
    --shadow-sm: 0 2px 10px rgba(16, 40, 34, 0.06);

    --sidebar-w: 250px;
    --inspector-w: 340px;

    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }

.app-splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.app-splash__brand { font-size: 2rem; font-weight: 800; color: var(--brand); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.1rem; font-size: 0.95rem; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s, opacity 0.15s; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); color: var(--brand); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-muted); }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; text-align: left; }
.field label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 600; }
.field input, .field select {
    width: 100%; padding: 0.7rem 0.85rem; font-size: 0.95rem; font-family: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--muted); }
.form-error { display: flex; gap: 0.5rem; padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem; color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); }
.validation-message { color: var(--danger); font-size: 0.8rem; }

/* ---------- Auth (centred) ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: linear-gradient(135deg, var(--brand-soft), var(--bg) 55%); }
.auth__card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.auth__brand { text-align: center; margin-bottom: 1.5rem; }
.auth__brand-name { font-size: 2rem; font-weight: 800; color: var(--brand); }
.auth__brand-tag { display: block; color: var(--muted); font-size: 0.9rem; }
.auth__title { text-align: center; font-size: 1.3rem; margin-bottom: 0.25rem; }
.auth__subtitle { text-align: center; color: var(--muted); margin-bottom: 1.25rem; }
.auth__footer { text-align: center; margin-top: 1.25rem; color: var(--muted); font-size: 0.9rem; }
.auth__env { text-align: center; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
.auth__env .btn-link { font-size: 0.8rem; margin-left: 0.4rem; }

/* ---------- Cockpit shell ---------- */
.cockpit { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar { background: var(--sidebar); color: #cfe0da; display: flex; flex-direction: column; padding: 1.25rem 0.9rem; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { font-size: 1.4rem; font-weight: 800; color: #fff; padding: 0.4rem 0.6rem 1.25rem; }
.sidebar__brand span { color: var(--brand); }
.sidebar__nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); color: var(--sidebar-muted); font-weight: 600; font-size: 0.92rem; }
.nav-link:hover { background: rgba(255,255,255,0.06); color: #eaf3f0; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-link .ico { font-size: 1.1rem; width: 1.4rem; text-align: center; }
.sidebar__footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 0.85rem; }
.sidebar__user { font-size: 0.8rem; color: var(--sidebar-muted); padding: 0 0.6rem 0.5rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar__logout { width: 100%; text-align: left; background: none; border: none; color: #cfe0da; font-weight: 600; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); cursor: pointer; }
.sidebar__logout:hover { background: rgba(255,255,255,0.06); }

.workspace { min-width: 0; padding: 1.75rem 2rem; max-width: 1400px; }

/* ---------- Page header + month nav ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-title { font-size: 1.6rem; }
.month-nav { display: flex; align-items: center; gap: 0.6rem; }
.month-nav__label { font-weight: 700; min-width: 9rem; text-align: center; }
.month-nav__btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 1.1rem; cursor: pointer; }
.month-nav__btn:hover { background: var(--surface-muted); }

/* ---------- Ready to Assign card ---------- */
.rta-card { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.25rem; border-radius: var(--radius); color: #fff; box-shadow: var(--shadow-sm); }
.rta-card--positive { background: var(--brand); }
.rta-card--zero { background: #5c6b66; }
.rta-card--negative { background: var(--danger); }
.rta-card__amount { font-size: 1.5rem; font-weight: 800; }
.rta-card__label { font-size: 0.82rem; }

/* ---------- Budget area (grid + inspector) ---------- */
.budget-area { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
.budget-area.with-inspector { grid-template-columns: 1fr var(--inspector-w); }

.grid-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.grid-head { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0.5rem; padding: 0.75rem 1.25rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-bottom: 1px solid var(--border); }
.grid-head span:not(:first-child), .grid-num { text-align: right; }
.group-title { padding: 0.85rem 1.25rem 0.4rem; font-weight: 700; font-size: 0.95rem; color: var(--text); }
.cat-line { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0.5rem; padding: 0.7rem 1.25rem; align-items: center; cursor: pointer; border-left: 3px solid transparent; }
/* Button reset so <button class="cat-line"> renders identically to the old div */
button.cat-line { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 0.5rem; padding: 0.7rem 1.25rem; align-items: center; width: 100%; cursor: pointer; border-left: 3px solid transparent; font: inherit; color: inherit; text-align: inherit; }
button.cat-line:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.cat-line:hover { background: var(--surface-muted); }
.cat-line.selected { background: var(--brand-soft); border-left-color: var(--brand); }
.cat-line__name { font-weight: 600; }
.grid-num { font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.grid-num.activity { color: var(--muted); }
.grid-num.available { font-weight: 700; }
.grid-num.available.pos { color: var(--brand); }
.grid-num.available.neg { color: var(--danger); }
.grid-num.available.zero { color: var(--muted); }
.grid-empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- Inspector panel ---------- */
.inspector { position: sticky; top: 1.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; }
.inspector__head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.inspector__title { font-size: 1.15rem; }
.inspector__group { font-size: 0.8rem; color: var(--muted); }
.inspector__close { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.stat-row { display: flex; justify-content: space-between; padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.stat-row .label { color: var(--muted); }
.stat-row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row .val.neg { color: var(--danger); }
.stat-row .val.pos { color: var(--brand); }
.inspector__section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 1.1rem 0 0.5rem; }
.target-chip { display: inline-block; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 0.78rem; font-weight: 600; }

/* ---------- Misc ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.text-muted { color: var(--muted); }
.placeholder-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 2rem; text-align: center; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; }

#blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.2); display: none; left: 0; padding: 0.6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Er is een fout opgetreden."; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar__group { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 40, 34, 0.5); display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 100; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 480px; padding: 1.75rem; max-height: 90vh; overflow: auto; }
.modal--wide { max-width: 620px; }
.modal__title { font-size: 1.25rem; margin-bottom: 1rem; }
.modal__actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ---------- Account cards ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.account-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.account-card__type { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.account-card__name { font-size: 1.1rem; font-weight: 700; }
.account-card__balance { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 0.15rem; }
.account-card__balance.neg { color: var(--danger); }
.account-card__actions { display: flex; gap: 1.1rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.account-card__actions button { background: none; border: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 0; font-size: 0.88rem; }
.account-card__actions button.danger { color: var(--danger); }

/* ---------- Filters + search ---------- */
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-family: inherit; font-size: 0.9rem; color: var(--text); }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--brand); }
.filters .search { flex: 1; min-width: 220px; }

/* ---------- Data table ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); user-select: none; white-space: nowrap; }
.th-sort { all: unset; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort:focus-visible { outline: 2px solid var(--brand); }
.data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.center, .data-table td.center { text-align: center; }
.data-table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.data-table tbody tr:hover { background: var(--surface-muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
.sort-ind { color: var(--brand); margin-left: 0.25rem; }
.cell-payee { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 0.82rem; }
.amount.neg { color: var(--danger); font-weight: 700; }
.amount.pos { color: var(--brand); font-weight: 700; }
.table-empty { padding: 2rem; text-align: center; color: var(--muted); }

.status-pill { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-muted); color: var(--muted); cursor: pointer; font-size: 0.85rem; }
.status-pill.status-Cleared { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.status-pill.status-Reconciled { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Row action buttons (edit / delete) ---------- */
.row-actions { display: inline-flex; gap: 0.35rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 0.9rem; transition: background 0.15s, opacity 0.15s; }
.icon-btn:hover:not(:disabled) { background: var(--surface-muted); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- Dismissible error banner ---------- */
.alert-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding: 0.7rem 1rem; margin-bottom: 1rem; border: 1px solid var(--danger); border-radius: var(--radius-sm); background: var(--surface); color: var(--danger); font-weight: 600; }
.alert-banner__close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1rem; padding: 0 0.15rem; line-height: 1; }
.alert-banner__close:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- Segmented control + split lines (modal forms) ---------- */
.seg { display: flex; gap: 0.25rem; background: var(--surface-muted); padding: 0.25rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.seg button { flex: 1; padding: 0.5rem; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.line-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.line-row select { flex: 2; min-width: 0; padding: 0.6rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.line-row input { flex: 1; min-width: 0; padding: 0.6rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.line-row button { flex: none; width: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--danger); cursor: pointer; }
.split-total { text-align: right; font-weight: 700; margin: 0.25rem 0 0.75rem; }

/* ---------- Settings ---------- */
.settings-grid { display: flex; flex-direction: column; gap: 1.25rem; max-width: 660px; }
.settings-grid .card h2 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.settings-grid .card .sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 1rem; }
.env-hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.5rem; }
.saved-flag { color: var(--brand); font-size: 0.85rem; font-weight: 600; }

/* ---------- Reports / charts ---------- */
.report-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.5rem; }
.chart-card h2 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.chart-card .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.25rem; }
.donut-layout { display: grid; grid-template-columns: 190px 1fr; gap: 1.75rem; align-items: center; }
.donut { width: 190px; height: 190px; }
.donut-total { fill: var(--text); font-weight: 800; font-size: 5px; }
.donut-total-label { fill: var(--muted); font-size: 2.6px; }
.legend { display: flex; flex-direction: column; gap: 0.7rem; }
.legend-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 0.7rem; align-items: center; font-size: 0.9rem; }
.legend-main { min-width: 0; }
.legend-name { font-weight: 600; }
.legend-bar { height: 7px; border-radius: 4px; background: var(--surface-muted); overflow: hidden; margin-top: 0.2rem; }
.legend-bar > span { display: block; height: 100%; border-radius: 4px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.legend-amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.linechart { width: 100%; height: 240px; }
.report-empty { color: var(--muted); text-align: center; padding: 2rem; }

@media (max-width: 720px) {
    .donut-layout { grid-template-columns: 1fr; justify-items: center; }
}

/* ---------- Inspector: target progress, quick budget & manage ---------- */
.target-progress { height: 8px; border-radius: 999px; background: var(--surface-muted); border: 1px solid var(--border); overflow: hidden; }
.target-progress__fill { height: 100%; border-radius: 999px; background: var(--brand); transition: width 0.2s ease; }
.target-progress__meta { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0.35rem 0 0.6rem; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.target-progress__done { color: var(--brand); font-weight: 600; }

.inspector-form { margin-top: 0.6rem; padding: 0.85rem; background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inspector-form .field { margin-bottom: 0.75rem; }

.quick-actions { display: flex; flex-direction: column; gap: 0.4rem; }

.section-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 1.1rem; padding: 0; background: none; border: none; cursor: pointer; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.section-toggle:hover { color: var(--text); }
.section-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.rename-row { display: flex; gap: 0.4rem; }
.rename-row input { flex: 1; min-width: 0; }
.rename-row .btn { padding: 0.5rem 0.8rem; flex: none; }

.manage-danger { display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; margin-top: 0.35rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.btn-link.danger { color: var(--danger); }
.btn-link:disabled { opacity: 0.6; cursor: default; }
.btn-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Responsive: collapse the sidebar on narrow screens ---------- */
@media (max-width: 900px) {
    .cockpit { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
    .budget-area.with-inspector { grid-template-columns: 1fr; }
    .workspace { padding: 1.25rem; }
}
