:root {
    --bg: #090b12;
    --bg-elevated: #0e111a;
    --sidebar: rgba(10, 12, 20, .96);
    --surface: rgba(18, 22, 33, .88);
    --surface-solid: #121621;
    --surface-2: #191e2c;
    --surface-3: #202637;
    --border: rgba(255, 255, 255, .075);
    --border-strong: rgba(255, 255, 255, .14);
    --text: #f6f7fb;
    --muted: #949bad;
    --muted-2: #697187;
    --purple: #8b5cf6;
    --purple-light: #a98bff;
    --blue: #49a8ff;
    --pink: #ff5b9d;
    --green: #49e8a4;
    --red: #ff6473;
    --orange: #ffad5c;
    --shadow: 0 22px 60px rgba(0, 0, 0, .22);
    --radius: 18px;
    --sidebar-width: 264px;
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
    --bg: #f2f4f8;
    --bg-elevated: #e9edf4;
    --sidebar: rgba(250, 251, 253, .97);
    --surface: rgba(255, 255, 255, .92);
    --surface-solid: #fff;
    --surface-2: #f4f6fa;
    --surface-3: #e9edf5;
    --border: rgba(23, 31, 51, .09);
    --border-strong: rgba(23, 31, 51, .16);
    --text: #172033;
    --muted: #687187;
    --muted-2: #8a92a3;
    --shadow: 0 18px 45px rgba(42, 50, 73, .09);
    color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    min-width: 320px;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 77% -8%, rgba(139, 92, 246, .09), transparent 30rem),
        radial-gradient(circle at 18% 92%, rgba(73, 168, 255, .055), transparent 30rem),
        var(--bg);
    font-size: 14px;
    line-height: 1.5;
}
body, button, input, select, textarea { font-family: inherit; }
button, input, select, textarea { font-size: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl, dd { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 2vw, 1.75rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.05rem; line-height: 1.25; letter-spacing: -.02em; }
small { color: var(--muted); }
code {
    padding: .15rem .38rem;
    border: 1px solid rgba(73, 232, 164, .12);
    border-radius: 6px;
    color: var(--green);
    background: rgba(73, 232, 164, .07);
}
.icon { display: block; width: 18px; height: 18px; flex: 0 0 18px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.green { color: var(--green) !important; }
.pink { color: var(--pink) !important; }
.red { color: var(--red) !important; }
.orange { color: var(--orange) !important; }
.eyebrow {
    margin-bottom: .38rem;
    color: var(--muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.heading-note { margin: .35rem 0 0; color: var(--muted); font-size: .7rem; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 24px 16px 18px;
    border-right: 1px solid var(--border);
    background: var(--sidebar);
    backdrop-filter: blur(22px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand-mark {
    position: relative;
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(169, 139, 255, .42);
    border-radius: 12px;
    color: #fff;
    background: #17142a;
    box-shadow: inset 0 0 18px rgba(139, 92, 246, .17), 0 9px 24px rgba(0, 0, 0, .22);
}
.brand-mark i { position: absolute; width: 25px; height: 25px; border: 1px solid var(--purple); border-radius: 50%; box-shadow: 0 0 16px rgba(139, 92, 246, .5); }
.brand-mark b { position: relative; font-size: .72rem; letter-spacing: -.08em; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: .9rem; letter-spacing: -.01em; }
.brand-copy small { margin-top: 1px; font-size: .59rem; }
.sidebar-section { margin-bottom: 21px; }
.admin-section { margin-top: 2px; }
.nav-label { margin: 0 10px 8px; color: var(--muted-2); font-size: .58rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.nav { display: grid; gap: 4px; }
.nav a {
    position: relative;
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 680;
    transition: .16s ease;
}
.nav a .icon { width: 17px; height: 17px; color: var(--muted-2); }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active {
    border-color: rgba(139, 92, 246, .18);
    color: #fff;
    background: rgba(139, 92, 246, .13);
    box-shadow: inset 3px 0 var(--purple-light);
}
[data-theme="light"] .nav a.active { color: #5f38c6; }
.nav a.active .icon { color: var(--purple-light); }
.sidebar-insight {
    position: relative;
    margin: auto 2px 18px;
    overflow: hidden;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(73, 168, 255, .07), rgba(139, 92, 246, .08));
}
.sidebar-insight > * { position: relative; z-index: 1; }
.sidebar-insight p { margin-bottom: 3px; color: var(--muted); font-size: .6rem; font-weight: 750; text-transform: uppercase; }
.sidebar-insight strong, .sidebar-insight small { display: block; }
.sidebar-insight strong { font-size: .83rem; }
.sidebar-insight small { margin-top: 7px; font-size: .57rem; line-height: 1.45; }
.insight-orb { position: absolute; width: 85px; height: 85px; right: -35px; bottom: -40px; border-radius: 50%; background: var(--purple); filter: blur(30px); opacity: .2; }
.sidebar-footer { display: flex; align-items: center; gap: 7px; padding-top: 15px; border-top: 1px solid var(--border); }
.admin-card { display: flex; min-width: 0; flex: 1; align-items: center; gap: 8px; }
.avatar { display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; border-radius: 9px; color: #fff; background: linear-gradient(145deg, #6442d1, #35236d); font-size: .7rem; font-weight: 850; }
.admin-card > span:last-child { min-width: 0; }
.admin-card strong, .admin-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-card strong { font-size: .66rem; }
.admin-card small { max-width: 105px; font-size: .52rem; }
.sidebar-actions { display: flex; gap: 3px; }
.icon-control, .menu-button {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}
.icon-control:hover, .menu-button:hover { color: var(--text); background: var(--surface-2); }
.icon-control .icon { width: 16px; height: 16px; }
.sidebar-scrim { display: none; }

.main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: 82px;
    align-items: center;
    gap: 16px;
    padding: 16px clamp(22px, 3.2vw, 46px);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(20px);
}
.menu-button { display: none; }
.page-title { min-width: 0; flex: 1; }
.page-title .eyebrow { margin-bottom: .25rem; }
.month-switcher {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}
.month-switcher a { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 7px; color: var(--muted); font-size: 1.25rem; }
.month-switcher a:hover { color: var(--text); background: var(--surface-2); }
.month-switcher input { width: 137px; min-height: 28px; padding: 2px 5px; border: 0; color: var(--text); background: transparent; font-size: .7rem; font-weight: 760; text-align: center; }
.page-content { display: grid; gap: 20px; padding: 25px clamp(22px, 3.2vw, 46px) 52px; }
.page-content > * { min-width: 0; }
.app-footer { display: flex; justify-content: space-between; margin: 0 clamp(22px, 3.2vw, 46px); padding: 17px 0 24px; border-top: 1px solid var(--border); color: var(--muted-2); font-size: .58rem; }

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px clamp(22px, 3.2vw, 46px) -5px;
    padding: 11px 14px;
    border: 1px solid;
    border-radius: 11px;
    font-size: .74rem;
}
.flash > span { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; font-weight: 900; }
.flash p { margin: 0; }
.flash.success { border-color: rgba(73, 232, 164, .28); color: var(--green); background: rgba(73, 232, 164, .06); }
.flash.error { border-color: rgba(255, 100, 115, .3); color: var(--red); background: rgba(255, 100, 115, .07); }
.flash button { display: grid; width: 27px; height: 27px; margin-left: auto; place-items: center; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; }
.flash button .icon { width: 14px; height: 14px; }

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}
.panel { min-width: 0; padding: 21px; }
.stack { display: grid; align-content: start; gap: 18px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-heading .eyebrow { margin-bottom: 3px; }
.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    color: var(--text);
    background: var(--surface-2);
    font-size: .7rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); border-color: rgba(169, 139, 255, .4); }
.button.primary { border-color: rgba(139, 92, 246, .55); color: #fff; background: #7448df; box-shadow: 0 8px 20px rgba(91, 54, 190, .22); }
.button.glass { background: rgba(255, 255, 255, .06); backdrop-filter: blur(8px); }
.button.secondary { background: transparent; }
.button.small { min-height: 32px; padding: 6px 10px; font-size: .64rem; }
.button.full { width: 100%; }
.button .icon { width: 15px; height: 15px; }
.top-action { min-height: 36px; }
.text-link { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: var(--purple-light); background: none; font-size: .67rem; font-weight: 750; cursor: pointer; }
.text-link:hover { color: var(--text); }
.icon-button, .micro-button {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}
.icon-button:hover, .micro-button:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-button.danger:hover, .micro-button.danger:hover { color: var(--red); border-color: rgba(255, 100, 115, .3); background: rgba(255, 100, 115, .06); }
.icon-button .icon, .micro-button .icon { width: 14px; height: 14px; }
.micro-button { width: 25px; height: 25px; flex-basis: 25px; border: 0; }

.overview-hero {
    position: relative;
    display: grid;
    min-height: 285px;
    grid-template-columns: minmax(0, 1.45fr) minmax(250px, .55fr);
    align-items: center;
    overflow: hidden;
    border-color: rgba(139, 92, 246, .18);
    background: #0b0f18;
}
.overview-hero, .dashboard-layout, .dashboard-main, .dashboard-side,
.dashboard-main > *, .dashboard-side > * { min-width: 0; }
.hero-art {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(8, 12, 20, .99) 0%, rgba(8, 12, 20, .92) 35%, rgba(8, 12, 20, .28) 77%, rgba(8, 12, 20, .12) 100%),
        url("/assets/images/financial-flow.png") center / cover no-repeat;
    opacity: .92;
}
[data-theme="light"] .overview-hero { color: #fff; }
.hero-copy, .hero-gauge { position: relative; z-index: 1; }
.hero-copy { padding: 32px clamp(26px, 4vw, 48px); }
.status-line { display: flex; align-items: center; gap: 8px; color: #aeb5c7; font-size: .62rem; font-weight: 700; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 11px var(--green); }
.status-divider { width: 3px; height: 3px; border-radius: 50%; background: #5b6477; }
.hero-label { margin: 25px 0 4px; color: #aeb5c7; font-size: .73rem; font-weight: 700; }
.hero-value { color: #fff; font-size: clamp(2.65rem, 5vw, 4.25rem); font-weight: 820; line-height: 1; letter-spacing: -.07em; }
.hero-value.negative { color: var(--red); }
.hero-summary { margin: 8px 0 0; color: #929bad; font-size: .72rem; }
.hero-summary span { margin: 0 5px; color: #535d70; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 25px; }
.hero-gauge { display: flex; align-items: center; gap: 18px; padding: 28px 35px 28px 10px; }
.gauge-ring {
    --angle: calc(var(--progress) * 3.6deg);
    display: grid;
    width: 116px;
    height: 116px;
    flex: 0 0 116px;
    place-content: center;
    border-radius: 50%;
    background:
        radial-gradient(circle 45px, #111522 97%, transparent 100%),
        conic-gradient(var(--green) var(--angle), rgba(255, 255, 255, .09) 0);
    box-shadow: 0 0 35px rgba(73, 232, 164, .08);
    text-align: center;
}
.gauge-ring span { color: #fff; font-size: 1.3rem; font-weight: 850; line-height: 1; }
.gauge-ring small { margin-top: 5px; color: #8f98aa; font-size: .55rem; font-weight: 750; text-transform: uppercase; }
.gauge-note { min-width: 0; }
.gauge-note span, .gauge-note strong, .gauge-note small { display: block; }
.gauge-note span { color: #929bad; font-size: .58rem; text-transform: uppercase; }
.gauge-note strong { margin-top: 4px; color: #fff; font-size: 1rem; }
.gauge-note small { margin-top: 4px; color: #737d92; font-size: .55rem; line-height: 1.4; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 148px; padding: 18px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 10px; }
.metric-icon .icon { width: 16px; height: 16px; }
.metric-icon.blue { color: var(--blue); background: rgba(73, 168, 255, .1); }
.metric-icon.pink { color: var(--pink); background: rgba(255, 91, 157, .1); }
.metric-icon.purple { color: var(--purple-light); background: rgba(139, 92, 246, .11); }
.metric-icon.green { color: var(--green); background: rgba(73, 232, 164, .1); }
.metric-icon.orange { color: var(--orange); background: rgba(255, 173, 92, .1); }
.trend-tag { padding: 4px 7px; border-radius: 20px; color: var(--green); background: rgba(73, 232, 164, .07); font-size: .54rem; font-weight: 800; white-space: nowrap; }
.trend-tag.warning, .trend-tag.negative { color: var(--orange); background: rgba(255, 173, 92, .08); }
.metric-card > p { margin: 14px 0 4px; color: var(--muted); font-size: .66rem; font-weight: 700; }
.metric-card > strong { display: block; font-size: 1.43rem; line-height: 1.1; letter-spacing: -.045em; }
.metric-card > small { display: block; margin-top: 7px; font-size: .57rem; line-height: 1.45; }

.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(300px, .8fr); gap: 18px; align-items: start; }
.budget-list { display: grid; }
.budget-row {
    display: grid;
    grid-template-columns: minmax(185px, .8fr) minmax(220px, 1.25fr) auto;
    align-items: center;
    gap: 18px;
    padding: 15px 0;
    border-top: 1px solid var(--border);
}
.budget-row:first-child { padding-top: 2px; border-top: 0; }
.budget-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.category-mark {
    display: grid;
    width: 35px;
    height: 35px;
    flex: 0 0 35px;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--dot), transparent 60%);
    border-radius: 10px;
    color: var(--dot);
    background: color-mix(in srgb, var(--dot), transparent 89%);
    font-size: .64rem;
    font-weight: 900;
}
.budget-identity > div { min-width: 0; }
.budget-identity strong, .budget-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-identity strong { font-size: .72rem; }
.budget-identity span { margin-top: 2px; color: var(--muted); font-size: .56rem; }
.budget-progress { min-width: 0; }
.progress-labels { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .55rem; }
.progress-labels strong { color: var(--text); font-size: .58rem; }
.progress-track { height: 5px; margin: 7px 0 5px; overflow: hidden; border-radius: 5px; background: var(--surface-3); }
.progress-track span { display: block; max-width: 100%; height: 100%; border-radius: inherit; background: var(--bar); box-shadow: 0 0 10px color-mix(in srgb, var(--bar), transparent 45%); }
.budget-progress small { display: block; font-size: .53rem; }
.row-actions, .table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions form, .table-actions form { display: flex; }
.trend-chart { display: block; width: 100%; max-width: 100%; }
.trend-chart.large { min-height: 270px; }
.activity-list, .income-list, .due-list { display: grid; width: 100%; min-width: 0; }
.activity-row, .income-list > div {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-top: 1px solid var(--border);
}
.activity-row:first-child, .income-list > div:first-child { padding-top: 0; border-top: 0; }
.activity-icon { display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; border-radius: 9px; color: var(--blue); background: rgba(73, 168, 255, .09); }
.activity-icon .icon { width: 14px; height: 14px; }
.activity-icon.expense { color: var(--pink); background: rgba(255, 91, 157, .09); }
.activity-icon.saved { color: var(--purple-light); background: rgba(139, 92, 246, .1); }
.activity-icon.restored, .activity-icon.income { color: var(--green); background: rgba(73, 232, 164, .09); }
.activity-row > div, .income-list p { min-width: 0; flex: 1; margin: 0; }
.activity-row strong, .activity-row small, .income-list strong, .income-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row strong, .income-list strong { font-size: .68rem; }
.activity-row small, .income-list small { margin-top: 2px; font-size: .54rem; }
.activity-row > b, .income-list > div > b { font-size: .66rem; }
.plan-card { border-color: rgba(139, 92, 246, .16); }
.health-score { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: rgba(139, 92, 246, .045); }
.health-score > span {
    --angle: calc(var(--score) * 3.6deg);
    display: grid;
    width: 55px;
    height: 55px;
    flex: 0 0 55px;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle 21px, var(--surface-solid) 97%, transparent 100%), conic-gradient(var(--purple-light) var(--angle), var(--surface-3) 0);
    font-size: .72rem;
    font-weight: 850;
}
.health-score strong, .health-score small { display: block; }
.health-score strong { font-size: .68rem; }
.health-score small { margin-top: 3px; font-size: .53rem; }
.plan-facts { margin: 13px 0 0; }
.plan-facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); font-size: .62rem; }
.plan-facts dt { color: var(--muted); }
.plan-facts dd { font-weight: 800; }
.rollover-refresh { display: flex; justify-content: flex-end; margin-top: 2px; }
.rule-summary { display: flex; align-items: center; gap: 10px; margin-top: 11px; padding: 11px; border-radius: 10px; background: var(--surface-2); }
.rule-summary > span { color: var(--purple-light); }
.rule-summary p { margin: 0; }
.rule-summary strong, .rule-summary small { display: block; }
.rule-summary strong { font-size: .62rem; }
.rule-summary small { margin-top: 2px; font-size: .51rem; }
.due-list > div { display: flex; align-items: center; gap: 9px; padding: 10px 0; border-top: 1px solid var(--border); }
.due-list > div:first-child { padding-top: 0; border-top: 0; }
.date-tile { display: grid; width: 35px; height: 39px; flex: 0 0 35px; place-content: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); text-align: center; }
.date-tile b { font-size: .72rem; line-height: 1; }
.date-tile small { margin-top: 3px; font-size: .46rem; }
.due-list p { min-width: 0; flex: 1; margin: 0; }
.due-list strong, .due-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-list strong { font-size: .65rem; }
.due-list small { margin-top: 2px; font-size: .52rem; }
.due-list > div > b { font-size: .62rem; }
.usage-card { padding: 17px 19px; background: linear-gradient(135deg, rgba(73, 168, 255, .06), rgba(139, 92, 246, .055)), var(--surface); }
.usage-card > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.usage-card span { display: block; padding: 8px 3px; border-left: 1px solid var(--border); text-align: center; }
.usage-card span:first-child { border-left: 0; }
.usage-card strong, .usage-card small { display: block; }
.usage-card strong { color: var(--blue); font-size: 1rem; }
.usage-card small { margin-top: 1px; font-size: .48rem; }

.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-intro h2 { font-size: 1.35rem; }
.page-intro p:last-child { max-width: 620px; margin: 7px 0 0; color: var(--muted); font-size: .72rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.summary-card { display: flex; min-height: 94px; align-items: center; gap: 12px; padding: 17px; }
.summary-card small, .summary-card strong { display: block; }
.summary-card small { font-size: .56rem; text-transform: uppercase; }
.summary-card strong { margin-top: 4px; font-size: 1.12rem; letter-spacing: -.035em; }

label { display: grid; gap: 6px; color: var(--muted); font-size: .64rem; font-weight: 750; }
input, select, textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: 0;
    color: var(--text);
    background: var(--surface-2);
    transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(139, 92, 246, .6); box-shadow: 0 0 0 3px rgba(139, 92, 246, .09); }
input[type="color"] { padding: 5px; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; accent-color: var(--purple); }
.money-input { position: relative; }
.money-input > span { position: absolute; z-index: 1; left: 10px; top: 50%; color: var(--muted); transform: translateY(-50%); }
.money-input input { padding-left: 25px; }
.stack-form { display: grid; gap: 13px; }
.stack-form.compact { gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-note { margin: 12px 0 0; color: var(--muted); font-size: .58rem; }
.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; background: rgba(255, 255, 255, .018); cursor: pointer; }
.check-row input { margin-top: 2px; }
.check-row span, .check-row strong, .check-row small { display: block; }
.check-row strong { color: var(--text); font-size: .66rem; }
.check-row small { margin-top: 2px; font-size: .54rem; font-weight: 500; }
.check-row.slim { align-items: center; padding: 4px 0; border: 0; background: transparent; }
.inline-form { display: flex; }
.top-gap { margin-top: 10px; }
.inline-fields { display: grid; grid-template-columns: 1.2fr .32fr 1fr auto; align-items: end; gap: 11px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.danger-link { color: var(--red); }
.danger-link .icon { width: 13px; height: 13px; }
.push-left { margin-right: auto; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }

dialog { width: min(590px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: auto; border: 0; border-radius: 17px; color: var(--text); background: transparent; box-shadow: 0 30px 100px rgba(0, 0, 0, .55); }
dialog::backdrop { background: rgba(3, 5, 10, .78); backdrop-filter: blur(6px); }
.dialog-card { padding: 22px; border: 1px solid var(--border-strong); border-radius: 17px; background: var(--surface-solid); }

.empty-state { display: grid; min-height: 210px; place-items: center; align-content: center; padding: 27px 15px; border: 1px dashed var(--border-strong); border-radius: 13px; color: var(--muted); text-align: center; }
.empty-state.compact { min-height: 130px; padding: 20px 10px; }
.empty-state strong { color: var(--text); font-size: .75rem; }
.empty-state p { max-width: 340px; margin: 5px 0 13px; font-size: .63rem; }
.empty-icon { display: grid; width: 37px; height: 37px; margin-bottom: 10px; place-items: center; border-radius: 10px; color: var(--purple-light); background: rgba(139, 92, 246, .1); }
.empty-icon .icon { width: 17px; height: 17px; }

.search-box { position: relative; width: min(285px, 100%); }
.search-box .icon { position: absolute; z-index: 1; left: 9px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); }
.search-box input { min-height: 34px; padding: 6px 9px 6px 30px; font-size: .63rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px; border-bottom: 1px solid var(--border-strong); color: var(--muted); font-size: .55rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: .67rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td > small, td > strong { display: block; }
td > small { margin-top: 3px; font-size: .53rem; }
.table-date { display: block; font-weight: 750; white-space: nowrap; }
.table-date small { display: block; margin-top: 1px; font-size: .5rem; font-weight: 500; }
.amount-negative { color: var(--pink); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 20px; background: var(--surface-2); font-size: .56rem; white-space: nowrap; }
.pill i, .category-bars i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }

.calendar-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.calendar-toolbar p:last-child { margin-bottom: 0; font-size: .68rem; }
.calendar-card { padding: 0 !important; overflow-x: auto; }
.calendar-weekdays, .calendar-grid { display: grid; min-width: 760px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.calendar-weekdays span { padding: 10px; color: var(--muted); font-size: .56rem; font-weight: 800; text-align: center; text-transform: uppercase; }
.calendar-day { min-height: 125px; padding: 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.blank { background: rgba(0, 0, 0, .06); }
.day-number { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; color: var(--muted); font-size: .62rem; font-weight: 800; }
.calendar-day.today .day-number { color: #fff; background: var(--purple); box-shadow: 0 0 15px rgba(139, 92, 246, .36); }
.calendar-event { display: flex; align-items: flex-start; gap: 5px; margin-top: 5px; padding: 5px 6px; border-left: 2px solid var(--purple); border-radius: 5px; background: rgba(139, 92, 246, .08); font-size: .53rem; }
.calendar-event.bill { border-color: var(--pink); background: rgba(255, 91, 157, .08); }
.calendar-event.payday { border-color: var(--green); background: rgba(73, 232, 164, .07); }
.calendar-event.deadline { border-color: var(--orange); background: rgba(255, 173, 92, .07); }
.calendar-event > div { min-width: 0; flex: 1; }
.calendar-event strong, .calendar-event small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event button { padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; }

.hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.comparison-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.content-grid .card, .page-content > .card, .calendar-card { padding: 21px; }
.span-2 { grid-column: span 2; }
.category-bars { display: grid; gap: 16px; }
.category-bars p { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 0; font-size: .62rem; }
.category-bars p span { display: flex; align-items: center; gap: 6px; }
.category-bars small { display: block; margin-top: -1px; font-size: .52rem; }

.dead-hero { display: flex; min-height: 195px; align-items: center; justify-content: space-between; gap: 30px; padding: 28px 32px !important; border-color: rgba(139, 92, 246, .18); background: linear-gradient(110deg, rgba(73, 168, 255, .06), rgba(139, 92, 246, .08)), var(--surface); }
.dead-hero > div:first-child { max-width: 650px; }
.dead-hero > div:first-child .metric-icon { margin-bottom: 17px; }
.dead-hero h2 { font-size: 1.4rem; }
.dead-hero p:last-child { margin: 9px 0 0; color: var(--muted); font-size: .72rem; }
.visible-balance, .concealed-balance { min-width: 220px; font-size: 1.9rem; font-weight: 850; letter-spacing: -.05em; text-align: center; }
.concealed-balance { padding: 18px; border: 1px solid rgba(73, 168, 255, .24); border-radius: 14px; color: var(--blue); background: rgba(73, 168, 255, .06); cursor: pointer; }
.concealed-balance .revealed { display: none; }
.concealed-balance.reveal .masked { display: none; }
.concealed-balance.reveal .revealed { display: block; }
.concealed-balance small { display: block; margin-top: 4px; font-size: .52rem; font-weight: 650; letter-spacing: 0; }
.dead-grid { grid-template-columns: repeat(2, 1fr); }
.rule-list { display: grid; gap: 11px; }
.rule-list > div { display: flex; align-items: center; gap: 11px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255, 255, 255, .014); }
.rule-list p, .rule-list strong, .rule-list small { display: block; margin: 0; }
.rule-list strong { font-size: .66rem; }
.rule-list small { margin-top: 2px; font-size: .54rem; }

.settings-grid { display: grid; grid-template-columns: .65fr repeat(2, 1fr); gap: 18px; align-items: start; }
.settings-nav { position: sticky; top: 103px; display: grid; gap: 4px; padding: 17px !important; }
.settings-nav .eyebrow { padding: 0 7px 6px; }
.settings-nav a { padding: 7px; border-radius: 7px; color: var(--muted); font-size: .65rem; font-weight: 700; }
.settings-nav a:hover { color: var(--text); background: var(--surface-2); }
.toggle-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.toggle-card { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255, 255, 255, .014); cursor: pointer; }
.toggle-card span, .toggle-card strong, .toggle-card small { display: block; }
.toggle-card strong { color: var(--text); font-size: .64rem; }
.toggle-card small { margin-top: 2px; font-size: .51rem; font-weight: 500; }
.toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-card i { position: relative; width: 34px; height: 19px; flex: 0 0 34px; border-radius: 20px; background: var(--muted-2); transition: .18s; }
.toggle-card i::after { position: absolute; width: 13px; height: 13px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .18s; content: ""; }
.toggle-card input:checked + i { background: var(--purple); box-shadow: 0 0 13px rgba(139, 92, 246, .26); }
.toggle-card input:checked + i::after { transform: translateX(15px); }
.status-badge { padding: 5px 8px; border-radius: 20px; font-size: .52rem; font-weight: 850; text-transform: uppercase; }
.status-badge.success { color: var(--green); background: rgba(73, 232, 164, .09); }
.status-badge.warning { color: var(--orange); background: rgba(255, 173, 92, .09); }
.sticky-save { position: sticky; bottom: 16px; z-index: 5; width: 100%; }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; }
.setup-secret { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 21px !important; border-color: rgba(73, 232, 164, .27); }
.setup-secret p { margin: 5px 0 0; color: var(--muted); }
.setup-secret > code { padding: 11px 14px; font-size: 1rem; letter-spacing: .11em; }
.setup-secret details { grid-column: 1 / -1; }
.wrap-code { display: block; margin-top: 7px; overflow-wrap: anywhere; }
.category-admin-list { display: grid; gap: 7px; margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--border); }
.category-admin-list form { display: grid; grid-template-columns: auto minmax(130px, 1fr) 46px minmax(120px, .6fr) auto auto; align-items: center; gap: 8px; }
.category-admin-list input { min-height: 35px; }
.category-swatch { width: 9px; height: 32px; border-radius: 6px; background: var(--dot); box-shadow: 0 0 10px color-mix(in srgb, var(--dot), transparent 50%); }

.data-actions { grid-template-columns: repeat(3, 1fr); }
.export-card { display: flex; min-height: 140px; align-items: center; gap: 14px; padding: 19px !important; transition: transform .16s ease, border-color .16s ease; }
.export-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.export-card > div { min-width: 0; flex: 1; }
.export-card small { display: block; margin-top: 6px; font-size: .56rem; }
.export-card b { font-size: 1.1rem; }
.export-icon { display: grid; width: 45px; height: 45px; flex: 0 0 45px; place-items: center; border-radius: 12px; font-size: .68rem; font-weight: 900; }
.export-card.purple .export-icon { color: var(--purple-light); background: rgba(139, 92, 246, .1); }
.export-card.blue .export-icon { color: var(--blue); background: rgba(73, 168, 255, .1); }
.export-card.pink .export-icon { color: var(--pink); background: rgba(255, 91, 157, .1); }
.data-grid { grid-template-columns: repeat(2, 1fr); }
.file-drop { padding: 22px; border: 1px dashed var(--border-strong); border-radius: 11px; text-align: center; cursor: pointer; }
.file-drop input { margin-bottom: 8px; background: transparent; }
.file-drop span { display: block; font-size: .57rem; }
.database-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.database-facts div { padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.database-facts span, .database-facts strong { display: block; }
.database-facts span { color: var(--muted); font-size: .52rem; }
.database-facts strong { margin-top: 3px; font-size: .65rem; }
.portability-note { display: flex; align-items: center; gap: 13px; }
.portability-note p { margin: 3px 0 0; color: var(--muted); font-size: .65rem; }

.auth-body { min-height: 100vh; overflow-x: hidden; background: #080a12; color: #f6f7fb; }
.auth-shell { display: grid; min-height: 100vh; grid-template-columns: 1.08fr .92fr; }
.auth-story { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(30px, 5vw, 68px); background: linear-gradient(90deg, rgba(8, 10, 18, .9), rgba(8, 10, 18, .28)), url("/assets/images/financial-flow.png") center / cover no-repeat; }
.auth-story::before { position: absolute; inset: 0; background: linear-gradient(145deg, rgba(139, 92, 246, .05), transparent 55%); content: ""; }
.auth-story > * { position: relative; z-index: 1; }
.auth-story h1 { max-width: 620px; margin-bottom: 18px; font-size: clamp(2.8rem, 5.5vw, 5.8rem); line-height: .93; letter-spacing: -.07em; }
.auth-story > div:nth-child(2) > p:last-child { max-width: 560px; color: #a5adbe; font-size: .9rem; }
.auth-orbit { position: absolute; width: 320px; height: 320px; right: -60px; bottom: -75px; border: 1px solid rgba(169, 139, 255, .14); border-radius: 50%; }
.auth-orbit span { position: absolute; inset: 35px; border: 1px solid rgba(73, 168, 255, .14); border-radius: 50%; }
.auth-orbit .orbit-two { inset: 78px; border-color: rgba(255, 91, 157, .14); }
.auth-orbit .orbit-three { inset: 120px; border-color: rgba(73, 232, 164, .14); }
.auth-orbit strong { position: absolute; inset: 0; display: grid; place-items: center; color: var(--green); font-size: 2.6rem; text-shadow: 0 0 28px rgba(73, 232, 164, .35); }
.auth-panel { display: grid; place-items: center; padding: 32px; background: #0b0e16; }
.auth-panel .flash { width: min(420px, 100%); margin: 0 0 13px; }
.auth-card { width: min(420px, 100%); padding: 30px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 19px; background: #121621; box-shadow: 0 28px 75px rgba(0, 0, 0, .32); }
.auth-card h2 { margin-bottom: 7px; font-size: 1.55rem; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-card input, .auth-card select { background: #191e2c; }
.otp-input { font-size: 1.45rem; letter-spacing: .38em; text-align: center; }

@media (max-width: 1220px) {
    .metric-grid, .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-layout { grid-template-columns: minmax(0, 1.55fr) minmax(290px, .85fr); }
    .budget-row { grid-template-columns: minmax(160px, .75fr) minmax(180px, 1.1fr) auto; gap: 13px; }
    .hero-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .data-actions { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-grid > .span-2 { grid-column: 1; }
    .settings-nav { position: static; display: flex; overflow-x: auto; }
}

@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 20px 0 70px rgba(0, 0, 0, .42); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 45; border: 0; background: rgba(2, 4, 8, .6); backdrop-filter: blur(2px); }
    .sidebar.open + .sidebar-scrim { display: block; }
    .main { margin-left: 0; }
    .menu-button { display: grid; }
    .dashboard-layout { grid-template-columns: minmax(0, 1fr); }
    .dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-side > * { min-width: 0; }
    .usage-card { grid-column: 1 / -1; }
    .comparison-grid, .content-grid, .dead-grid, .data-grid { grid-template-columns: minmax(0, 1fr); }
    .content-grid > .span-2 { grid-column: 1; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-story { display: none; }
    .auth-panel { min-height: 100vh; }
}

@media (max-width: 760px) {
    .topbar { min-height: 72px; gap: 10px; padding: 13px 15px; }
    .topbar .eyebrow { display: none; }
    .top-action { display: none; }
    .month-switcher input { width: 112px; }
    .page-content { padding: 18px 14px 40px; }
    .flash { margin-left: 14px; margin-right: 14px; }
    .app-footer { margin: 0 14px; }
    .overview-hero { min-height: 390px; grid-template-columns: 1fr; align-content: end; }
    .hero-art { background: linear-gradient(0deg, rgba(8, 12, 20, .99) 0%, rgba(8, 12, 20, .8) 45%, rgba(8, 12, 20, .15) 100%), url("/assets/images/financial-flow.png") 70% center / cover no-repeat; }
    .hero-copy { padding: 25px 23px 15px; }
    .hero-label { margin-top: 18px; }
    .hero-gauge { justify-content: flex-start; padding: 10px 23px 24px; }
    .gauge-ring { width: 86px; height: 86px; flex-basis: 86px; background: radial-gradient(circle 33px, #111522 97%, transparent 100%), conic-gradient(var(--green) var(--angle), rgba(255, 255, 255, .09) 0); }
    .gauge-ring span { font-size: 1rem; }
    .budget-row { grid-template-columns: 1fr auto; }
    .budget-progress { grid-column: 1 / -1; grid-row: 2; }
    .row-actions { grid-column: 2; grid-row: 1; }
    .metric-grid, .summary-grid, .hero-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-side { grid-template-columns: minmax(0, 1fr); }
    .usage-card { grid-column: 1; }
    .page-intro { align-items: flex-start; flex-direction: column; }
    .card-heading { flex-wrap: wrap; }
    .search-box { width: 100%; }
    .form-grid, .toggle-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: 1; }
    .inline-fields { grid-template-columns: 1fr; }
    .category-admin-list form { grid-template-columns: auto 1fr 44px auto auto; }
    .category-admin-list .money-input { grid-column: 2 / 4; }
    .dead-hero { align-items: stretch; flex-direction: column; padding: 23px !important; }
    .visible-balance, .concealed-balance { width: 100%; min-width: 0; }
    .setup-secret { grid-template-columns: 1fr; }
    .setup-secret details { grid-column: 1; }
    .setup-secret > code { overflow-x: auto; }
    .database-facts { grid-template-columns: 1fr; }
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { position: relative; padding: 13px 0; border-bottom: 1px solid var(--border); }
    .data-table tr:last-child { border-bottom: 0; }
    .data-table td { display: grid; grid-template-columns: 105px 1fr; gap: 10px; padding: 5px 0; border: 0; }
    .data-table td::before { color: var(--muted); font-size: .55rem; font-weight: 800; text-transform: uppercase; content: attr(data-label); }
    .data-table td.table-actions { display: flex; position: absolute; top: 10px; right: 0; width: auto; }
    .data-table td.table-actions::before { display: none; }
}

@media (max-width: 520px) {
    .metric-grid, .summary-grid, .hero-grid { grid-template-columns: minmax(0, 1fr); }
    .metric-card { min-height: 130px; }
    .hero-actions { align-items: stretch; flex-direction: column; }
    .hero-actions .button { width: 100%; }
    .hero-gauge { align-items: flex-start; }
    .dialog-card { padding: 18px; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions .button { width: 100%; }
    .settings-actions { align-items: stretch; flex-direction: column; }
    .settings-actions .button { width: 100%; }
    .category-admin-list form { grid-template-columns: auto 1fr auto auto; }
    .category-admin-list input[type="color"] { grid-column: 2; grid-row: 2; }
    .category-admin-list .money-input { grid-column: 2 / -1; }
    .auth-panel { padding: 17px; }
    .auth-card { padding: 23px; }
}
