:root {
    color-scheme: dark;
    --brand-lime: #22c55e;
    --brand-green: #16a34a;
    --brand-navy: #0f172a;
    --brand-gray: #e5e7eb;
    --bg: #121212;
    --surface: #1a1a1a;
    --surface-2: #161616;
    --line: #303030;
    --line-soft: #242424;
    --text: #f3f4f6;
    --muted: #b7bbc2;
    --blue: #38bdf8;
    --green: #22c55e;
    --red: #ef5350;
    --orange: #f59e0b;
    --debt-rest: #64748b;
    --violet: #a78bfa;
    --teal: #22c55e;
    --goal-accent: #ec4899;
    --income-accent: #22c55e;
    --expense-accent: #ef5350;
    --balance-accent: #38bdf8;
    --debt-accent: #a78bfa;
    --obligation-accent: #f59e0b;
    --shadow: 0 18px 50px rgba(0, 0, 0, .24);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light-theme {
    color-scheme: light;
    --bg: #e5e7eb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #cbd5e1;
    --line-soft: #edf2f7;
    --text: #0f172a;
    --muted: #475569;
    --blue: #0369a1;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #d97706;
    --debt-rest: #64748b;
    --violet: #7c3aed;
    --teal: #16a34a;
    --goal-accent: #db2777;
    --shadow: 0 14px 34px rgba(15, 23, 42, .10);
}

body.light-theme .sidebar {
    background: #ffffff;
}

body.light-theme .topbar {
    background: rgba(229, 231, 235, .94);
    backdrop-filter: blur(14px);
}

body.light-theme .brand .brand-mark {
    background: transparent;
    color: #16a34a;
}

body.light-theme .sidebar a:not(.brand) {
    color: #475569;
}

body.light-theme .sidebar a.active {
    color: #16a34a;
    background: #dcfce7;
    box-shadow: inset 3px 0 0 #16a34a;
}

body.light-theme .sidebar a:hover {
    color: #0f172a;
    background: #f0fdf4;
}

body.light-theme .btn,
body.light-theme .theme-toggle,
body.light-theme .icon-button {
    background: #ffffff;
    border-color: #9fceb0;
    color: #16a34a;
}

body.light-theme .btn:hover,
body.light-theme .theme-toggle:hover,
body.light-theme .icon-button:hover {
    background: #f0fdf4;
    border-color: #16a34a;
    box-shadow: 0 10px 24px rgba(22, 163, 74, .16);
}

body.light-theme .metric,
body.light-theme .panel,
body.light-theme .table-card,
body.light-theme .modal,
body.light-theme .user-menu {
    background: #ffffff;
    border-color: #c8d3e1;
}

body.light-theme .metric:hover,
body.light-theme .panel:hover,
body.light-theme .table-card:hover {
    border-color: #8bc99c;
    box-shadow: 0 22px 54px rgba(15, 23, 42, .14);
}

body.light-theme .metric small {
    color: #1f2937;
}

body.light-theme .filters input,
body.light-theme .filters select,
body.light-theme input,
body.light-theme select {
    background: #ffffff;
    color: #111827;
}

body.light-theme .filters input:hover,
body.light-theme .filters select:hover,
body.light-theme .filters input:focus,
body.light-theme .filters select:focus {
    background: #f3fbfa;
}

body.light-theme .grid-line {
    stroke: rgba(71, 85, 105, .28);
}

body.light-theme .axis-label,
body.light-theme .chart-legend,
body.light-theme .muted {
    color: #475569;
    fill: #475569;
}

body.light-theme .pill {
    background: #eef2f7;
    color: #334155;
}

body.light-theme .pill.ok {
    background: #dcfce7;
    color: #166534;
}

body.light-theme .pill.bad {
    background: #fee2e2;
    color: #991b1b;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--teal); text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 1.35rem; font-weight: 760; }
h2 { font-size: 1.08rem; font-weight: 780; }
button, input, select { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes draw-line {
    from { stroke-dashoffset: 780; }
    to { stroke-dashoffset: 0; }
}

@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-lime) 28%, transparent); }
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--teal) 0%, transparent); }
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; width: 238px; flex: 0 0 238px; background: var(--surface-2); border-right: 1px solid var(--line); color: var(--text); padding: 15px 11px; position: sticky; top: 0; height: 100vh; overflow: hidden; z-index: 30; animation: fade-in .35s ease both; transition: width .22s ease, flex-basis .22s ease, padding .22s ease, transform .22s ease; }
.sidebar-overlay { display: none; }
.sidebar-head { display: flex; align-items: flex-start; gap: 8px; padding-bottom: 13px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.brand { flex: 1; display: flex; align-items: center; color: var(--text); padding: 0 9px; }
.brand .brand-mark { display: flex; align-items: center; gap: 8px; border-radius: 14px; background: transparent; box-shadow: none; overflow: visible; padding: 0;align-items: flex-end; }
.brand .brand-mark img { display: block; object-fit: contain; object-position: center; background: transparent; }
.brand .brand-mark .theme-logo-favicon { width: 40px; flex: 0 0 24px; }
.brand .brand-mark .theme-logo-dash { height: 40px; width: auto; max-width: 150px; flex: 0 0 auto; }
body.sidebar-collapsed .brand .brand-mark .theme-logo-dash { display: none; }
body.sidebar-collapsed .brand .brand-mark { gap: 0; }
body.sidebar-collapsed .brand { justify-content: center; padding: 0; }
.brand strong { line-height: 1; font-size: 1.02rem; }
.brand strong em { color: var(--brand-lime); font-style: normal; }
.brand small { color: var(--muted); font-size: .62rem; font-weight: 650; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close {
    display: inline-flex !important;
    position: absolute !important;
    top: 54px !important;
    right: 0px !important;
    width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    border-radius: 999px !important;
    background: transparent !important;
    box-shadow: var(--shadow) !important;
    z-index: 99994 !important;
    border: none !important;
}
.sidebar nav { display: grid; gap: 6px; overflow: auto; padding-bottom: 18px; }

.sidebar-foot { margin-top: auto; }
.sidebar-foot > div { border-top: 1px solid var(--line); }
.nav-heading { margin: 15px 10px 5px; color: var(--text); font-size: .74rem; font-weight: 680; }
.sidebar a:not(.brand) { position: relative; display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 11px 13px; border-radius: 12px; font-weight: 650; transition: color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease; }
.sidebar a.active { color: var(--brand-lime); background: rgba(34, 197, 94, .16); box-shadow: inset 3px 0 0 var(--brand-lime); }
.sidebar a:hover { transform: translateX(3px); }
.app-icon, .ui-icon, [data-lucide] { width: 18px; height: 18px; display: inline-block; flex: 0 0 18px; color: currentColor; position: relative; }
[data-lucide] { stroke-width: 2; }
.app-icon::before, .app-icon::after, .ui-icon::before, .ui-icon::after { content: ""; position: absolute; box-sizing: border-box; }
.icon-dashboard::before { left: 2px; top: 3px; width: 6px; height: 12px; border-radius: 2px; background: currentColor; box-shadow: 8px -1px 0 -1px currentColor, 8px 7px 0 -1px currentColor; }
.icon-expense::before { left: 3px; right: 3px; bottom: 2px; height: 11px; border: 2px solid currentColor; border-radius: 3px; }
.icon-expense::after { left: 5px; top: 2px; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.icon-transaction::before { left: 2px; right: 2px; top: 4px; height: 10px; border: 2px solid currentColor; border-radius: 999px; }
.icon-transaction::after { left: 5px; top: 8px; width: 8px; height: 2px; background: currentColor; box-shadow: 0 -4px 0 -1px currentColor, 0 4px 0 -1px currentColor; }
.icon-category::before { left: 2px; top: 3px; width: 7px; height: 7px; border-radius: 2px; background: currentColor; box-shadow: 9px 0 0 currentColor, 0 9px 0 currentColor; }
.icon-category::after { right: 2px; bottom: 2px; width: 7px; height: 7px; border-radius: 50%; border: 2px solid currentColor; }
.icon-history::before { inset: 2px; border: 2px solid currentColor; border-left-color: transparent; border-radius: 50%; }
.icon-history::after { left: 1px; top: 5px; width: 6px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.icon-obligation::before { left: 3px; top: 2px; width: 12px; height: 14px; border: 2px solid currentColor; border-radius: 2px; }
.icon-obligation::after { left: 6px; top: 6px; width: 7px; height: 2px; background: currentColor; box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor; }
.icon-debt::before { left: 2px; right: 2px; bottom: 3px; height: 8px; border: 2px solid currentColor; border-radius: 2px; }
.icon-debt::after { left: 4px; top: 2px; width: 10px; height: 7px; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.icon-goal::before { left: 2px; right: 2px; bottom: 3px; height: 10px; border: 2px solid currentColor; border-radius: 6px 6px 3px 3px; }
.icon-goal::after { right: 2px; top: 1px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: -9px 5px 0 -3px currentColor; }
.icon-settings::before { inset: 2px; border: 3px dotted currentColor; border-radius: 50%; }
.icon-settings::after { inset: 6px; border: 2px solid currentColor; border-radius: 50%; background: var(--surface-2); }
.icon-income::before { left: 3px; top: 10px; width: 12px; height: 2px; background: currentColor; transform: rotate(-35deg); }
.icon-income::after { right: 2px; top: 4px; width: 7px; height: 7px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; }
.icon-plus::before { left: 3px; top: 8px; width: 12px; height: 2px; background: currentColor; }
.icon-plus::after { left: 8px; top: 3px; width: 2px; height: 12px; background: currentColor; }
.icon-logout::before { left: 2px; top: 3px; width: 9px; height: 12px; border: 2px solid currentColor; border-right: 0; }
.icon-logout::after { right: 1px; top: 7px; width: 10px; height: 5px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); }
.ui-icon.menu::before { left: 2px; right: 2px; top: 4px; height: 2px; background: currentColor; box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor; }
.ui-icon.close::before, .ui-icon.close::after { left: 2px; top: 8px; width: 14px; height: 2px; background: currentColor; }
.ui-icon.close::before { transform: rotate(45deg); }
.ui-icon.close::after { transform: rotate(-45deg); }
body.sidebar-collapsed .ui-icon.close::before { transform: rotate(0deg); width: 12px; left: 2px; }
body.sidebar-collapsed .ui-icon.close::after { transform: rotate(45deg); width: 8px; left: 8px; top: 6px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; background: transparent; }
.ui-icon.theme::before { inset: 3px; border: 2px solid currentColor; border-radius: 50%; box-shadow: 0 -7px 0 -5px currentColor, 0 7px 0 -5px currentColor, 7px 0 0 -5px currentColor, -7px 0 0 -5px currentColor; }
body.light-theme .ui-icon.theme::before { inset: 2px; border-radius: 50%; background: currentColor; box-shadow: none; }
body.light-theme .ui-icon.theme::after { right: 1px; top: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); }

.main { flex: 1; min-width: 0; padding: 0 24px 24px; }
body.sidebar-collapsed .sidebar { width: 76px; flex-basis: 76px; padding-inline: 10px; overflow: visible; }
body.sidebar-collapsed .sidebar-head { justify-content: center; padding-bottom: 12px; }
body.sidebar-collapsed .brand { grid-template-columns: 1fr; padding: 0; justify-items: center; }
body.sidebar-collapsed .brand .brand-mark { grid-row: auto; width: 42px; height: 42px; }
body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .brand small,
body.sidebar-collapsed .nav-heading { display: none; }
body.sidebar-collapsed .sidebar nav { gap: 8px; margin-top: 22px; }
body.sidebar-collapsed .sidebar a:not(.brand) { justify-content: center; padding: 13px 0; gap: 0; font-size: 0; }
body.sidebar-collapsed .sidebar a:not(.brand) .app-icon { width: 20px; height: 20px; }
body.sidebar-collapsed .sidebar a:not(.brand)::after {
    content: attr(aria-label);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 10px;
    box-shadow: var(--shadow);
    font-size: .82rem;
    transition: opacity .16s ease, transform .16s ease;
    z-index: 60;
}
body.sidebar-collapsed .sidebar a:not(.brand):hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
.topbar { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 -24px 22px; padding: 10px 24px; background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; animation: fade-in .3s ease both; }
.top-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-title-copy { min-width: 0; }
.mobile-brand { display: none; align-items: center; }
.mobile-brand img { height: 32px; width: auto; max-width: 120px; object-fit: contain; }
.top-actions, .filters, .quick-actions, .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.filters .filter-control { min-width: 132px; color: var(--muted); font-size: .72rem; gap: 0; position: relative; }
.filters .filter-control::after { content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--teal); border-bottom: 2px solid var(--teal); transform: translateY(-65%) rotate(45deg); pointer-events: none; opacity: .9; }
.filters .filter-control:has(input[type="month"])::after { display: none; }
.filters input, .filters select { min-height: 40px; background: color-mix(in srgb, var(--surface) 72%, transparent); border-color: color-mix(in srgb, var(--line) 78%, var(--teal)); border-radius: 10px; color: var(--text); font-weight: 650; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease; }
.filters select { appearance: none; padding-right: 34px; }
.filters input:hover, .filters select:hover, .filters input:focus, .filters select:focus { border-color: var(--teal); background: color-mix(in srgb, var(--surface) 90%, var(--teal) 8%); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent); outline: 0; transform: translateY(-1px); }
.eyebrow { margin: 4px 0 0; color: var(--muted); font-size: .78rem; font-weight: 650; text-transform: none; letter-spacing: 0; }
.muted { color: var(--muted); }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface); animation: rise-in .28s ease both; }
.alert-success { border-color: rgba(34, 197, 94, .35); color: #6ee7b7; }
.alert-error { border-color: rgba(239, 83, 80, .4); color: #fca5a5; }

.btn, .theme-toggle, .avatar, .icon-button { border: 1px solid rgba(34, 197, 94, .48); background: rgba(34, 197, 94, .05); color: var(--brand-lime); border-radius: 8px; padding: 7px 11px; font-weight: 640; cursor: pointer; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.btn:hover, .theme-toggle:hover, .icon-button:hover { background: rgba(34, 197, 94, .13); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .16); }
.btn:active, .theme-toggle:active, .avatar:active, .icon-button:active { transform: translateY(0) scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--brand-lime), var(--brand-green)); color: #04111d; border-color: var(--brand-lime); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 8px; min-height: 29px; font-size: .8rem; }
.btn.danger { color: #fca5a5; border-color: rgba(239, 83, 80, .5); }
.theme-toggle, .avatar, .icon-button { width: 38px; padding: 0; border-color: var(--line); color: var(--text); background: var(--surface); }
.avatar { border-radius: 8px; border-color: var(--line);
    color: var(--text);
    background: var(--surface);}
.avatar [data-lucide] { width: 19px; height: 19px; stroke-width: 2.3; }
.mobile-menu-button { display: none; flex: 0 0 40px; }
.user-menu-wrap { position: relative; }
.user-menu { position: absolute; right: 0; top: calc(100% + 10px); width: 240px; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 22px 70px rgba(0, 0, 0, .35); padding: 8px; z-index: 40; }
.user-menu.open { display: grid; gap: 4px; animation: rise-in .18s ease both; transform-origin: top right; }
.user-menu-head { padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu-head strong, .user-menu-head span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-head span { margin-top: 3px; color: var(--muted); font-size: .8rem; }
.user-menu a, .user-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-weight: 650; }
.user-menu a:hover, .user-menu button:hover { background: rgba(34, 197, 94, .12); color: var(--brand-lime); }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; margin-bottom: 20px; }
.metric, .panel, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); animation: rise-in .42s ease both; transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease, background .22s ease; }
.metric:hover, .panel:hover, .table-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand-lime) 35%, var(--line)); box-shadow: 0 24px 70px rgba(0, 0, 0, .3); }
.metric-grid .metric:nth-child(1) { animation-delay: .02s; }
.metric-grid .metric:nth-child(2) { animation-delay: .06s; }
.metric-grid .metric:nth-child(3) { animation-delay: .1s; }
.metric-grid .metric:nth-child(4) { animation-delay: .14s; }
.metric-grid .metric:nth-child(5) { animation-delay: .18s; }
.metric-grid .metric:nth-child(6) { animation-delay: .22s; }
.dashboard-grid .panel:nth-child(1) { animation-delay: .12s; }
.dashboard-grid .panel:nth-child(2) { animation-delay: .16s; }
.dashboard-grid .panel:nth-child(3) { animation-delay: .2s; }
.dashboard-grid .panel:nth-child(4) { animation-delay: .24s; }
.dashboard-grid .panel:nth-child(5) { animation-delay: .28s; }
.metric { min-height: 144px; padding: 18px; display: grid; grid-template-columns: 1fr 42px; grid-template-rows: 1fr auto; gap: 12px; align-items: start; }
.metric span, .metric small { color: var(--muted); font-weight: 600; }
.metric strong { display: block; margin-top: 8px; font-size: 1.13rem; font-weight: 760; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { grid-column: 1 / 3; display: flex; justify-content: space-between; padding: 9px 10px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--tone, var(--blue)) 34%, transparent); background: color-mix(in srgb, var(--tone, var(--blue)) 12%, transparent); }
.metric-icon { width: 42px; height: 42px; border-radius: 14px; background: color-mix(in srgb, var(--tone, var(--blue)) 82%, #111); color: #fff; position: relative; display: grid; place-items: center; transition: transform .22s ease; box-shadow: inset 0 -10px 20px rgba(0, 0, 0, .12); }
.metric-icon [data-lucide] { width: 21px; height: 21px; }
.metric:hover .metric-icon { transform: rotate(-4deg) scale(1.06); }
.metric-icon::before, .metric-icon::after { content: none; }
.metric-icon-trend::after, .metric-icon-income::after { left: 12px; top: 22px; width: 17px; height: 2px; background: #fff; transform: rotate(-38deg); border-radius: 999px; }
.metric-icon-trend::before, .metric-icon-income::before { right: 10px; top: 12px; width: 9px; height: 9px; border-top: 3px solid #fff; border-right: 3px solid #fff; }
.metric-icon-expense::before { left: 12px; top: 10px; width: 18px; height: 22px; border: 3px solid #fff; border-radius: 5px; }
.metric-icon-expense::after { left: 16px; top: 15px; width: 10px; height: 10px; border-left: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(-45deg); }
.metric-icon-wallet::before { left: 9px; top: 13px; width: 24px; height: 17px; border: 3px solid #fff; border-radius: 6px; }
.metric-icon-wallet::after { right: 9px; top: 18px; width: 8px; height: 7px; border: 3px solid #fff; border-radius: 4px; background: var(--tone, var(--blue)); }
.metric-icon-debt::before { left: 9px; bottom: 10px; width: 24px; height: 13px; border: 3px solid #fff; border-radius: 4px; }
.metric-icon-debt::after { left: 13px; top: 8px; width: 16px; height: 11px; background: #fff; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.metric-icon-calendar::before { left: 10px; top: 10px; width: 22px; height: 23px; border: 3px solid #fff; border-radius: 5px; }
.metric-icon-calendar::after { left: 15px; top: 18px; width: 4px; height: 4px; background: #fff; border-radius: 1px; box-shadow: 7px 0 0 #fff, 0 7px 0 #fff, 7px 7px 0 #fff; }
.metric-icon-goal::before { left: 9px; bottom: 10px; width: 24px; height: 16px; border: 3px solid #fff; border-radius: 10px 10px 5px 5px; }
.metric-icon-goal::after { right: 8px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: -15px 9px 0 -5px #fff; }
.metric.green { --tone: var(--income-accent); }
.metric.red { --tone: var(--expense-accent); }
.metric.orange { --tone: var(--obligation-accent); }
.metric.violet { --tone: var(--debt-accent); }
.metric.teal { --tone: var(--goal-accent); }
.metric.blue { --tone: var(--balance-accent); }

.dashboard-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.span-2 { grid-column: span 3; }
.panel, .table-card { padding: 24px; margin-bottom: 0; overflow: auto; }
.dashboard-grid > .panel:nth-child(n + 3) { grid-column: span 2; min-height: 212px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head > [data-lucide] { color: var(--brand-lime); width: 20px; height: 20px; }
.panel-icon { width: 20px; height: 20px; display: inline-block; color: var(--teal); position: relative; transition: transform .22s ease; }
.panel-icon::before, .panel-icon::after { content: ""; position: absolute; box-sizing: border-box; }
.panel-icon::before { left: 2px; top: 12px; width: 5px; height: 2px; background: currentColor; box-shadow: 5px -4px 0 currentColor, 10px -9px 0 currentColor; border-radius: 999px; }
.panel-icon::after { right: 2px; top: 2px; width: 8px; height: 8px; border-top: 3px solid currentColor; border-right: 3px solid currentColor; }
.panel:hover .panel-icon { transform: translate(2px, -2px); }
.panel-icon.bars::before { left: 3px; bottom: 3px; top: auto; width: 4px; height: 11px; border-radius: 999px; background: currentColor; box-shadow: 6px -5px 0 currentColor, 12px -2px 0 currentColor; }
.panel-icon.bars::after { display: none; }
.panel-icon.calendar::before { inset: 2px; border: 2px solid currentColor; border-radius: 4px; background: transparent; box-shadow: none; }
.panel-icon.calendar::after { left: 6px; top: 8px; width: 3px; height: 3px; background: currentColor; border: 0; border-radius: 1px; box-shadow: 5px 0 0 currentColor, 0 5px 0 currentColor, 5px 5px 0 currentColor; }
.panel-icon.shapes::before { left: 2px; top: 7px; width: 8px; height: 8px; background: currentColor; transform: rotate(45deg); box-shadow: none; }
.panel-icon.shapes::after { right: 1px; bottom: 2px; width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; }
.panel-icon.pig::before { left: 2px; right: 2px; bottom: 3px; top: auto; height: 11px; border: 2px solid currentColor; border-radius: 8px 8px 4px 4px; background: transparent; box-shadow: none; }
.panel-icon.pig::after { right: 1px; top: 2px; width: 7px; height: 7px; border: 0; border-radius: 50%; background: currentColor; box-shadow: -11px 7px 0 -4px currentColor; }

.chart-wrap { width: 100%; }
.chartjs-wrap { position: relative; min-height: 360px; }
.chartjs-canvas { width: 100% !important; height: 340px !important; display: block; }
.line-chart { width: 100%; height: 330px; display: block; overflow: visible; }
.grid-line { stroke: color-mix(in srgb, var(--muted) 24%, transparent); stroke-width: 1; stroke-dasharray: 3 4; }
.grid-line.vertical { opacity: .55; }
.axis-label { fill: var(--muted); font-size: 12px; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 780; animation: draw-line 1.15s ease both; }
.chart-point { fill: var(--surface); stroke-width: 3; cursor: pointer; opacity: .92; transition: r .18s ease, fill .18s ease, filter .18s ease; }
.chart-point:hover, .chart-point:focus { r: 7; fill: var(--text); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .24)); outline: 0; }
.chart-line.green, .chart-legend .green::before { stroke: var(--green); background: var(--green); }
.chart-point.green { stroke: var(--green); }
.chart-line.red, .chart-legend .red::before { stroke: var(--red); background: var(--red); }
.chart-point.red { stroke: var(--red); }
.chart-line.orange, .chart-legend .orange::before { stroke: var(--orange); background: var(--orange); }
.chart-point.orange { stroke: var(--orange); }
.chart-legend .debt-rest::before { background: var(--debt-rest); }
.chart-line.violet, .chart-legend .violet::before { stroke: var(--violet); background: var(--violet); }
.chart-point.violet { stroke: var(--violet); }
.chart-line.teal, .chart-legend .teal::before { stroke: var(--brand-green); background: var(--brand-green); }
.chart-point.teal { stroke: var(--brand-green); }
.chart-line.blue, .chart-legend .blue::before { stroke: var(--blue); background: var(--blue); }
.chart-point.blue { stroke: var(--blue); }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 13px; color: var(--muted); margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend span::before { content: ""; width: 14px; height: 4px; border-radius: 999px; }
.has-tooltip { position: relative; }
.has-tooltip:not(.donut-chart)::after,
.donut-chart.has-tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    width: max-content;
    max-width: min(270px, 80vw);
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    pointer-events: none;
    z-index: 80;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: .76rem;
    font-weight: 650;
    line-height: 1.25;
    white-space: normal;
    transition: opacity .16s ease, transform .16s ease;
}
.has-tooltip:not(.donut-chart):hover::after,
.has-tooltip:not(.donut-chart):focus-within::after,
.donut-chart.has-tooltip:hover::before { opacity: 1; transform: translateX(-50%) translateY(0); }
.debt-bars { display: grid; gap: 12px; min-height: 330px; align-content: start; }
.debt-bar-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-weight: 650;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--brand-lime) 58%, transparent);
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.debt-bar-row:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand-lime) 28%, var(--line));
    background: color-mix(in srgb, var(--surface-2) 72%, var(--brand-lime) 5%);
}
.debt-bar-row strong { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt-bar-row small { display: block; margin-top: 3px; font-size: .76rem; color: var(--muted); }
.debt-name { min-width: 0; }
.debt-title-line { min-width: 0; display: flex; align-items: center; gap: 8px; }
.debt-title-line strong { flex: 1; min-width: 0; }
.debt-stack-wrap { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 12px; min-width: 0; }
.debt-stack-box { position: relative; min-width: 0; padding-top: 16px; }
.debt-stack { display: flex; height: 30px; border-radius: 999px; overflow: hidden; background: var(--line-soft); }
.debt-stack .paid,
.debt-stack .remaining {
    transition: width .65s cubic-bezier(.2, .7, .2, 1);
    position: relative;
    display: grid;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}
.debt-stack .compact { min-width: 8px; }
.debt-stack .paid { background: var(--green); color: #04111d; }
.debt-stack .remaining { background: #4242428e; color: #fff; }
.debt-stack span {
    padding: 0 9px;
    font-size: .72rem;
    font-weight: 720;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .24);
}
.debt-floating-value {
    position: absolute;
    top: 0;
    max-width: 124px;
    transform: translateX(-50%);
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: .69rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
    z-index: 2;
}
.debt-floating-value.remaining-value { transform: translateX(50%); color: var(--debt-rest); }
.debt-floating-value.paid-value { color: var(--green); }
.chart-empty { min-height: 245px; display: grid; place-items: center; color: var(--muted); }

.list { display: grid; gap: 10px; }
.list.compact { margin-top: 12px; }
.list-item, .progress-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); transition: transform .18s ease, background .18s ease, padding .18s ease; }
.list-item small { display: block; color: var(--muted); margin-top: 3px; }
.separated-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--brand-lime) 58%, transparent);
    padding: 12px 14px 12px 16px;
    transition: transform .18s ease, background .18s ease, padding .18s ease;
}
.list-item.separated-item,
.goal-progress-item.separated-item {
    border-bottom: 1px solid var(--line);
}
.list-item.separated-item:hover,
.goal-progress-item.separated-item:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand-lime) 28%, var(--line));
    background: color-mix(in srgb, var(--surface-2) 72%, var(--brand-lime) 5%);
}
.donut-report { min-height: 150px; display: grid; justify-items: center; gap: 16px; }
.donut-chart-shell { width: min(230px, 100%); aspect-ratio: 1; display: grid; place-items: center; position: relative; animation: rise-in .36s ease both; }
.category-donut-canvas { width: 100% !important; height: 100% !important; display: block; filter: drop-shadow(0 18px 34px rgba(0, 0, 0, .18)); }
.donut-chart-shell span { position: absolute; z-index: 1; width: 104px; color: var(--text); font-size: .9rem; font-weight: 720; text-align: center; line-height: 1.1; overflow-wrap: anywhere; pointer-events: none; }
.donut-list { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-width: 0; }
.donut-item { max-width: 100%; display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--surface-2) 82%, transparent); cursor: default; }
.donut-item span { min-width: 0; max-width: 120px; color: var(--text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-item span::before { content: ""; width: 9px; height: 9px; display: inline-block; margin-right: 7px; border-radius: 999px; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent); }
.donut-item strong { color: var(--teal); font-size: .8rem; }
.donut-item small { color: var(--muted); font-size: .78rem; font-weight: 560; white-space: nowrap; }
.right { display: grid; justify-items: end; gap: 5px; }
.pill { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 999px; background: var(--line-soft); color: var(--muted); font-size: .77rem; font-weight: 650; }
.debt-status { flex: 0 0 auto; justify-content: center; white-space: nowrap; font-size: .68rem; min-height: 21px; padding-inline: 7px; }
.pill.ok { background: rgba(34, 197, 94, .18); color: #86efac; }
.pill.bad { background: rgba(239, 83, 80, .18); color: #fca5a5; }
.meter { height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-green), var(--brand-lime)); transition: width .75s cubic-bezier(.2, .7, .2, 1); }
.table-meter { width: min(220px, 100%); margin: 8px 0 4px; }
.goal-progress-item {
    display: grid;
    gap: 7px;
    padding: 12px 14px 12px 16px;
    border-bottom: 1px solid var(--line);
}
.goal-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.goal-progress-head span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}
.goal-progress-head strong {
    color: var(--brand-lime);
    font-size: .9rem;
}
.goal-progress-bar {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--line-soft);
}
.goal-progress-bar span {
    display: block;
    height: 100%;
    min-width: 4px;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-green), var(--brand-lime));
    transition: width .75s cubic-bezier(.2, .7, .2, 1);
}
.goal-progress-item small {
    color: var(--muted);
    font-weight: 750;
}
.obligations-list {
    display: grid;
    gap: 12px;
}
.obligation-card {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(160px, .8fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
    box-shadow: inset 3px 0 0 color-mix(in srgb, var(--brand-lime) 58%, transparent);
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.obligation-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand-lime) 28%, var(--line));
    background: color-mix(in srgb, var(--surface-2) 72%, var(--brand-lime) 5%);
}
.obligation-main {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.obligation-main h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 680;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.obligation-meta {
    min-width: 0;
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: .82rem;
}
.obligation-meta strong {
    color: var(--text);
    font-size: .98rem;
    font-weight: 720;
}
.obligation-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.obligation-actions form {
    display: inline-flex;
}
.goals-list {
    display: grid;
    gap: 12px;
}
.goal-card {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(220px, .9fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-2) 82%, transparent);
}
.goal-card h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 680;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.goal-card-main {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.goal-card-progress {
    min-width: 0;
    display: grid;
    gap: 7px;
}
.goal-card-progress .goal-progress-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
    gap: 8px;
    font-size: .82rem;
}
.goal-card-progress .goal-progress-head span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.goal-card-progress .goal-progress-head span:last-child {
    text-align: right;
}
.goal-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.goal-card-actions form {
    display: inline-flex;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.form-stack { display: grid; gap: 12px; }
.form-grid .btn, .form-stack .btn { justify-self: start; height: 32px; min-height: 32px; padding: 0 10px; font-size: .86rem; line-height: 32px; }
.page-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-bottom: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 600; font-size: .85rem; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; min-height: 37px; padding: 7px 10px; background: var(--surface-2); color: var(--text); transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
input:focus, select:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent); }
summary { cursor: pointer; font-weight: 700; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tbody tr { transition: background .18s ease, transform .18s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--teal) 5%, transparent); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 650; }
.num { text-align: right; }
.negative { color: #fca5a5; }
.actions form { display: inline-flex; }
.modal { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 16px; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 22px 70px rgba(0, 0, 0, .45); animation: rise-in .2s ease both; }
.modal-narrow { width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(18, 18, 18, .78); backdrop-filter: blur(2px); }
.modal-close { position: absolute; right: 12px; top: 10px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--muted); }
.hidden { display: none !important; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at 18% 18%, rgba(34, 197, 94, .18), transparent 28%),
        linear-gradient(135deg, #101010, #171717 48%, #121212);
}
.auth-shell {
    width: min(920px, 100%);
    min-height: min(560px, calc(100vh - 44px));
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(340px, .82fr);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .42);
    animation: rise-in .42s ease both;
}
.auth-hero {
    position: relative;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 24px;
    min-height: 100%;
    padding: 34px;
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, .22), transparent 32%),
        linear-gradient(160deg, #181818, #101010);
    border-right: 1px solid var(--line);
}
.auth-hero::after {
    content: "";
    position: absolute;
    inset: auto 34px 96px 34px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 197, 94, .7), transparent);
    opacity: .7;
}
.auth-logo {
    width: min(245px, 78%);
    filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .25));
    animation: fade-in .5s ease both;
}
.auth-hero-copy {
    max-width: 390px;
    display: grid;
    justify-items: center;
    gap: 10px;
    text-align: center;
    animation: rise-in .5s ease .08s both;
}
.auth-hero-copy h1 {
    max-width: 24ch;
    font-size: clamp(1.15rem, 2.5vw, 1.55rem);
    line-height: 1.12;
    font-weight: 660;
}
.auth-hero-copy p:last-child {
    max-width: 360px;
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.5;
}
.auth-highlights {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(420px, 100%);
    gap: 10px;
    animation: rise-in .5s ease .16s both;
}
.auth-highlights span {
    min-width: 0;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 7px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-size: .66rem;
    font-weight: 650;
    letter-spacing: .03em;
    text-align: center;
    text-transform: uppercase;
}
.auth-highlights i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--brand-navy);
}
.auth-highlights svg {
    width: 40px;
    height: 40px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.auth-highlights svg .accent {
    stroke: var(--brand-lime);
}
body:not(.light-theme) .auth-highlights i {
    color: #e5e7eb;
}
body:not(.light-theme) .auth-highlights svg .accent {
    stroke: #4ade80;
}
body.light-theme .auth-highlights i {
    color: #0f172a;
}
body.light-theme .auth-highlights span {
    color: #0f172a;
}
body.light-theme .auth-highlights svg .accent {
    stroke: #22c55e;
}
/*
    Legacy auth highlight support retained for simple text-only items.
*/
.auth-highlights .legacy-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .03);
    color: var(--muted);
    font-size: .82rem;
}
.auth-highlights .legacy-chip strong {
    color: var(--brand-lime);
    font-weight: 680;
}
.auth-panel {
    display: grid;
    align-content: center;
    justify-items: stretch;
    gap: 18px;
    padding: clamp(24px, 4vw, 38px);
    background: var(--surface);
}
.auth-form-head {
    display: grid;
    gap: 20px;
}
.auth-form-head h2 {
    margin-top: 4px;
    font-size: 1.85rem;
    font-weight: 720;
}
.auth-form-head .muted {
    margin: 8px 0 0;
    line-height: 1.5;
}
.auth-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}
.auth-switch a {
    min-height: 36px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 650;
    transition: color .18s ease, background .18s ease, transform .18s ease;
}
.auth-switch a:hover {
    color: var(--text);
}
.auth-switch a.active {
    color: #04111d;
    background: linear-gradient(135deg, var(--brand-lime), var(--brand-green));
    box-shadow: 0 10px 26px rgba(34, 197, 94, .22);
}
.auth-form {
    animation: rise-in .28s ease both;
}
.auth-form .btn {
    width: 100%;
    min-height: 40px;
    margin-top: 4px;
}
.auth-footnote {
    margin: 0;
    color: var(--muted);
    text-align: center;
    font-size: .9rem;
}
.auth-footnote a {
    font-weight: 650;
}
/* Solo escritorio */
@media (min-width: 901px) {

    .donut-report{
        display:flex;
        align-items:center;
        justify-content:space-between;
        gap:32px;
        min-height:340px;
    }

    .donut-chart-shell{
        width:320px;
        height:320px;
        flex-shrink:0;
    }

    .donut-list{
        flex:1;
        display:flex;
        flex-direction:column;
        justify-content:center;
        gap:10px;
    }

    .donut-item{
        width:100%;
        justify-content:space-between;
    }

}
@media (max-width: 1320px) {
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .span-2, .dashboard-grid > .panel:nth-child(n + 3) { grid-column: span 1; }
    .obligation-card { grid-template-columns: 1fr; align-items: stretch; }
    .obligation-actions { justify-content: flex-start; }
    .goal-card { grid-template-columns: 1fr; align-items: stretch; }
    .goal-card-actions { justify-content: flex-start; }
}

