:root {
    --ink: #182622;
    --muted: #697772;
    --paper: #f4f2eb;
    --card: #fffefa;
    --line: #dedfd7;
    --primary: #123d35;
    --primary-2: #1f6f5f;
    --soft: #e1ece7;
    --gold: #d8a744;
    --danger: #a73737;
    --danger-soft: #f8e5e2;
    --positive: #17724e;
    --shadow: 0 18px 50px rgba(29, 45, 39, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 0 0, rgba(31,111,95,.09), transparent 30rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.85rem, 5vw, 3rem); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin-bottom: .2rem; font-size: clamp(1.15rem, 3.5vw, 1.55rem); letter-spacing: -.025em; }
h3 { margin-bottom: .25rem; }
.muted, .page-heading p, .form-note { color: var(--muted); }
.eyebrow { margin-bottom: .35rem; color: var(--primary-2); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.negative { color: var(--danger) !important; }
.positive { color: var(--positive) !important; }

.topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: max(.75rem, env(safe-area-inset-top)) max(1rem, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid rgba(222,223,215,.75);
    background: rgba(244,242,235,.86);
    backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand span:last-child { display: grid; }
.brand strong { font-size: .94rem; }
.brand small { color: var(--muted); font-size: .7rem; }
.brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 13px 13px 13px 5px;
    color: white;
    background: var(--primary);
    font-size: .73rem;
    font-weight: 900;
    letter-spacing: -.05em;
    box-shadow: 0 8px 18px rgba(18,61,53,.2);
}
.brand-mark.large { width: 54px; height: 54px; border-radius: 18px 18px 18px 7px; font-size: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: .55rem; }
.icon-button, .avatar {
    display: inline-grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    font-weight: 800;
}
.icon-button { cursor: pointer; }
.avatar { color: white; border: 0; background: var(--primary-2); }

.app-main { width: min(1180px, 100%); min-height: calc(100vh - 140px); margin: auto; padding: 1.2rem 1rem 7rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1rem 0 1.4rem; }
.page-heading p:last-child { margin-bottom: 0; }
.heading-actions { display: flex; gap: .6rem; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: .72rem 1rem;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    font-weight: 750;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:active { transform: translateY(1px); }
.button.primary { color: white; background: var(--primary); box-shadow: 0 9px 22px rgba(18,61,53,.17); }
.button.soft { color: var(--primary); background: var(--soft); }
.button.ghost { color: var(--primary); border: 1px solid var(--line); background: transparent; }
.button.danger { color: white; background: var(--danger); }
.button.full, .full { width: 100%; }
.text-button { padding: 0; border: 0; color: var(--primary-2); background: none; cursor: pointer; font-size: .82rem; font-weight: 800; }

.hero-balance {
    position: relative;
    display: flex;
    min-height: 188px;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    padding: 1.55rem;
    border-radius: 30px;
    color: white;
    background:
        linear-gradient(130deg, rgba(255,255,255,.06), transparent 45%),
        var(--primary);
    box-shadow: 0 24px 55px rgba(18,61,53,.18);
}
.hero-balance::after {
    position: absolute;
    width: 220px;
    height: 220px;
    right: -85px;
    bottom: -130px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    content: "";
}
.hero-balance > div:first-child { position: relative; z-index: 1; display: grid; gap: .2rem; }
.hero-balance span { color: rgba(255,255,255,.72); font-size: .82rem; }
.hero-balance strong { color: white; font-size: clamp(2rem, 8vw, 3.7rem); line-height: 1.1; letter-spacing: -.055em; }
.hero-balance small { color: rgba(255,255,255,.65); }
.hero-balance.compact { min-height: 155px; }
.balance-orb { position: relative; z-index: 1; display: grid; width: 74px; height: 74px; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: rgba(255,255,255,.1); }
.balance-orb span { color: white; font-size: 2rem; }

.metric-grid, .report-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin: .9rem 0 1.5rem;
}
.metric-card, .report-summary article {
    display: grid;
    gap: .2rem;
    padding: 1rem;
    border: 1px solid rgba(222,223,215,.9);
    border-radius: 18px;
    background: rgba(255,254,250,.75);
}
.metric-card span, .report-summary span { color: var(--muted); font-size: .75rem; }
.metric-card strong, .report-summary strong { font-size: 1.1rem; letter-spacing: -.03em; }
.metric-card small, .report-summary small { color: var(--muted); font-size: .68rem; }

.content-card {
    margin: 1rem 0;
    padding: 1.1rem;
    border: 1px solid rgba(222,223,215,.9);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-title-row p, .section-title-row h2 { margin-bottom: 0; }
.quick-section { margin: 1.7rem 0; }
.quick-categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.quick-chip { display: grid; min-width: 0; gap: .35rem; justify-items: center; padding: .7rem .3rem; border: 0; border-radius: 15px; color: var(--muted); background: rgba(255,254,250,.8); cursor: pointer; font-size: .68rem; }
.quick-chip span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; color: white; background: var(--chip-color); font-weight: 850; }
.quick-chip.selected { color: var(--primary); outline: 2px solid var(--primary-2); background: var(--soft); }
.quick-purchase-layout { display: grid; grid-template-columns: .8fr 1.2fr; align-items: start; gap: 1rem; }
.quick-purchase-layout .content-card { margin-top: 0; }
.purchase-category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.purchase-save { min-height: 52px; font-size: 1rem; }

.list { display: grid; }
.list-row { position: relative; display: flex; min-width: 0; align-items: center; gap: .75rem; padding: .85rem 0; border-bottom: 1px solid #ecece6; }
.list-row:last-child { border-bottom: 0; }
.list-icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 12px; color: var(--primary); background: var(--soft); font-weight: 850; }
.list-main { display: grid; min-width: 0; flex: 1; }
.list-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main small, .list-row > small { color: var(--muted); }
.list-value { flex: 0 0 auto; font-weight: 800; white-space: nowrap; }
.category-dot { width: 10px; height: 36px; flex: 0 0 auto; border-radius: 20px; background: var(--category-color); }
.row-action button { border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.row-actions { display: flex; align-items: center; gap: .35rem; }
.row-actions a, .row-actions button { padding: .25rem; border: 0; color: var(--primary-2); background: transparent; cursor: pointer; font-size: .72rem; font-weight: 750; }
.expense-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.expense-group { min-width: 0; margin-top: 0; }
.expense-group .section-title-row { align-items: flex-start; }
.expense-group .section-title-row small { display: block; max-width: 360px; color: var(--muted); }
.credit-group { border-top: 4px solid #725a7a; }
.direct-group { border-top: 4px solid var(--primary-2); }

.shortcut-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin: 1rem 0; }
.shortcut-grid a { display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem; padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,254,250,.75); }
.shortcut-grid span { grid-column: 1; color: var(--muted); font-size: .72rem; }
.shortcut-grid strong { grid-column: 1; font-size: .88rem; }
.shortcut-grid a { color: var(--primary); }

.notification-panel { margin-bottom: 1rem; padding: 1rem; border: 1px solid #ead8ad; border-radius: var(--radius); background: #fff9e9; }
.notification-list { display: grid; }
.notification-item { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-top: 1px solid #efe2c3; }
.notification-item > span:nth-child(2) { display: grid; flex: 1; }
.notification-item small { color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.status-dot.danger { background: var(--danger); }

.empty-state { display: grid; min-height: 140px; place-items: center; align-content: center; gap: .4rem; padding: 1rem; color: var(--muted); text-align: center; }
.empty-state span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: var(--primary-2); background: var(--soft); font-weight: 800; }
.empty-state p { margin: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-stack { display: grid; gap: .9rem; }
.field { display: grid; min-width: 0; gap: .35rem; }
.field.full { grid-column: 1 / -1; }
.field > span, .filter-bar label > span { color: var(--muted); font-size: .76rem; font-weight: 750; }
.field input, .field select, .field textarea, .filter-bar input, .filter-bar select, .inline-form input {
    width: 100%;
    min-height: 45px;
    padding: .7rem .8rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: 0;
    color: var(--ink);
    background: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(31,111,95,.12); }
.field input[type="color"] { padding: .35rem; }
.check-field { display: flex; align-items: flex-start; gap: .7rem; cursor: pointer; }
.check-field input { width: 19px; height: 19px; margin-top: .15rem; accent-color: var(--primary-2); }
.check-field span { display: grid; }
.check-field small { color: var(--muted); }
.form-note { margin: .7rem 0 0; font-size: .76rem; }
.filter-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: .65rem; margin: 0 0 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,254,250,.75); }
.filter-bar label { display: grid; gap: .25rem; }
.inline-form { display: flex; gap: .45rem; margin-top: .7rem; }

.app-dialog { width: min(620px, calc(100% - 1.2rem)); max-height: calc(100dvh - 1.2rem); padding: 0; border: 0; border-radius: 25px; background: var(--card); box-shadow: 0 30px 80px rgba(17,32,27,.3); }
.app-dialog::backdrop { background: rgba(15,30,26,.55); backdrop-filter: blur(4px); }
.dialog-content { display: grid; gap: 1rem; max-height: calc(100dvh - 1.2rem); overflow-y: auto; padding: 1.15rem; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--paper); cursor: pointer; font-size: 1.4rem; }

.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: .8rem; }
.tabs a { padding: .6rem .85rem; border-radius: 12px; color: var(--muted); font-size: .8rem; font-weight: 750; white-space: nowrap; }
.tabs a.active { color: var(--primary); background: var(--soft); }
.bill-grid, .invoice-grid, .wallet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; }
.bill-card, .invoice-card, .wallet-card { padding: 1rem; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.bill-card.overdue, .invoice-card:has(.status-badge:first-child) { }
.bill-card.overdue { border-color: #e9b7b0; background: #fffafa; }
.bill-card h3, .bill-card p { margin-bottom: .2rem; }
.bill-card > strong, .wallet-card > strong { display: block; margin: .65rem 0; font-size: 1.45rem; }
.bill-top, .invoice-card > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.bill-top small, .invoice-card p, .wallet-card small { color: var(--muted); }
.status-badge { display: inline-flex; width: fit-content; padding: .27rem .55rem; border-radius: 99px; color: var(--primary); background: var(--soft); font-size: .66rem; font-weight: 850; }
.overdue .status-badge { color: var(--danger); background: var(--danger-soft); }

.card-carousel { display: grid; grid-auto-columns: minmax(280px, 390px); grid-auto-flow: column; gap: 1rem; overflow-x: auto; padding: .2rem .1rem 1rem; scroll-snap-type: x mandatory; }
.credit-card { position: relative; min-height: 230px; overflow: hidden; padding: 1.2rem; border-radius: 25px; color: white; background: linear-gradient(140deg, rgba(255,255,255,.12), transparent 55%), var(--card-color); box-shadow: 0 18px 38px color-mix(in srgb, var(--card-color) 22%, transparent); scroll-snap-align: start; }
.credit-card::after { position: absolute; width: 180px; height: 180px; right: -90px; top: -90px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; content: ""; }
.credit-card-top, .credit-card-dates, .card-actions { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: .7rem; }
.credit-card h2 { position: relative; z-index: 1; margin: 1.2rem 0 .1rem; }
.credit-card p { color: rgba(255,255,255,.75); }
.credit-card-dates { margin-top: 1.1rem; }
.credit-card-dates span { display: grid; font-weight: 800; }
.credit-card-dates small { color: rgba(255,255,255,.65); font-weight: 500; }
.card-goal { margin-top: .8rem; font-size: .75rem; }
.card-actions { margin-top: 1rem; justify-content: flex-end; }
.card-actions form { display: inline; }
.card-actions button, .card-actions a { padding: .2rem .45rem; border: 0; color: rgba(255,255,255,.9); background: none; cursor: pointer; font-size: .73rem; text-decoration: underline; text-underline-offset: 3px; }
.invoice-card h3 { margin: .8rem 0 .25rem; font-size: 1.55rem; }
.card-edit-panel { max-width: 760px; }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; }

.progress { height: 7px; margin: .75rem 0 .35rem; overflow: hidden; border-radius: 20px; background: var(--soft); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary-2); }
.two-column, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.goal-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; padding: .7rem 0; border-bottom: 1px solid #ecece6; }
.goal-row > div { display: grid; }
.goal-row small { color: var(--muted); }
.goal-row .progress { grid-column: 1 / -1; width: 100%; margin: .2rem 0; }

