:root {
    --navy: #10233f;
    --navy-2: #18365f;
    --green: #2f6f4e;
    --gold: #c89f3d;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e1ea;
    --surface: #ffffff;
    --background: #f2f5f8;
    --accent: #1f5fbf;
    --success: #18795b;
    --danger: #b42318;
}

* { box-sizing: border-box; }

body {
    background: var(--background);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.app-navbar {
    background: linear-gradient(90deg, var(--navy), var(--navy-2));
    box-shadow: 0 12px 30px rgba(16, 35, 63, 0.18);
}

.brand-lockup,
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-copy {
    display: grid;
    gap: 2px;
    line-height: 1.05;
}

.brand-copy small,
.maker-line {
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.72rem;
    font-weight: 650;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, var(--green), var(--gold));
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0;
    flex: 0 0 auto;
}

.navbar-brand {
    white-space: normal;
    line-height: 1.1;
}

.nav-link {
    font-weight: 650;
    opacity: 0.9;
}

.logout-btn {
    color: var(--navy);
}

.app-shell {
    max-width: 1440px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(16, 35, 63, 0.78), rgba(16, 35, 63, 0.78)),
        url("https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.auth-card {
    width: min(100%, 440px);
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
    padding: 32px;
}

.flash-stack { margin-bottom: 20px; }
.auth-shell .flash-stack {
    position: fixed;
    top: 20px;
    width: min(440px, calc(100% - 32px));
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    font-weight: 800;
}

.eyebrow {
    color: var(--green);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin: 0 0 4px;
    text-transform: uppercase;
}

.panel,
.metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 35px rgba(16, 35, 63, 0.07);
}

.panel { padding: 22px; }
.panel h2,
.panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.metric-card {
    padding: 22px;
    min-height: 124px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-top: 4px solid var(--accent);
}

.metric-card span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    font-size: clamp(1.4rem, 2.8vw, 2rem);
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.metric-card.income { border-top-color: var(--success); }
.metric-card.expense { border-top-color: var(--danger); }
.metric-card.balance { border-top-color: var(--gold); }
.metric-card.receivable { border-top-color: #0e9f6e; }
.metric-card.payable { border-top-color: #c2410c; }
.metric-card.net { border-top-color: #2563eb; }

.dashboard-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.content-grid,
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
    gap: 18px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.dashboard-grid .panel:first-child {
    grid-row: span 2;
}

.finance-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
    gap: 14px;
    align-items: end;
}

.filter-form.extended-filter {
    grid-template-columns: repeat(4, minmax(145px, 1fr)) auto;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.filter-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.filter-summary span {
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--muted);
    font-size: 0.92rem;
}

.table {
    --bs-table-bg: transparent;
    min-width: 720px;
}

.table thead th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.form-control,
.form-select {
    border-color: #cbd5e1;
    border-radius: 8px;
    min-height: 44px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(31, 95, 191, 0.14);
}

.btn {
    border-radius: 8px;
    font-weight: 750;
    min-height: 40px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.table .btn-sm {
    min-height: 34px;
    padding-inline: 12px;
    white-space: nowrap;
}

.stack-list {
    display: grid;
    gap: 12px;
}

.stack-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.stack-item span,
.stack-item time,
.muted-count {
    color: var(--muted);
    font-size: 0.9rem;
}

.stack-item div {
    display: grid;
    gap: 2px;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 26px 12px;
}

.app-footer {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px 24px;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 0.88rem;
}

.app-footer strong {
    color: var(--navy);
}

@media (max-width: 1199.98px) {
    .dashboard-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .metrics-grid,
    .content-grid,
    .dashboard-grid,
    .finance-layout,
    .filter-form {
        grid-template-columns: 1fr;
    }

    .dashboard-grid .panel:first-child {
        grid-row: auto;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn {
        flex: 1;
    }
}

@media (max-width: 767.98px) {
    .app-shell {
        padding-left: 14px;
        padding-right: 14px;
    }

    .page-heading,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading .btn,
    .panel-header .btn {
        width: 100%;
    }

    .panel,
    .auth-card,
    .metric-card {
        padding: 18px;
        border-radius: 9px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
    }

    .navbar-nav {
        padding-top: 12px;
    }

    .navbar-nav .nav-link,
    .logout-btn {
        width: 100%;
        text-align: left;
    }

    .table-responsive {
        overflow: visible;
    }

    .table {
        min-width: 0;
    }

    .table thead {
        display: none;
    }

    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        border: 1px solid var(--line);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 10px 12px;
        background: #fff;
    }

    .table td {
        border: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        padding: 7px 0;
        text-align: right !important;
        overflow-wrap: anywhere;
    }

    .table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 800;
        text-align: left;
        flex: 0 0 110px;
    }

    .table td[colspan] {
        display: block;
        text-align: center !important;
    }

    .table td[colspan]::before {
        content: none;
    }

    .stack-item {
        flex-direction: column;
    }

    .app-footer {
        flex-direction: column;
        padding: 0 14px 20px;
    }
}
