:root {
    color-scheme: dark;
    --ink: #e9ebf2;
    --muted: #9aa3b5;
    --line: #293041;
    --surface: #151a24;
    --canvas: #0b0e14;
    --accent: #8b7bff;
    --accent-strong: #a293ff;
    --accent-soft: rgba(139, 123, 255, .14);
    --orange: #f3b35e;
    --red: #fb7185;
    --shadow-card: 0 12px 32px rgba(0, 0, 0, .18);
    --shadow-float: 0 20px 60px rgba(0, 0, 0, .42);
    --radius-card: 18px;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-shell { min-height: 100vh; }
.desktop-sidebar {
    display: none;
}
.main-content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 16px 112px;
}

.topbar, .section-heading, .card-header, .bottom-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; margin: 0 0 5px; }
h1, h2, h3 { color: var(--ink); letter-spacing: -.025em; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 36px); line-height: 1.14; font-weight: 750; }
h2 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 700; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
.page-header { margin: 0 0 22px; }
.page-description { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.section-note { margin-left:auto;color:var(--muted);font-size:12px;font-weight:600;text-align:right; }
button, input, select, textarea { font: inherit; }
a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(139, 123, 255, .28); outline-offset: 2px; }
.month-picker {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 10px 12px;
    color: var(--ink);
    font-weight: 700;
}
.period-toolbar {
    position:sticky;
    top:0;
    z-index:40;
    display:flex;
    align-items:center;
    gap:6px;
    margin:-20px -16px 24px;
    padding:10px 16px;
    border-bottom:1px solid rgba(228,235,230,.9);
    background:rgba(245,248,246,.94);
    box-shadow:0 8px 18px rgba(27,55,39,.045);
    backdrop-filter:blur(16px);
    -webkit-backdrop-filter:blur(16px);
}
.period-selector {
    display:flex;
    align-items:center;
    gap:5px;
    flex:1;
    min-width:0;
    margin:0;
    padding:0;
    border:0;
    background:transparent;
    box-shadow:none;
}
.period-selector select {
    border:1px solid var(--line);
    border-radius:10px;
    background:var(--surface);
    padding:8px 9px;
    color:var(--ink);
    font:inherit;
    font-size:13px;
    font-weight:650;
    min-width:0;
}
.period-selector select[name="month"] { flex:1; }
.period-selector select[name="year"] { width:82px; }
.period-submit {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:5px;
    min-width:40px;
    min-height:40px;
    border:0;border-radius:10px;padding:8px 10px;
    background:var(--accent);color:white;font-size:12px;font-weight:700;
}
.period-submit svg { width:16px;height:16px; }
.period-step, .month-delete-button {
    display:grid;
    place-items:center;
    flex:0 0 40px;
    width:40px;
    height:40px;
    border:1px solid var(--line);
    border-radius:13px;
    background:var(--surface);
    color:var(--accent);
    text-decoration:none;
    box-shadow:var(--shadow-card);
    transition:background .18s ease,transform .18s ease;
}
.period-step:hover { background:var(--accent-soft);transform:translateY(-1px); }
.month-delete-form { flex:0 0 auto;margin:0 0 0 auto; }
.month-delete-button { cursor:pointer;color:var(--red);box-shadow:none; }
.heading-period { color:var(--accent);font-size:.76em;font-weight:700;letter-spacing:-.02em;white-space:nowrap; }
.dashboard-expense-empty { margin:8px; }
.dashboard-pagination { justify-content:flex-start;gap:8px; }
.dashboard-pagination .secondary-button { min-height:40px;padding:9px 12px; }
.dashboard-pagination .is-disabled { opacity:.45;cursor:default; }
.dashboard-expense-list .item-row { min-width:0; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--ink); color: white; font-weight: 700;
}