.report-summary { grid-template-columns: repeat(4, 1fr); }
.report-summary article { padding: 1.1rem; background: var(--card); }
.report-summary strong { font-size: 1.35rem; }
.chart-wrap { display: grid; grid-template-columns: minmax(160px, .8fr) 1.2fr; align-items: center; gap: 1rem; }
.donut-chart { position: relative; width: min(190px, 100%); aspect-ratio: 1; margin: auto; border-radius: 50%; background: conic-gradient(var(--soft) 0 100%); }
.donut-chart::after { position: absolute; inset: 24%; border-radius: 50%; background: var(--card); content: ""; }
.donut-chart > span { position: absolute; z-index: 1; inset: 0; display: grid; place-content: center; text-align: center; font-size: .9rem; font-weight: 850; }
.donut-chart small { display: block; color: var(--muted); font-size: .6rem; font-weight: 500; }
.chart-legend { display: grid; gap: .55rem; }
.chart-legend > div { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: .5rem; }
.chart-legend > div > span { width: 9px; height: 9px; border-radius: 50%; background: var(--legend-color); }
.chart-legend strong, .chart-legend small { font-size: .72rem; }
.chart-legend small { color: var(--muted); }
.cash-breakdown { display: grid; gap: .65rem; }
.cash-breakdown > div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .6rem; border-bottom: 1px solid #ecece6; }
.cash-breakdown span { color: var(--muted); }
.cash-breakdown .total { padding: .7rem; border: 0; border-radius: 12px; background: var(--paper); }
.insight-box { margin-top: 1rem; padding: 1rem; border-radius: 16px; color: white; background: var(--primary); }
.insight-box span { color: rgba(255,255,255,.65); font-size: .7rem; }
.insight-box strong { display: block; font-size: 1.3rem; }
.insight-box p { margin: .15rem 0 0; color: rgba(255,255,255,.75); }
.forecast-bars { display: grid; gap: .7rem; }
.forecast-bars > div { display: grid; grid-template-columns: 65px 1fr 95px; align-items: center; gap: .7rem; }
.forecast-bars > div > div { height: 8px; overflow: hidden; border-radius: 20px; background: var(--soft); }
.forecast-bars i { display: block; height: 100%; border-radius: inherit; background: var(--primary-2); }
.forecast-bars span { color: var(--muted); font-size: .75rem; }
.forecast-bars strong { text-align: right; font-size: .78rem; }
.discrepancy-panel { margin-bottom: 1rem; padding: 1rem; border: 1px solid #e6c58a; border-radius: 17px; background: #fff8e8; }
.discrepancy-panel h3 { font-size: 1.25rem; }
.reconcile-equation { display: flex; align-items: center; gap: .8rem; margin: .9rem 0; }
.reconcile-equation span { display: grid; flex: 1; padding: .7rem; border-radius: 12px; background: white; color: var(--muted); font-size: .72rem; }
.reconcile-equation strong { color: var(--ink); font-size: 1rem; }
.danger-check { padding: .8rem; border-radius: 14px; background: var(--danger-soft); }
.closure-result .metric-grid { grid-template-columns: repeat(4, 1fr); }
.closure-result .metric-grid > div { display: grid; gap: .2rem; padding: .8rem; border-radius: 12px; background: var(--paper); }
.closure-result span { color: var(--muted); font-size: .7rem; }

.import-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 1rem; }
.import-steps article { display: grid; grid-template-columns: auto 1fr; gap: .1rem .65rem; padding: .9rem; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,254,250,.75); }
.import-steps article > span { grid-row: 1 / 3; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: white; background: var(--primary); font-size: .8rem; font-weight: 850; }
.import-steps small { color: var(--muted); }
.prompt-box { width: 100%; min-height: 460px; padding: .9rem; border: 1px solid var(--line); border-radius: 13px; color: #dbece6; background: #152923; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .72rem; line-height: 1.55; resize: vertical; }
.upload-field { display: grid; min-height: 145px; place-items: center; padding: 1rem; border: 1.5px dashed #9fb4ad; border-radius: 17px; background: #f5faf7; cursor: pointer; text-align: center; }
.upload-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-field span { display: grid; color: var(--primary); font-weight: 800; }
.upload-field small { color: var(--muted); font-weight: 500; }
.review-list { display: grid; gap: .7rem; }
.review-item { display: grid; grid-template-columns: auto 1fr; gap: .75rem; padding: .85rem; border: 1px solid var(--line); border-radius: 16px; }
.review-item.has-duplicate { border-color: #e7c47f; background: #fffbf1; }
.review-select input { width: 20px; height: 20px; accent-color: var(--primary-2); }
.review-fields { display: grid; grid-template-columns: 1fr 220px; gap: .7rem; }
.review-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: .6rem; }
.review-meta .review-date { width: min(190px, 100%); }
.review-meta strong { margin-left: auto; }
.duplicate-warning { grid-column: 1 / -1; display: grid; padding: .65rem; border-radius: 11px; background: #f7e7bd; }
.duplicate-warning span, .duplicate-warning small { color: #6f5722; font-size: .73rem; }
.sticky-action { position: sticky; z-index: 4; bottom: 82px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,254,250,.94); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.sticky-action p { margin: 0; color: var(--muted); font-size: .8rem; }

.more-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
.more-menu a { display: flex; align-items: center; gap: .75rem; padding: .85rem; border: 1px solid var(--line); border-radius: 17px; background: var(--card); }
.more-menu a > span { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 12px; color: var(--primary); background: var(--soft); font-weight: 850; }
.more-menu a > div { display: grid; flex: 1; }
.more-menu small { color: var(--muted); }
.member-grid { display: grid; gap: .6rem; }
.member-grid article { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px solid #ecece6; }
.member-grid article > div { display: grid; flex: 1; }
.member-grid small { color: var(--muted); }
.category-cloud { display: flex; flex-wrap: wrap; gap: .5rem; }
.category-cloud > span { display: grid; padding: .48rem .65rem; border-left: 4px solid var(--tag-color); border-radius: 9px; background: var(--paper); font-size: .77rem; font-weight: 750; }
.category-cloud small { color: var(--muted); font-size: .6rem; font-weight: 500; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-color: #e6bdb8; }
.danger-zone p { margin-bottom: 0; color: var(--muted); }

.flash-stack { position: fixed; z-index: 100; top: 80px; right: 1rem; display: grid; width: min(390px, calc(100% - 2rem)); gap: .5rem; }
.flash { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: 0 16px 40px rgba(20,35,30,.16); }
.flash button { border: 0; background: none; cursor: pointer; }
.flash-success { border-color: #a9d0bf; }
.flash-error { border-color: #e4aaa2; background: #fff5f3; }
.flash-warning { border-color: #e4c179; background: #fff9eb; }
.inline-alert { margin: .8rem 0; padding: .8rem; border-radius: 12px; }
.inline-alert.danger { color: #802c2c; background: var(--danger-soft); }
.inline-alert.warning { color: #6f5722; background: #fff3d3; }
.report-explanation { color: var(--primary); border: 1px solid #c8ddd5; background: #edf6f2; }

.guest-body { min-height: 100vh; background: radial-gradient(circle at 50% 0, rgba(31,111,95,.16), transparent 33rem), var(--paper); }
.guest-main { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
.auth-card { width: min(460px, 100%); padding: 1.35rem; border: 1px solid var(--line); border-radius: 28px; background: var(--card); box-shadow: 0 30px 80px rgba(18,61,53,.13); }
.setup-card { width: min(620px, 100%); }
.auth-brand { margin-bottom: 1.5rem; }

.bottom-nav {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-height: 68px;
    padding: .45rem max(.45rem, env(safe-area-inset-right)) max(.45rem, env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left));
    border-top: 1px solid rgba(222,223,215,.9);
    background: rgba(255,254,250,.94);
    backdrop-filter: blur(18px);
}
.bottom-nav a { display: grid; place-items: center; align-content: center; gap: .1rem; color: #7b8682; }
.bottom-nav a > span { font-size: 1.15rem; line-height: 1; }
.bottom-nav small { font-size: .56rem; font-weight: 750; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .nav-add span { display: grid; width: 42px; height: 42px; place-items: center; margin-top: -25px; border: 4px solid var(--paper); border-radius: 50%; color: white; background: var(--primary); box-shadow: 0 9px 22px rgba(18,61,53,.2); }

@media (min-width: 760px) {
    .app-main { padding: 2rem 1.5rem 8rem; }
    .hero-balance { padding: 2rem; }
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .quick-categories { grid-template-columns: repeat(8, 1fr); }
    .bottom-nav { right: auto; left: 50%; bottom: 1rem; width: min(760px, calc(100% - 2rem)); transform: translateX(-50%); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
}

@media (max-width: 759px) {
    .page-heading { align-items: flex-start; }
    .page-heading .button { padding-inline: .75rem; }
    .filter-bar { grid-template-columns: repeat(2, 1fr); }
    .two-column, .settings-grid, .report-columns { grid-template-columns: 1fr; }
    .quick-purchase-layout { grid-template-columns: 1fr; }
    .expense-groups { grid-template-columns: 1fr; }
    .report-summary { grid-template-columns: repeat(2, 1fr); }
    .closure-result .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .import-columns { display: grid; }
    .review-fields { grid-template-columns: 1fr; }
    .review-fields > * { grid-column: 1 !important; }
}

@media (max-width: 460px) {
    .app-main { padding-inline: .75rem; }
    .topbar { padding-inline: .8rem; }
    .brand span:last-child { display: none; }
    .page-heading { gap: .5rem; }
    .page-heading > .button { font-size: .75rem; }
    .hero-balance { min-height: 165px; padding: 1.2rem; border-radius: 24px; }
    .balance-orb { width: 55px; height: 55px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-card:last-child { grid-column: 1 / -1; }
    .form-grid { grid-template-columns: 1fr; }
    .field { grid-column: 1 !important; }
    .shortcut-grid, .more-menu { grid-template-columns: 1fr 1fr; }
    .chart-wrap { grid-template-columns: 1fr; }
    .chart-legend { grid-template-columns: 1fr 1fr; }
    .import-steps { grid-template-columns: 1fr; }
    .prompt-box { min-height: 390px; }
    .sticky-action { bottom: 74px; align-items: stretch; flex-direction: column; }
    .danger-zone { align-items: stretch; flex-direction: column; }
}

@media print {
    body { background: white; color: #111; }
    .no-print, .bottom-nav, .topbar, .flash-stack { display: none !important; }
    .app-main { width: 100%; padding: 0; }
    .content-card, .report-summary article { break-inside: avoid; box-shadow: none; }
    .report-columns { grid-template-columns: 1fr 1fr; }
    .page-heading { margin-top: 0; }
}