@media (max-width: 900px) {
    .auth-body { padding: 14px; }
    .auth-shell {
        min-height: 0;
        grid-template-columns: 1fr;
        border-radius: 18px;
    }
    .auth-hero {
        min-height: 260px;
        padding: 26px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .auth-hero::after { inset: auto 26px 92px 26px; }
    .auth-logo { width: min(220px, 78%); }
    .auth-highlights { grid-template-columns: repeat(5, minmax(54px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 2px; }
    .auth-highlights span { font-size: .66rem; }
    .auth-highlights i { width: 40px; height: 40px; }
    .auth-highlights svg { width: 38px; height: 38px; }
    .auth-hero-copy h1 {
        max-width: none;
        font-size: clamp(1.15rem, 5vw, 1.55rem);
    }
    .auth-panel { padding: 26px; }
    .app-shell { display: block; }
    .sidebar,
    body.sidebar-collapsed .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(84vw, 310px); height: 100dvh; flex-basis: auto; padding: 15px 11px; border-right: 1px solid var(--line); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 24px 0 80px rgba(0, 0, 0, .35); overflow-y: auto; }
    body.menu-open .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(18, 18, 18, .66); opacity: 0; pointer-events: none; transition: opacity .22s ease; z-index: 20; }
    body.menu-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
    .sidebar-close, .mobile-menu-button { display: inline-flex; }
    body.sidebar-collapsed .sidebar-head,
    .sidebar-head { justify-content: initial; padding-bottom: 10px; }
    body.sidebar-collapsed .brand,
    .brand { grid-template-columns: 38px 1fr; justify-items: initial; }
    body.sidebar-collapsed .brand .brand-mark { width: 38px; height: 38px; }
    body.sidebar-collapsed .brand strong,
    body.sidebar-collapsed .brand small,
    body.sidebar-collapsed .nav-heading { display: block; }
    .sidebar-close { position: static; width: 40px; height: 40px; min-height: 38px; border-radius: 8px; box-shadow: none; }
    body.sidebar-collapsed .sidebar nav,
    .sidebar nav { grid-template-columns: 1fr; gap: 6px; margin-top: 0; }
    .nav-heading { grid-column: auto; }
    body.sidebar-collapsed .sidebar a:not(.brand),
    .sidebar a:not(.brand) { justify-content: flex-start; padding: 12px 13px; gap: 12px; font-size: .95rem; }
    body.sidebar-collapsed .sidebar a:not(.brand)::after { display: none; }
    .main { padding: 0 14px 92px; }
    .topbar {
        min-height: 64px;
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) 42px;
        gap: 10px;
        margin: 0 -14px 16px;
        padding: 10px 14px;
        align-items: center;
        position: sticky;
    }
    .top-title { display: contents; }
    .mobile-menu-button { grid-column: 1; grid-row: 1; }
    .top-title-copy { display: none; }
    .mobile-brand { grid-column: 2; grid-row: 1; display: inline-flex; justify-self: center; justify-content: center; min-width: 0; }
    .mobile-brand img { height: 34px; max-width: min(172px, 52vw); }
    .top-title h1 { font-size: 1.18rem; }
    .top-actions { display: contents; }
    .top-actions > .filters {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        justify-content: center;
        margin-top: 4px;
    }
    .user-menu-wrap { grid-column: 3; grid-row: 1; justify-self: end; }
    .user-menu { right: 0; left: auto; width: min(260px, calc(100vw - 28px)); }
    .quick-actions {
        position: fixed;
        left: 0px;
        right: 0px;
        bottom: 0px;
        z-index: 70;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
        padding: 10px 12px;
        border: 1px solid var(--line);
        background: #121212;
        box-shadow: 0 18px 46px rgba(0, 0, 0, .38);
        backdrop-filter: blur(14px);
    }
    .quick-actions .btn {
        min-width: 0;
        min-height: 46px;
        flex-direction: column;
        gap: 3px;
        padding: 6px 4px;
        font-size: .68rem;
        line-height: 1;
    }
    .quick-actions .btn [data-lucide] {
        width: 17px;
        height: 17px;
    }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid, .form-grid { grid-template-columns: 1fr; }
    .metric strong { font-size: 1.08rem; }
}