.hero-card {
    position:relative;
    isolation:isolate;
    overflow:hidden;
    margin-top:0;
    border-radius:24px;
    padding:24px;
    background:linear-gradient(125deg,#171a2a,#242343);
    color: white;
    box-shadow:0 16px 38px rgba(25,84,54,.18);
}
.hero-card::after {
    content:"";
    position:absolute;
    z-index:-1;
    width:280px;
    height:280px;
    right:-90px;
    top:-150px;
    border:1px solid rgba(255,255,255,.11);
    border-radius:50%;
    box-shadow:0 0 0 30px rgba(255,255,255,.035),0 0 0 64px rgba(255,255,255,.025);
}
.hero-card .label { color:rgba(255,255,255,.75);font-size:13px;font-weight:600; }
.hero-card .amount { font-size:clamp(38px,6vw,54px);font-weight:750;letter-spacing:-.055em;line-height:1.1;margin:8px 0 22px; }
.hero-meta { display:grid;grid-template-columns:1fr 1fr;gap:14px;max-width:560px; }
.hero-meta div { border-left:1px solid rgba(255,255,255,.22);padding-left:14px; }
.hero-meta div:first-child { border:0;padding:0; }
.hero-meta span { display:block;color:rgba(255,255,255,.7);font-size:12px; }
.hero-meta strong { display:block;margin-top:3px;font-size:16px; }

.section-heading { margin:30px 2px 14px;gap:12px;flex-wrap:wrap; }
.text-link { color:var(--accent);text-decoration:none;font-weight:700;font-size:13px; }
.text-link:hover { color:var(--accent-strong);text-decoration:underline;text-underline-offset:3px; }
.metrics-grid, .content-grid {
    display: grid;
    gap:12px;
}
.metrics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
.content-grid { grid-template-columns:minmax(0,1fr); }
.metric-card, .panel-card, .list-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius:var(--radius-card);
    padding:18px;
    box-shadow:var(--shadow-card);
}
.metric-card { min-height:132px; }
.metric-icon {
    width:38px;height:38px;border-radius:13px;
    display: grid; place-items: center;
    background:var(--accent-soft);color:var(--accent);
}
.metric-icon svg { width:19px;height:19px; }
.metric-card span { display:block;color:var(--muted);font-size:12px;line-height:1.35;margin-top:14px; }
.metric-card strong { display:block;font-size:clamp(17px,2vw,21px);font-weight:750;letter-spacing:-.03em;margin-top:4px;overflow-wrap:anywhere; }
.panel-card { margin-top:14px; }
.progress-track { height: 8px; background: #edf1ed; border-radius: 99px; overflow:hidden; margin:14px 0 8px; }
.progress-bar { height:100%; background: var(--accent); border-radius:99px; }
.progress-labels { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; }

.item-row {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap:12px;
    align-items: center;
    padding:15px 0;
    border-top: 1px solid var(--line);
}
.item-row:first-child { border-top: 0; }
.item-icon { width:42px;height:42px;border-radius:14px;display:grid;place-items:center;background:#eef3ef; }
.item-main strong { display:block;font-size:14px; }
.item-main span { display:block;color:var(--muted);font-size:12px;margin-top:3px; }
.item-amount { text-align:right;font-weight:700;font-size:14px; }
.item-amount span { display:block;color:var(--muted);font-size:11px;margin-top:3px;font-weight:500; }

.bottom-nav {
    position: fixed;
    z-index: 20;
    left:10px;right:10px;bottom:max(10px,env(safe-area-inset-bottom));
    min-height:70px;
    display: grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    align-items: center;
    padding:6px 4px;
    background:rgba(255,255,255,.96);
    border: 1px solid var(--line);
    border-radius:20px;
    box-shadow:var(--shadow-float);
    backdrop-filter:blur(16px);
}
.mobile-nav-link {
    min-width:0;
    min-height:54px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:3px;
    border-radius:13px;
    color:#7b8981;
    text-decoration:none;
    font-size:9px;
    font-weight:650;
    white-space:nowrap;
}
.mobile-nav-link svg { width:19px;height:19px; }
.mobile-nav-link.active { background:var(--accent-soft);color:var(--accent-strong); }

.bottom-nav a:focus-visible, .primary-navigation a:focus-visible { outline-offset:1px; }

.form-card { background:white;border:1px solid var(--line);border-radius:var(--radius-card);padding:20px;box-shadow:var(--shadow-card); }
.form-grid { display:grid;gap:15px; }
.form-grid label { display:grid;gap:7px;color:var(--ink);font-size:13px;font-weight:650; }
.form-grid input, .form-grid select, .form-grid textarea {
    width:100%;
    min-height:46px;
    border:1px solid #dfe7e1;
    border-radius:12px;
    padding:11px 13px;
    background:#fbfcfb;
    color:var(--ink);
    font:inherit;
    transition:border-color .15s ease,box-shadow .15s ease,background .15s ease;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.expense-filters input:focus, .expense-filters select:focus, .bulk-payment-row input:focus {
    outline:0;
    border-color:var(--accent);
    background:#fff;
    box-shadow:0 0 0 3px rgba(139,123,255,.12);
}
.inline-checkbox {
    display:flex !important;
    align-items:center;
    gap:10px !important;
    min-height:46px;
    padding:0 12px;
    border:1px solid var(--line);
    border-radius:12px;
    background:#fbfcfb;
}
.inline-checkbox input { width:18px !important;min-height:18px !important;margin:0;accent-color:var(--accent); }
.primary-button, .secondary-button, .danger-button {
    min-height:44px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    border-radius:12px;
    padding:11px 16px;
    font-size:13px;
    font-weight:700;
    text-decoration:none;
    cursor:pointer;
    transition:background .16s ease,color .16s ease,border-color .16s ease,box-shadow .16s ease,transform .16s ease;
}
.primary-button {
    border:1px solid var(--accent);
    background:var(--accent);
    color:white;
    box-shadow:0 3px 8px rgba(139,123,255,.14);
}
.primary-button:hover:not(:disabled) { background:var(--accent-strong);border-color:var(--accent-strong);transform:translateY(-1px); }
.secondary-button {
    border:1px solid var(--line);
    background:white;
    color:var(--ink);
}
.secondary-button:hover:not(:disabled) { border-color:#45405f;background:#24283a; }
.primary-button:disabled, .secondary-button:disabled { opacity:.48;cursor:not-allowed;box-shadow:none; }
.auth-wrap { min-height:calc(100vh - 132px);min-height:calc(100svh - 132px);display:grid;place-items:center;padding:12px; }
.auth-card { width:min(440px,100%);background:white;border-radius:26px;padding:32px;border:1px solid var(--line);box-shadow:var(--shadow-float); }
.brand { display:flex;align-items:center;gap:10px;font-weight:700;margin-bottom:28px; }
.brand-mark { width:38px;height:38px;border-radius:12px;background:var(--ink);color:white;display:grid;place-items:center; }
.brand-logo { display:flex;align-items:center;gap:10px;text-decoration:none;color:var(--ink); }
.brand-logo img { width:46px;height:46px; }
.brand-logo.compact img { width:42px;height:42px; }

.quick-add-card {
    overflow:hidden;
    margin-bottom:20px;
    border:1px solid #dfe9e2;
    border-radius:17px;
    background:var(--surface);
    box-shadow:var(--shadow-card);
}
.quick-add-card > summary {
    min-height:58px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:13px 17px;
    color:var(--accent-strong);
    cursor:pointer;
    list-style:none;
    font-weight:700;
}
.quick-add-card > summary:hover { background:#1b2130; }
.quick-add-card[open] > summary { border-bottom:1px solid var(--line); }
.quick-add-card > summary::-webkit-details-marker { display:none; }
.quick-add-title { display:flex;align-items:center;gap:10px; }
.quick-add-title svg { width:20px;height:20px; }
.quick-add-chevron { width:18px;height:18px;color:var(--muted);transition:transform .18s ease; }
.quick-add-card[open] .quick-add-chevron { transform:rotate(180deg); }
.quick-add-form { padding:2px 17px 18px; }
.expense-card {
    background:var(--surface);
    border:1px solid var(--line);
    border-radius:18px;
    margin-bottom:12px;
    overflow:hidden;
    box-shadow:var(--shadow-card);
    transition:border-color .18s ease,box-shadow .18s ease;
}
.expense-card:hover { border-color:#d6e2d9;box-shadow:0 10px 24px rgba(27,55,39,.07); }
.expense-card.over-budget {
    border-color:#e9a29d;
    background:#fff9f8;
}
.expense-card[hidden] { display:none !important; }
.expense-filters {
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
    margin:0 0 14px;
}
.expense-filters label, .bulk-payment-row label {
    display:grid;
    gap:6px;
    color:var(--muted);
    font-size:12px;
    font-weight:600;
}
.expense-filters input, .expense-filters select, .bulk-payment-row input {
    width:100%;
    min-width:0;
    border:1px solid var(--line);
    border-radius:11px;
    padding:11px;
    background:white;
    color:var(--ink);
    font:inherit;
}
.bulk-payment-rows { display:grid;gap:12px; }
.bulk-payment-row {
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
    padding:12px;
    border:1px solid var(--line);
    border-radius:16px;
    background:#fafbfa;
}
.bulk-payment-row > input[type="hidden"] { display:none; }
.expense-payment-entry { display:grid;gap:12px; }
.expense-payment-actions { display:flex;flex-wrap:wrap;align-items:center;gap:10px; }
.expense-payment-actions .eyebrow { margin:0; }
.expense-payment-entry .bulk-payment-row { background:white; }
.expense-batch-submit {
    display:flex;
    flex-direction:column;
    gap:12px;
    margin-top:14px;
    padding:16px;
    border:1px solid var(--line);
    border-radius:18px;
    background:white;
}
.expense-batch-submit div { display:grid;gap:4px; }
.expense-batch-submit span { color:var(--muted);font-size:13px; }
.expense-batch-submit .primary-button { width:100%; }
.pagination-controls {
    display:flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    margin:16px 0;
}
.pagination-controls[hidden] { display:none; }
.pagination-controls span { color:var(--muted);font-size:13px;text-align:center; }
.pagination-controls button:disabled { opacity:.45;cursor:default; }
.savings-source-toggle {
    display:flex !important;
    align-items:center;
    gap:8px !important;
    min-height:42px;
}
.savings-source-toggle input {
    width:18px !important;
    height:18px;
    margin:0;
    accent-color:var(--accent);
}
.remove-payment-row { justify-self:start; }
.expense-no-results { margin-top:12px;color:var(--muted); }
.expense-card-summary {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 16px;
}
.expense-status {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    margin-top: 6px;
    padding:4px 9px;
    background:#f0f4f1;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}
.expense-status.partial { background:#fff3e3;color:#9a611f; }
.expense-status.paid { background: var(--accent-soft); color: var(--accent); }
.expense-status.over { background:#fde8e6;color:var(--red); }
.expense-progress { padding: 0 16px 14px 70px; }
.expense-progress .progress-track { margin: 0 0 8px; }
.expense-details {
    border-top:1px solid var(--line);
}
.expense-details summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap:10px;
    min-height:48px;
    padding:12px 16px;
    color:var(--accent-strong);
    font-size:13px;
    font-weight:700;
}
.expense-details summary::-webkit-details-marker { display: none; }
.expense-details summary:hover { background:#f8faf8; }
.payment-panel { padding:16px;background:#f8faf8;border-top:1px solid var(--line); }
.payment-panel h3 { margin-bottom: 12px; }
.expense-delete-form { display:flex;justify-content:flex-end;padding:0 16px 14px; }
.payment-list { display:grid;gap:8px;margin:0 0 14px;padding:0;list-style:none; }
.payment-list li {
    display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;gap:10px;
    border:1px solid var(--line);border-radius:12px;padding:10px 12px;
    background:white;font-size:12px;
}
.payment-history-main { display:grid;gap:5px; }
.payment-history-actions { display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:8px; }
.payment-history-actions details summary { color:var(--accent);cursor:pointer;font-weight:700; }
.payment-history-actions .inline-delete { padding:0; }
.savings-funded-label { color:var(--accent);font-size:11px;font-weight:700; }
.full-payment-toggle {
    grid-column: 1 / -1;
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 9px !important;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    background: white;
}
.full-payment-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.full-payment-toggle strong { margin-left: auto; color: var(--ink); }
.recurring-intro { color:var(--muted);line-height:1.55; }
.recurring-template-card { padding-bottom:0; }
.template-edit { min-width:90px; }
.template-edit summary { justify-content:center; }
.template-actions { display:flex;flex-wrap:wrap;gap:8px;padding:0 16px 14px; }
.danger-button {
    border:1px solid #f0d7d4;
    background:#fff8f7;
    color:var(--red);
}
.danger-button:hover:not(:disabled) {
    border-color:#e9bdb8;
    background:#fff0ee;
}
.payment-edit-row {
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
    padding:12px 0;border-top:1px solid var(--line);
}
.payment-edit-row label { display:grid;gap:6px;color:var(--muted);font-size:12px;font-weight:600; }
.payment-edit-row input {
    width:100%;border:1px solid var(--line);border-radius:11px;padding:11px;
    background:white;font:inherit;
}
.payment-edit-row .secondary-button { align-self:end; }
.inline-delete { padding:0 0 12px; }
.flash-message {
    display:flex;
    align-items:flex-start;
    gap:10px;
    margin:0 0 16px;
    border:1px solid #cfe5d6;
    border-radius:14px;
    padding:13px 15px;
    background:var(--accent-soft);
    color:var(--accent);
    font-size:14px;
    font-weight:600;
    box-shadow:var(--shadow-card);
}
.flash-message svg { width:19px;height:19px;flex:0 0 auto;margin-top:1px; }
.flash-message.error {
    border-color:#f0c3bf;
    background:#fff0ee;
    color:#a8322b;
}
.recurring-generation {
    display:flex;
    flex-direction:column;
    gap:16px;
}
.recurring-generation .eyebrow { line-height:1.55;margin-top:8px; }
.payment-edit-row .savings-source-toggle input {
    width:18px !important;height:18px;padding:0;
}
.auth-error {
    margin:16px 0;
    border:1px solid #f0c3bf;
    border-radius:12px;
    padding:11px 13px;
    background:#fff0ee;
    color:#a8322b;
    font-size:13px;
    font-weight:600;
}
.auth-card h1 { font-size:30px; }
.auth-card > .eyebrow { margin-top:8px; }
.auth-card .brand-logo { margin-bottom:28px; }
.auth-card .form-grid { grid-template-columns:1fr; }

@media (min-width: 700px) {
    .recurring-generation { flex-direction:row;align-items:center;justify-content:space-between; }
    .expense-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .expense-filters label:first-child { grid-column:1 / -1; }
    .bulk-payment-row { grid-template-columns:1.4fr 1fr 1fr 1.4fr;align-items:end; }
    .bulk-payment-row .full-payment-toggle { grid-column:1 / -1; }
    .bulk-payment-row .savings-source-toggle { grid-column:1 / 3; }
    .bulk-payment-row .remove-payment-row { grid-column:3 / -1;justify-self:end; }
    .expense-batch-submit { flex-direction:row;align-items:center;justify-content:space-between; }
    .expense-batch-submit .primary-button { width:auto; }
    .payment-list li { flex-direction:row;align-items:center; }
    .auth-wrap { min-height:calc(100vh - 84px);min-height:calc(100svh - 84px); }
    .period-toolbar { margin:-28px -24px 24px;padding-right:24px;padding-left:24px; }
    .period-selector { flex:1;max-width:540px; }
    .period-step, .month-delete-button { flex-basis:42px;width:42px;height:42px; }
}

@media (min-width: 700px) {
    .main-content { padding: 28px 24px 100px; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
    .form-grid .primary-button { width: max-content; }
    .bottom-nav { display: none; }
}

@media (min-width: 700px) and (max-width: 899px) {
    .desktop-sidebar {
        display: flex;
        position: fixed;
        z-index: 30;
        left: 12px;
        bottom: 96px;
        top: auto;
        width: 64px;
        height: auto;
        align-items: center;
        padding: 8px;
        background:#fff;
        border: 1px solid var(--line);
        border-radius: 22px;
        box-shadow: 0 12px 35px rgba(38,58,45,.12);
    }
    .desktop-sidebar .brand-logo, .sidebar-caption, .sidebar-user, .sidebar-logout span { display:none; }
    .desktop-sidebar .primary-navigation { display:grid;margin:0;gap:4px;width:100%; }
    .desktop-sidebar .nav-link {
        display:grid;
        place-items:center;
        justify-content: center;
        width: 46px;
        height: 46px;
        padding: 0;
        overflow: hidden;
        font-size:0;
        border-radius:12px;
        color:var(--muted);
    }
    .desktop-sidebar .nav-link.active { background:var(--accent-soft);color:var(--accent-strong); }
    .desktop-sidebar .nav-link svg { width:20px;height:20px; }
    .sidebar-footer { display:flex;justify-content:center;margin-top:auto; }
    .sidebar-logout { display:grid;place-items:center;justify-content:center;width:46px;height:46px;padding:0;color:var(--muted); }
    .sidebar-logout svg { width:19px;height:19px; }
    .main-content { padding-left: 96px; }
}

@media (min-width: 900px) {
    .app-shell.authenticated { display:grid;grid-template-columns:240px 1fr; }
    .desktop-sidebar {
        display:flex;
        position:sticky;
        top:0;
        height:100vh;
        flex-direction:column;
        padding:26px 18px 18px;
        background:#fff;
        border-right:1px solid var(--line);
    }
    .brand-logo { padding:2px 8px; }
    .brand-logo img { width:46px;height:46px; }
    .sidebar-caption {
        margin:38px 10px 10px;
        color:#98a49c;
        font-size:10px;
        font-weight:750;
        letter-spacing:.1em;
    }
    .primary-navigation { display:grid;gap:5px; }
    .nav-link, .sidebar-logout {
        min-height:46px;
        display:flex;
        align-items:center;
        gap:12px;
        padding:0 12px;
        border-radius:12px;
        color:#64746a;
        text-decoration:none;
        font-size:13px;
        font-weight:650;
        transition:background .16s ease,color .16s ease;
    }
    .nav-link svg, .sidebar-logout svg { width:19px;height:19px;flex:0 0 auto; }
    .nav-link:hover, .sidebar-logout:hover { background:#11151e;color:var(--accent-strong); }
    .nav-link.active { background:var(--accent-soft);color:var(--accent-strong);font-weight:750; }
    .sidebar-footer { display:grid;gap:14px;margin-top:auto;padding-top:20px;border-top:1px solid var(--line); }
    .sidebar-user { display:flex;align-items:center;gap:10px;min-width:0;padding:0 5px; }
    .sidebar-avatar { width:34px;height:34px;display:grid;place-items:center;flex:0 0 auto;border-radius:11px;background:var(--accent-soft);color:var(--accent-strong);font-size:13px;font-weight:750; }
    .sidebar-user-name { overflow:hidden;color:var(--ink);font-size:12px;font-weight:700;text-overflow:ellipsis;white-space:nowrap; }
    .sidebar-logout { min-height:40px;padding:0 8px;color:var(--muted);font-size:12px; }
    .main-content { padding:34px 38px 50px; }
    .period-toolbar { margin:-34px -38px 24px;padding-right:38px;padding-left:38px; }
    .bottom-nav { display:none; }
    .hero-card { padding:30px; }
    .hero-card .amount { font-size:48px; }
}

@media (min-width: 1100px) {
    .period-selector { flex:0 1 520px; }
    .metrics-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
    .content-grid { grid-template-columns:minmax(0,1.35fr) minmax(280px,.65fr); }
    .expense-filters { grid-template-columns:minmax(220px,2fr) repeat(4,minmax(125px,1fr)); }
    .expense-filters label:first-child { grid-column:auto; }
    .recurring-filters { grid-template-columns:minmax(220px,2fr) repeat(3,minmax(130px,1fr)); }
}

@media (max-width: 699px) {
    .topbar.page-header { align-items:flex-start;flex-wrap:wrap;gap:8px; }
    .topbar.page-header > .text-link { margin-left:auto; }
    .period-selector select[name="year"] { width:66px; }
    .period-submit { flex:0 0 36px;min-width:36px;padding:8px; }
    .period-submit span { display:none; }
    .period-toolbar { gap:4px; }
    .period-step, .month-delete-button { flex-basis:36px;width:36px;height:36px;border-radius:11px; }
    .period-selector { gap:4px; }
    .section-heading { align-items:flex-end; }
    .section-heading .text-link { max-width:46%;text-align:right; }
    .expense-card-summary { grid-template-columns:36px minmax(0,1fr) auto;gap:9px;padding:14px 12px; }
    .expense-card-summary .item-icon { width:36px;height:36px;border-radius:12px; }
    .expense-card-summary .item-amount { max-width:96px;font-size:12px; }
    .expense-card-summary .item-amount span { font-size:10px; }
    .expense-progress { padding-left:58px;padding-right:12px; }
    .item-row { grid-template-columns:36px minmax(0,1fr) auto;gap:9px; }
    .item-row .item-icon { width:36px;height:36px; }
    .item-amount { max-width:100px; }
    .hero-card { padding:21px;border-radius:21px; }
    .hero-meta { gap:10px; }
    .hero-meta strong { font-size:14px; }
    .metric-card { min-height:120px;padding:15px; }
    .metric-card strong { font-size:17px; }
    .auth-card { padding:25px 21px; }
}

@media (max-width: 360px) {
    .mobile-nav-link { font-size:8px; }
    .mobile-nav-link svg { width:18px;height:18px; }
    .bottom-nav { left:6px;right:6px;padding-left:2px;padding-right:2px; }
    .main-content { padding-left:12px;padding-right:12px; }
    .period-toolbar { margin-right:-12px;margin-left:-12px;padding-right:12px;padding-left:12px; }
    .period-step, .month-delete-button { flex-basis:34px;width:34px;height:34px; }
    .period-selector select { padding-right:5px;padding-left:7px;font-size:12px; }
    .period-selector select[name="year"] { width:58px; }
    .period-submit { flex-basis:30px;min-width:30px;min-height:36px;padding:6px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior:auto !important;transition-duration:.01ms !important; }
}

body {
    background:
        radial-gradient(ellipse at 82% -10%, rgba(116, 94, 255, .10), transparent 34rem),
        var(--canvas);
    color:var(--ink);
}
:focus-visible { outline-color:rgba(139,123,255,.55); }
h1, h2, h3 { color:var(--ink); }
.period-toolbar {
    border-bottom-color:rgba(41,48,65,.92);
    background:rgba(11,14,20,.91);
    box-shadow:0 10px 24px rgba(0,0,0,.2);
}
.period-selector select,
.form-grid input, .form-grid select, .form-grid textarea,
.expense-filters input, .expense-filters select,
.bulk-payment-row input, .payment-edit-row input {
    border-color:var(--line);
    background:#10141d;
    color:var(--ink);
}
.period-submit, .primary-button {
    background:var(--accent);
    border-color:var(--accent);
    color:#fff;
    box-shadow:0 5px 16px rgba(139,123,255,.2);
}
.period-submit:hover, .primary-button:hover:not(:disabled) {
    background:#7867ed;
    border-color:#7867ed;
}
.period-step, .month-delete-button {
    border-color:var(--line);
    background:#171c27;
    color:var(--accent-strong);
    box-shadow:none;
}
.period-step:hover { background:var(--accent-soft); }
.month-delete-button { color:var(--red); }
.heading-period { color:var(--accent-strong); }
.avatar, .brand-mark { background:var(--accent);color:#fff; }
.hero-card {
    border:1px solid rgba(164,149,255,.2);
    background:linear-gradient(125deg,#171a2a 0%,#242343 100%);
    box-shadow:0 18px 48px rgba(0,0,0,.28);
}
.hero-card::after {
    border-color:rgba(174,163,255,.13);
    box-shadow:0 0 0 30px rgba(174,163,255,.035),0 0 0 64px rgba(174,163,255,.025);
}
.hero-card .amount { color:#fff; }
.hero-meta div { border-color:rgba(255,255,255,.16); }
.text-link { color:var(--accent-strong); }
.text-link:hover { color:#c1b6ff; }
.metric-card, .panel-card, .list-card, .form-card, .chart-card,
.auth-card, .quick-add-card, .expense-card {
    border-color:var(--line);
    background:var(--surface);
    box-shadow:var(--shadow-card);
}
.metric-card, .panel-card, .list-card, .chart-card { background:linear-gradient(145deg,#171c27,#131720); }
.metric-icon, .chart-card-icon {
    background:var(--accent-soft);
    color:var(--accent-strong);
}
.progress-track { background:#272e3c; }
.progress-bar { background:var(--accent); }
.item-icon { background:#202635;color:#c5cbd7; }
.item-row { border-color:var(--line); }
.bottom-nav {
    border-color:var(--line);
    background:rgba(20,24,34,.96);
}
.mobile-nav-link { color:#8d97aa; }
.mobile-nav-link.active { background:var(--accent-soft);color:#c6bcff; }
.nav-link, .sidebar-logout { color:#a0a9ba; }
.desktop-sidebar, .desktop-sidebar .nav-link:hover, .sidebar-logout:hover { background:#11151e; }
.desktop-sidebar { border-color:var(--line); }
.desktop-sidebar .nav-link:hover, .desktop-sidebar .sidebar-logout:hover { color:var(--ink); }
.desktop-sidebar .nav-link.active { background:var(--accent-soft);color:#c6bcff; }
.sidebar-caption { color:#687286; }
.sidebar-user-name { color:var(--ink); }
.sidebar-avatar { background:var(--accent-soft);color:#c6bcff; }
.sidebar-footer { border-color:var(--line); }
.form-grid label, .expense-filters label, .bulk-payment-row label { color:#c4cad6; }
.inline-checkbox, .bulk-payment-row, .expense-payment-entry .bulk-payment-row,
.payment-list li, .payment-edit-row, .full-payment-toggle, .expense-batch-submit {
    border-color:var(--line);
    background:#111620;
    color:var(--ink);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.expense-filters input:focus, .expense-filters select:focus, .bulk-payment-row input:focus {
    border-color:var(--accent);
    background:#141927;
    box-shadow:0 0 0 3px rgba(139,123,255,.17);
}
.inline-checkbox input, .savings-source-toggle input, .full-payment-toggle input { accent-color:var(--accent); }
.secondary-button {
    border-color:var(--line);
    background:#1b2130;
    color:#d5d9e3;
}
.secondary-button:hover:not(:disabled) { border-color:#45405f;background:#24283a; }
.quick-add-card { background:#151a24; }
.quick-add-card > summary { color:#c7beff; }
.quick-add-card > summary:hover, .expense-details summary:hover { background:#1b2130; }
.quick-add-card[open] > summary, .expense-details, .payment-panel { border-color:var(--line); }
.expense-card:hover { border-color:#41415f;box-shadow:0 14px 34px rgba(0,0,0,.26); }
.expense-card.over-budget { border-color:rgba(251,113,133,.48);background:#20161e; }
.expense-status { background:#252b39;color:#b1bac9; }
.expense-status.partial { background:rgba(243,179,94,.14);color:#f3bd75; }
.expense-status.paid { background:rgba(71,199,212,.13);color:#70d5de; }
.expense-status.over { background:rgba(251,113,133,.14);color:#ff9bab; }
.expense-details summary { color:#c7beff; }
.payment-panel { background:#10141d; }
.full-payment-toggle strong { color:var(--ink); }
.danger-button {
    border-color:rgba(251,113,133,.28);
    background:rgba(251,113,133,.09);
    color:#ff91a1;
}
.danger-button:hover:not(:disabled) { border-color:rgba(251,113,133,.5);background:rgba(251,113,133,.16); }
.flash-message { border-color:rgba(71,199,212,.24);background:rgba(71,199,212,.1);color:#8adbe1; }
.flash-message.error, .auth-error { border-color:rgba(251,113,133,.28);background:rgba(251,113,133,.1);color:#ff9bab; }
.auth-card h1 { color:var(--ink); }
.recurring-intro { color:var(--muted); }
.chart-grid { display:grid;grid-template-columns:minmax(0,1.55fr) minmax(280px,.9fr);gap:14px; }
.chart-card { min-width:0;border:1px solid var(--line);border-radius:var(--radius-card);padding:20px; }
.chart-card-header { display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px; }
.chart-card-header h3 { margin:0;color:var(--ink);font-size:15px; }
.chart-card-header p { margin:5px 0 0;color:var(--muted);font-size:12px; }
.chart-card-icon { width:36px;height:36px;flex:0 0 auto;display:grid;place-items:center;border-radius:12px; }
.chart-card-icon svg { width:18px;height:18px; }
.chart-card-summary { display:flex;align-items:center;gap:12px; }
.chart-card-summary > strong { color:var(--ink);font-size:15px;white-space:nowrap; }
.chart-frame { position:relative;height:270px;min-width:0; }
.chart-frame-doughnut { height:270px; }
.chart-frame canvas { max-width:100%; }
.statistics-heading { align-items:flex-end; }
.statistics-heading .page-description { margin-top:5px; }
.statistics-period { color:var(--muted);font-size:12px;font-weight:600; }
.chart-empty-state { min-height:270px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:20px;text-align:center;color:var(--muted); }
.chart-empty-state svg { width:30px;height:30px;color:var(--accent-strong);opacity:.8; }
.chart-empty-state strong { color:var(--ink);font-size:13px; }
.chart-empty-state span { max-width:240px;font-size:12px;line-height:1.55; }
.auth-wrap { min-height:100vh; }
.auth-card { border-radius:20px; }
@media (max-width: 760px) {
    .chart-grid { grid-template-columns:minmax(0,1fr); }
    .chart-card-category { max-width:none; }
    .chart-frame, .chart-frame-doughnut { height:250px; }
}
@media (max-width: 480px) {
    .chart-card { padding:16px; }
    .statistics-heading { align-items:flex-start; }
    .statistics-period { margin-top:4px;white-space:nowrap; }
}
.password-field {
    display:grid;
    gap:7px;
    color:#c4cad6;
    font-size:13px;
    font-weight:650;
}
.password-input-wrapper { position:relative; }
.password-input-wrapper input { padding-right:50px; }
.password-toggle {
    position:absolute;
    top:50%;
    right:6px;
    display:grid;
    place-items:center;
    width:36px;
    height:36px;
    padding:0;
    border:0;
    border-radius:9px;
    background:transparent;
    color:var(--muted);
    cursor:pointer;
    transform:translateY(-50%);
}
.password-toggle:hover { color:var(--accent-strong); }
.password-toggle:focus-visible { outline:2px solid var(--accent-strong);outline-offset:1px; }
.password-toggle svg { width:19px;height:19px; }
