:root {
    --bg: #f3f1eb;
    --panel: #fffdf8;
    --ink: #1c2430;
    --muted: #5f6b7a;
    --line: #ddd6c8;
    --brand: #0f5c4c;
    --brand-2: #173a5e;
    --income: #0f7a4a;
    --expense: #b42318;
    --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
    --radius: 16px;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

html, body {
    font-family: var(--font);
    background: linear-gradient(160deg, #e8f0ec 0%, var(--bg) 45%, #e7eef6 100%);
    color: var(--ink);
    min-height: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--brand-2), #0d2a45 55%, #0b3d34);
    color: #f5f7fa;
    padding: 1.25rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
    padding: .25rem .5rem;
}

.brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #f4c95f;
    color: #173a5e;
    font-weight: 800;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.nav-section { display: grid; gap: .35rem; }

.nav-group {
    margin-top: .75rem;
    padding-top: .5rem;
    border-top: 1px solid rgba(255,255,255,.12);
}

.nav-group-title {
    color: rgba(215,224,234,.65);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .4rem .9rem .2rem;
}

.nav-item {
    color: #d7e0ea !important;
    padding: .7rem .9rem;
    border-radius: 10px;
    text-decoration: none !important;
}

.nav-item.nav-sub {
    padding-left: 1.15rem;
    font-size: .95rem;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255,255,255,.12);
    color: #fff !important;
}

.main-panel { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(28,36,48,.08);
    backdrop-filter: blur(8px);
}

.topbar-title { color: var(--muted); font-size: .95rem; }
.topbar-user { display: flex; gap: .75rem; align-items: center; }

.content {
    padding: 1.25rem 1.5rem 2rem;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 {
    font-size: clamp(1.6rem, 2vw, 2rem);
    margin: 0 0 .35rem;
}
.page-head p { margin: 0; color: var(--muted); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: .85rem;
    margin-bottom: .35rem;
}

.stat-card strong { font-size: 1.35rem; }
.stat-card.income strong { color: var(--income); }
.stat-card.expense strong { color: var(--expense); }
.stat-card.net strong { color: var(--brand-2); }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
}

.panel-head h2 {
    font-size: 1.05rem;
    margin: 0;
}

.table { margin-bottom: 0; }
.table > :not(caption) > * > * { background: transparent; }
.table thead th {
    color: var(--muted);
    font-weight: 600;
    border-bottom-color: var(--line);
}

.badge-income, .badge-expense {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-income { background: #e5f6ec; color: var(--income); }
.badge-expense { background: #fde8e6; color: var(--expense); }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
}
.btn-primary:hover {
    background: #0c4b3e;
    border-color: #0c4b3e;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .85rem;
    align-items: stretch;
}

.filter-box {
    margin: 0;
    padding: .65rem .75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #faf8f3;
    min-height: 100%;
}

.filter-box legend {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
    float: none;
    width: auto;
    padding: 0 .25rem;
    margin-bottom: .35rem;
}

.filter-radio {
    display: block;
    font-size: .9rem;
    margin-bottom: .25rem;
    color: var(--ink);
}

.filter-period {
    display: grid;
    gap: .15rem;
    margin-top: .35rem;
}

.filter-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    justify-content: flex-end;
}

.filter-stats {
    margin-bottom: 0;
}

.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
}

.report-sheet {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem 1.5rem;
    box-shadow: var(--shadow);
}

.report-sheet-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: .85rem;
    border-bottom: 2px solid var(--brand-2);
}

.report-brand {
    font-weight: 800;
    color: var(--brand);
    letter-spacing: .04em;
    font-size: .85rem;
    text-transform: uppercase;
}

.report-sheet-head h2 {
    margin: .2rem 0 .25rem;
    font-size: 1.45rem;
    color: var(--brand-2);
}

.report-period { margin: 0; color: var(--muted); }
.report-meta { color: var(--muted); font-size: .9rem; text-align: right; }

.report-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.report-kpi {
    border-radius: 12px;
    padding: .75rem .9rem;
    border: 1px solid var(--line);
}

.report-kpi span {
    display: block;
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: .2rem;
}

.report-kpi strong { font-size: 1.2rem; }
.report-kpi.income { background: #e5f6ec; }
.report-kpi.income strong { color: var(--income); }
.report-kpi.expense { background: #fde8e6; }
.report-kpi.expense strong { color: var(--expense); }
.report-kpi.net { background: #e8eef6; }
.report-kpi.net strong { color: var(--brand-2); }

.report-table thead th {
    background: var(--brand-2) !important;
    color: #fff !important;
    border-color: var(--brand-2) !important;
}

.text-income { color: var(--income); font-weight: 600; }
.text-expense { color: var(--expense); font-weight: 600; }

@media print {
    .no-print, .sidebar, .topbar, .nav-section { display: none !important; }
    .app-shell { display: block; }
    .main-panel { display: block; }
    .content { padding: 0; }
    .report-sheet { box-shadow: none; border: none; }
}

@media (max-width: 900px) {
    .report-kpis { grid-template-columns: 1fr; }
    .report-sheet-head { flex-direction: column; }
    .report-meta { text-align: left; }
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 15% 20%, rgba(15,92,76,.18), transparent 35%),
        radial-gradient(circle at 85% 10%, rgba(23,58,94,.18), transparent 30%),
        linear-gradient(160deg, #e8f0ec, #f3f1eb 50%, #e7eef6);
}

.auth-card {
    width: min(420px, 100%);
    background: rgba(255,253,248,.92);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--brand-2);
}

.auth-sub {
    color: var(--muted);
    margin: .35rem 0 1.25rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1rem;
    color: white;
}

#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;
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        padding-bottom: .75rem;
    }
    .nav-section {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
    }
    .stat-grid,
    .filter-row {
        grid-template-columns: 1fr;
    }
    .content { padding: 1rem; }
    .topbar { padding: .85rem 1rem; }
}
