/* Household CFO design tokens. Condensed display face, plain sans body, mono for numbers. */
:root {
    --cfo-bg: #eef1f3;
    --cfo-surface: #ffffff;
    --cfo-surface-2: #f6f8f9;
    --cfo-ink: #1d2730;
    --cfo-muted: #5d6b77;
    --cfo-line: #d5dce2;
    --cfo-nav: #16232b;
    --cfo-nav-ink: #cfd8de;
    --cfo-accent: #3bb08f;      /* ledger green: current/active */
    --cfo-accent-ink: #1d2730;
    --cfo-done: #2f8a5b;
    --cfo-pending: #9aa7b2;
    --cfo-over: #c4472f;
    --cfo-risk: #c27c0e;
    --cfo-track: #e3e8ec;
    --cfo-link: #1f5f8b;
    --cfo-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --cfo-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --cfo-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
    --bs-body-font-family: var(--cfo-body);
    --bs-body-bg: var(--cfo-bg);
    --bs-body-color: var(--cfo-ink);
    --bs-border-color: var(--cfo-line);
    --bs-link-color: var(--cfo-link);
    --bs-link-color-rgb: 31, 95, 139;
}

html, body { background: var(--cfo-bg); color: var(--cfo-ink); font-family: var(--cfo-body); font-size: 15px; }
h1:focus { outline: none; }
a { color: var(--cfo-link); }

.display-title { font-family: var(--cfo-display); font-weight: 700; font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: .01em; line-height: 1.05; margin: 0; text-wrap: balance; }
.section-title { font-family: var(--cfo-display); font-weight: 700; font-size: 1.35rem; letter-spacing: .02em; margin: 0; }
.eyebrow { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--cfo-muted); font-weight: 600; }
.mono, .num { font-family: var(--cfo-mono); font-variant-numeric: tabular-nums; }
.text-muted { color: var(--cfo-muted) !important; }
.small-muted { font-size: .82rem; color: var(--cfo-muted); }

/* Money colors */
.num-under { color: var(--cfo-done) !important; }
.num-ok { color: var(--cfo-ink) !important; }
.num-risk { color: var(--cfo-risk) !important; }
.num-over { color: var(--cfo-over) !important; }
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.pill-under, .pill-done { background: color-mix(in srgb, var(--cfo-done) 14%, transparent); color: var(--cfo-done); }
.pill-ok, .pill-pending { background: var(--cfo-track); color: var(--cfo-muted); }
.pill-risk, .pill-active { background: color-mix(in srgb, var(--cfo-accent) 22%, transparent); color: #1f6b55; }
.pill-over, .pill-blocked { background: color-mix(in srgb, var(--cfo-over) 14%, transparent); color: var(--cfo-over); }
.pill-sheet { background: transparent; border-color: #9cc3db; color: var(--cfo-link); font-family: var(--cfo-mono); font-weight: 500; }

/* Buttons */
.btn { border-radius: 6px; font-weight: 500; }
.btn-primary { background: var(--cfo-ink); border-color: var(--cfo-ink); }
.btn-primary:hover, .btn-primary:focus { background: #33414d; border-color: #33414d; }
.btn-accent { background: var(--cfo-accent); border-color: var(--cfo-accent); color: var(--cfo-accent-ink); }
.btn-accent:hover { background: #2f9a7b; border-color: #2f9a7b; color: var(--cfo-accent-ink); }
.btn-outline-secondary { border-color: var(--cfo-line); color: var(--cfo-ink); background: var(--cfo-surface); }
.btn-outline-secondary:hover { background: var(--cfo-surface-2); color: var(--cfo-ink); border-color: var(--cfo-pending); }
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: inline-grid; place-items: center; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--cfo-accent) 45%, transparent); border-color: var(--cfo-accent); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--cfo-muted); margin-bottom: .25rem; }
.form-control, .form-select { border-color: var(--cfo-line); background-color: var(--cfo-surface); }