@media (max-width: 560px) {
    .auth-body { padding: 0; }
    .auth-shell {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
    }
    .auth-hero {
        min-height: auto;
        gap: 18px;
        padding: 22px 18px;
    }
    .auth-hero::after { display: none; }
    .auth-logo { width: min(190px, 72vw); }
    .auth-hero-copy { gap: 8px; }
    .auth-hero-copy h1 { font-size: 1.25rem; }
    .auth-highlights { gap: 6px; }
    .auth-highlights span { font-size: .62rem; }
    .auth-panel { padding: 22px 18px 26px; }
    .auth-form-head h2 { font-size: 1.45rem; }
    .filters { width: 100%; }
    .filters label { flex: 1 1 160px; }
    .page-actions { justify-content: stretch; }
    .page-actions .btn { width: 100%; }
    .theme-toggle, .avatar { margin-left: 0; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric { min-height: 128px; padding: 13px; grid-template-columns: 1fr 34px; gap: 8px; }
    .metric strong { font-size: .94rem; }
    .metric span, .metric small { font-size: .72rem; }
    .metric small { grid-column: 1 / 3; padding: 7px 8px; }
    .metric-icon { width: 34px; height: 34px; border-radius: 11px; }
    .line-chart, .chartjs-canvas { height: 260px !important; }
    .chartjs-wrap { min-height: 280px; }
    .debt-bar-row, .debt-stack-wrap { grid-template-columns: 1fr; }
    .debt-bar-row { padding: 11px 12px 12px 14px; gap: 10px; }
    .debt-title-line { align-items: flex-start; }
    .debt-status { width: auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
    .obligation-card { padding: 12px; }
    .obligation-main { align-items: flex-start; flex-direction: column; }
    .obligation-actions .btn,
    .obligation-actions form { flex: 1 1 calc(50% - 6px); }
    .obligation-actions .btn { width: 100%; }
    .goal-card { padding: 12px; }
    .goal-card-main { align-items: flex-start; flex-direction: column; }
    .goal-card-actions .btn,
    .goal-card-actions form { flex: 1 1 calc(50% - 6px); }
    .goal-card-actions .btn { width: 100%; }
    .donut-chart-shell { width: min(220px, 78vw); }
    .panel, .table-card { padding: 16px; }
}

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

/* Compact checkboxes and radios for forms */
.form-grid input[type="checkbox"],
.form-grid input[type="radio"],
.form-stack input[type="checkbox"],
.form-stack input[type="radio"] {
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: middle;
    accent-color: var(--brand-lime);
}

.compact-control { display: inline-flex; align-items: center; gap: 8px; line-height: 1; }

.form-grid .compact-control, .form-stack .compact-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.form-grid label, .form-stack label { font-size: .95rem; }

/* Modal buttons: consistent, slightly more compact */
.modal .btn { height: 32px; min-height: 32px; padding: 0 10px; line-height: 32px; }
.modal .btn.primary { padding: 0 12px; }
.modal .btn.small { height: 30px; min-height: 30px; padding: 0 8px; line-height: 30px; }

/* Ensure box-sizing includes padding for height calculations */
.btn, .modal .btn, .form-grid .btn { box-sizing: border-box; }
.sidebar { overflow-x: hidden; }
.sidebar nav { overflow-x: hidden; }

/* Place modal form buttons bottom-right */
.modal form { position: relative; padding-bottom: 56px; }
.modal form .btn { position: absolute; bottom: 16px; }
.modal form .btn.primary { right: 18px; }
.modal form .btn.small { right: 18px; }
.modal form .btn:not(.primary) { right: calc(18px + 100px); }

@media (max-width: 600px) {
    .modal form { padding-bottom: 76px; }
    .modal form .btn, .modal form .btn.primary, .modal form .btn.small { position: static; margin-top: 12px; }
}