/* App frame */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.app-nav { background: var(--cfo-nav); color: var(--cfo-nav-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; color: #fff; text-decoration: none; font-family: var(--cfo-display); font-weight: 700; font-size: 1.45rem; letter-spacing: .03em; }
.brand:hover { color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--cfo-accent); color: var(--cfo-ink); display: grid; place-items: center; font-size: 1rem; }
.nav-project { padding: .25rem 1.1rem 1rem; border-bottom: 1px solid #2f3c47; }
.nav-project .name { color: #fff; font-weight: 600; line-height: 1.25; }
.nav-project .addr { font-size: .78rem; color: #93a3af; }
.nav-group { padding: .7rem .6rem .2rem; }
.nav-group-label { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: #7f909c; padding: 0 .55rem .3rem; font-weight: 600; }
.nav-link-cfo { display: flex; align-items: center; gap: .65rem; padding: .42rem .55rem; border-radius: 6px; color: var(--cfo-nav-ink); text-decoration: none; font-size: .92rem; }
.nav-link-cfo i { font-size: 1rem; width: 1.1rem; text-align: center; opacity: .85; }
.nav-link-cfo:hover { background: #2a3640; color: #fff; }
.nav-link-cfo.active { background: color-mix(in srgb, var(--cfo-accent) 20%, transparent); color: #fff; box-shadow: inset 3px 0 0 var(--cfo-accent); }
.nav-link-cfo .badge-count { margin-left: auto; font-size: .7rem; background: var(--cfo-over); color: #fff; border-radius: 999px; padding: 0 .45rem; }
.nav-foot { margin-top: auto; padding: .9rem 1.1rem; border-top: 1px solid #2f3c47; display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #3a4854; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .8rem; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar { display: none; }
.page-body { padding: 1.5rem 1.75rem 3rem; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-loading { padding: 3rem; text-align: center; color: var(--cfo-muted); }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .app-nav { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 1050; transform: translateX(-100%); transition: transform .2s ease; }
    .app.nav-open .app-nav { transform: none; }
    .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1040; }
    .topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--cfo-nav); color: #fff; position: sticky; top: 0; z-index: 1030; }
    .topbar .title { font-family: var(--cfo-display); font-weight: 700; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar button { background: none; border: 0; color: #fff; font-size: 1.4rem; padding: 0 .25rem; }
    .page-body { padding: 1rem 1rem 3rem; }
}

/* Surfaces */
.panel { background: var(--cfo-surface); border: 1px solid var(--cfo-line); border-radius: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--cfo-line); flex-wrap: wrap; }
.panel-body { padding: 1.1rem; }
.panel + .panel { margin-top: 1rem; }
.grid-2 > .panel, .grid-3 > .panel, .stack > .panel, .lanes > .panel { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--cfo-muted); }
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--cfo-pending); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.kpi { background: var(--cfo-surface); border: 1px solid var(--cfo-line); border-radius: 10px; padding: .8rem .95rem; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.kpi .label { font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--cfo-muted); font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.kpi .value { font-family: var(--cfo-display); font-weight: 700; font-size: 1.85rem; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: .78rem; color: var(--cfo-muted); }
.kpi .meter { height: 6px; background: var(--cfo-track); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.kpi .meter b { display: block; height: 100%; background: var(--cfo-done); }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--cfo-pending); }

/* Tables */
.table-cfo { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table-cfo th { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--cfo-muted); font-weight: 600; padding: .55rem .7rem; border-bottom: 1px solid var(--cfo-line); background: var(--cfo-surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table-cfo td { padding: .55rem .7rem; border-bottom: 1px solid var(--cfo-line); vertical-align: middle; }
.table-cfo tr:last-child td { border-bottom: 0; }
.table-cfo tbody tr:hover td { background: color-mix(in srgb, var(--cfo-track) 45%, transparent); }
.table-cfo .r { text-align: right; font-family: var(--cfo-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-cfo tfoot td { font-weight: 600; background: var(--cfo-surface-2); border-top: 2px solid var(--cfo-line); }
.table-wrap { overflow-x: auto; position: relative; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { padding: .15rem .45rem; }
.group-row td { background: var(--cfo-surface-2); font-weight: 600; }

/* Modal */
.cfo-modal-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 34, .5); z-index: 1060; display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.cfo-modal { background: var(--cfo-surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.cfo-modal.lg { max-width: 820px; }
.cfo-modal.xl { max-width: 1100px; }
.cfo-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--cfo-line); }
.cfo-modal-head h2 { font-size: 1.1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: .5rem; }
.cfo-modal-body { padding: 1.2rem; overflow-y: auto; }
.cfo-modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.2rem; border-top: 1px solid var(--cfo-line); background: var(--cfo-surface-2); border-radius: 0 0 12px 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Toasts */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast-cfo { background: var(--cfo-ink); color: #fff; border-radius: 8px; padding: .7rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; }
.toast-cfo.danger { background: var(--cfo-over); }
.toast-cfo button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--cfo-line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a, .tabs button { border: 0; background: none; padding: .55rem .85rem; color: var(--cfo-muted); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active, .tabs button.active { color: var(--cfo-ink); border-bottom-color: var(--cfo-accent); }

/* Cards grid (projects, documents, boards) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.tile { background: var(--cfo-surface); border: 1px solid var(--cfo-line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--cfo-pending); color: inherit; }
.tile-img { aspect-ratio: 16 / 10; background: #25313a center/cover no-repeat; position: relative; max-width: 100%; }
.tile-img .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #93a3af; font-size: 2rem; }
.tile-body { padding: .8rem .95rem; display: flex; flex-direction: column; gap: .25rem; }
.tile-title { font-weight: 600; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 480px); }
.login-art { background: var(--cfo-nav); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-family: var(--cfo-display); font-weight: 700; font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 1; max-width: 12ch; }
.login-art p { color: #b9c5cd; max-width: 46ch; }
.login-form { background: var(--cfo-surface); padding: 3rem 2.5rem; display: flex; flex-direction: column; justify-content: center; gap: 1rem; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: .7rem; border: 1px solid var(--cfo-line); background: #fff; color: #1f1f1f; padding: .7rem 1rem; font-weight: 600; border-radius: 8px; }
.btn-google:hover { background: #f6f8f9; color: #1f1f1f; }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; } .login-art { padding: 2rem 1.25rem; min-height: 38vh; } .login-form { padding: 2rem 1.25rem; } }

/* Print */
@media print {
    .app { display: block; }
    .app-nav, .topbar, .no-print, .toasts, #blazor-error-ui, .page-head .actions { display: none !important; }
    .page-body { padding: 0; max-width: none; }
    body, html { background: #fff; font-size: 12px; }
    .panel, .kpi { break-inside: avoid; border-color: #bbb; }
    .table-cfo th { position: static; }
    .report-page { break-after: page; }
}

#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); box-sizing: border-box; display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 2000; }
#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: "An error has occurred." }
.validation-message { color: var(--cfo-over); font-size: .8rem; }

/* Navigation items for areas not built yet */
.nav-link-cfo.soon { opacity: .45; cursor: default; }
.nav-link-cfo.soon:hover { background: none; color: var(--cfo-nav-ink); }

/* Overview roadmap */
.roadmap { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.roadmap li { color: var(--cfo-muted); }
.roadmap li b { color: var(--cfo-ink); }
.roadmap li.now::marker { color: var(--cfo-done); font-weight: 700; }
