/* Deliberately no external font import (previously Google Fonts). A personal-finance
   app has no business phoning a third party on every page load just to render text,
   and it also lets the Content-Security-Policy below stay tight. Every font-family
   declaration in this file already lists a solid system-font fallback chain, so
   removing the @import just means the system equivalents render instead. */

:root{
  color-scheme: light;
  --bg:            #f3f6f4;
  --surface:       #ffffff;
  --surface-2:     #eaeeec;
  --ink:           #0c1210;
  --ink-2:         #4b544e;
  --muted:         #868d85;
  --border:        rgba(12,18,16,0.10);
  --border-strong: rgba(12,18,16,0.16);

  --accent:        #1f5d53;
  --accent-ink:    #ffffff;
  --accent-soft:   #e2f0ec;
  --accent-soft-ink: #144038;

  --status-good:     #0ca30c;
  --status-good-soft:#e3f6e0;
  --status-warning:  #b8790a;
  --status-warning-soft:#fbedd2;
  --status-critical: #d03b3b;
  --status-critical-soft:#fbe3e1;

  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a;
  --cat-4: #b8860a; --cat-5: #e87ba4; --cat-6: #1e7a1e;

  --shadow: 0 1px 2px rgba(12,18,16,0.04), 0 8px 24px -12px rgba(12,18,16,0.16);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px;
  --tabbar-h: 60px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme: dark;
    --bg:#0c110f; --surface:#131a17; --surface-2:#1b2320;
    --ink:#f4f6f4; --ink-2:#c2c9c4; --muted:#8b938c;
    --border:rgba(244,246,244,0.10); --border-strong:rgba(244,246,244,0.18);
    --accent:#49b39e; --accent-ink:#06110e; --accent-soft:rgba(73,179,158,0.16); --accent-soft-ink:#8fe0cd;
    --status-good:#35c235; --status-good-soft:rgba(53,194,53,0.16);
    --status-warning:#f0a83d; --status-warning-soft:rgba(240,168,61,0.16);
    --status-critical:#ea6a6a; --status-critical-soft:rgba(234,106,106,0.16);
    --cat-1:#3987e5; --cat-2:#d95926; --cat-3:#199e70; --cat-4:#c98500; --cat-5:#d55181; --cat-6:#3fae3f;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#0c110f; --surface:#131a17; --surface-2:#1b2320;
  --ink:#f4f6f4; --ink-2:#c2c9c4; --muted:#8b938c;
  --border:rgba(244,246,244,0.10); --border-strong:rgba(244,246,244,0.18);
  --accent:#49b39e; --accent-ink:#06110e; --accent-soft:rgba(73,179,158,0.16); --accent-soft-ink:#8fe0cd;
  --status-good:#35c235; --status-good-soft:rgba(53,194,53,0.16);
  --status-warning:#f0a83d; --status-warning-soft:rgba(240,168,61,0.16);
  --status-critical:#ea6a6a; --status-critical-soft:rgba(234,106,106,0.16);
  --cat-1:#3987e5; --cat-2:#d95926; --cat-3:#199e70; --cat-4:#c98500; --cat-5:#d55181; --cat-6:#3fae3f;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}

*{box-sizing:border-box;}
html,body{margin:0;}
body{background:var(--bg);color:var(--ink);font-family:"Public Sans",-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased;}
h1,h2,h3{font-family:"Fraunces",Georgia,serif;font-weight:600;margin:0;text-wrap:balance;}
.mono{font-family:"IBM Plex Mono",SFMono-Regular,Consolas,monospace;font-variant-numeric:tabular-nums;}
a{color:inherit;}
button{font-family:inherit;}
[hidden]{display:none !important;}
@media (prefers-reduced-motion: reduce){*{animation-duration:.001ms !important;transition-duration:.001ms !important;}}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px;}

/* ---------- Login ---------- */
.login-screen{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;}
.login-card{width:100%;max-width:360px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow);padding:32px 28px;}
.login-brand{display:flex;align-items:center;gap:10px;margin-bottom:22px;}
.login-brand .mark{width:34px;height:34px;border-radius:9px;background:var(--accent);color:var(--accent-ink);display:flex;align-items:center;justify-content:center;}
.login-brand .mark svg{width:19px;height:19px;}
.login-brand h1{font-size:18px;}
.field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px;}
.field label{font-size:12px;font-weight:600;color:var(--ink-2);}
.field input,.field select{font-family:inherit;font-size:16px;padding:11px 11px;border-radius:8px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink);width:100%;}
.login-error{background:var(--status-critical-soft);color:var(--status-critical);font-size:13px;padding:9px 11px;border-radius:8px;margin-bottom:14px;}

/* ---------- Shell / nav ---------- */
.preview-banner{background:var(--accent-soft);color:var(--accent-soft-ink);font-size:12.5px;font-weight:600;text-align:center;padding:7px 16px;border-bottom:1px solid var(--border);}
.shell{display:flex;min-height:100vh;}
.nav{width:232px;flex-shrink:0;display:flex;flex-direction:column;gap:4px;padding:22px 14px;border-right:1px solid var(--border);background:var(--surface);}
.brand{display:flex;align-items:center;gap:10px;padding:4px 10px 20px;}
.brand-mark{width:30px;height:30px;border-radius:8px;background:var(--accent);color:var(--accent-ink);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.brand-mark svg{width:17px;height:17px;}
.brand-name{font-family:"Fraunces",serif;font-weight:600;font-size:16.5px;line-height:1.1;}
.brand-sub{font-size:11px;color:var(--muted);margin-top:1px;}
.navlist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;}
.navbtn{width:100%;display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:var(--radius-sm);border:none;background:transparent;cursor:pointer;color:var(--ink-2);font-size:14px;font-weight:500;text-align:left;transition:background .12s ease,color .12s ease;}
.navbtn svg{width:18px;height:18px;flex-shrink:0;}
.navbtn:hover{background:var(--surface-2);color:var(--ink);}
.navbtn[aria-current="page"]{background:var(--accent-soft);color:var(--accent-soft-ink);font-weight:600;}
.navbtn-more{display:none;}
.nav-foot{margin-top:auto;padding:12px 10px 2px;border-top:1px solid var(--border);}
.who{display:flex;align-items:center;gap:9px;padding:6px 2px;font-size:13px;color:var(--ink-2);}
.who-dot{width:22px;height:22px;border-radius:50%;background:var(--surface-2);display:flex;align-items:center;justify-content:center;font-size:10.5px;font-weight:700;color:var(--ink-2);flex-shrink:0;}
.logout-btn{background:none;border:none;color:var(--muted);font-size:12px;cursor:pointer;padding:6px 2px;}
.logout-btn:hover{color:var(--ink);}

.main{flex:1;min-width:0;}
.pagehead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:26px clamp(16px,3vw,36px) 4px;}
.pagehead h1{font-size:24px;}
.pagehead p{margin:5px 0 0;color:var(--ink-2);font-size:13.5px;}
.btn{display:inline-flex;align-items:center;gap:7px;border-radius:var(--radius-sm);padding:9px 15px;font-size:13.5px;font-weight:600;border:1px solid transparent;cursor:pointer;white-space:nowrap;transition:filter .12s ease,background .12s ease;}
.btn svg{width:15px;height:15px;}
.btn-primary{background:var(--accent);color:var(--accent-ink);}
.btn-primary:hover{filter:brightness(1.08);}
.btn-ghost{background:transparent;color:var(--ink-2);border-color:var(--border-strong);}
.btn-ghost:hover{background:var(--surface-2);color:var(--ink);}
.btn-sm{padding:6px 10px;font-size:12.5px;}
.btn-danger{background:var(--status-critical-soft);color:var(--status-critical);}
.btn-danger:hover{filter:brightness(0.97);}

.view{display:none;padding:18px clamp(16px,3vw,36px) 48px;}
.view.active{display:block;}

.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow);}
.stat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:16px;}
.stat-tile{padding:16px 18px;display:flex;flex-direction:column;gap:6px;}
.stat-label{font-size:11.5px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600;}
.stat-value{font-size:22px;font-weight:600;}
.stat-delta{font-size:12px;font-weight:600;}
.stat-delta.good{color:var(--status-good);}
.stat-delta.critical{color:var(--status-critical);}
.stat-foot{font-size:11.5px;color:var(--muted);margin-top:auto;}

/* ---------- Dashboard: cash flow hero + pace ---------- */
.flow-hero{display:grid;grid-template-columns:1fr;gap:14px;margin-bottom:14px;}
.flow-card{padding:20px 22px;}
.flow-card .flow-label{font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600;margin-bottom:10px;}
.flow-net{font-size:30px;font-weight:600;}
.flow-net.good{color:var(--status-good);}
.flow-net.critical{color:var(--status-critical);}
.flow-split{display:flex;gap:20px;margin-top:12px;}
.flow-split div{font-size:13px;color:var(--ink-2);}
.flow-split b{display:block;font-size:16px;color:var(--ink);font-weight:600;margin-top:2px;}
.pace-card{padding:20px 22px;display:flex;flex-direction:column;gap:10px;}
.pace-headline{font-size:15px;font-weight:600;}
.pace-headline.good{color:var(--status-good);}
.pace-headline.critical{color:var(--status-critical);}
.pace-sub{font-size:12.5px;color:var(--muted);}
.pace-bar{height:8px;border-radius:5px;background:var(--surface-2);overflow:hidden;margin-top:2px;}
.pace-bar-fill{height:100%;border-radius:5px;background:var(--accent);}
.pace-bar-fill.over{background:var(--status-critical);}
.pace-excluded{font-style:italic;margin-top:2px;}

/* ---------- Bills due soon ---------- */
.due-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--border);}
.due-row:last-child{border-bottom:none;}
.due-date{width:48px;flex-shrink:0;text-align:center;background:var(--surface-2);border-radius:8px;padding:5px 0;font-size:11px;font-weight:700;color:var(--ink-2);line-height:1.3;}
.due-date b{display:block;font-size:15px;color:var(--ink);}
.due-name{font-size:13.5px;font-weight:600;}
.due-owner{font-size:11.5px;color:var(--muted);}
.due-amt{margin-left:auto;font-size:14px;font-weight:600;}

/* ---------- Trend chart ---------- */
.trend-chart{display:flex;align-items:flex-end;gap:10px;height:110px;padding:4px 2px 0;}
.trend-col{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;gap:6px;}
.trend-bars{flex:1;display:flex;align-items:flex-end;gap:3px;width:100%;justify-content:center;}
.trend-bar{width:9px;border-radius:3px 3px 0 0;background:var(--surface-2);min-height:2px;}
.trend-bar.income{background:var(--status-good);}
.trend-bar.expense{background:var(--cat-2);}
.trend-label{font-size:10.5px;color:var(--muted);}
.trend-legend{display:flex;gap:16px;font-size:11.5px;color:var(--ink-2);margin-top:10px;}
.trend-legend span{display:inline-flex;align-items:center;gap:6px;}
.trend-legend i{width:8px;height:8px;border-radius:2px;display:inline-block;}

.grid-2{display:grid;grid-template-columns:1.3fr 1fr;gap:14px;align-items:start;}
.section-card{padding:18px 20px 20px;margin-bottom:14px;}
.section-head{display:flex;align-items:baseline;justify-content:space-between;margin-bottom:14px;gap:10px;}
.section-head h3{font-size:15.5px;}
.section-head .see-all{font-size:12.5px;color:var(--accent);font-weight:600;background:none;border:none;cursor:pointer;padding:0;}

.acct-row{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:16px;}
.acct-card{padding:14px 16px;display:flex;flex-direction:column;gap:5px;}
.acct-top{display:flex;align-items:center;justify-content:space-between;gap:8px;}
.acct-name{font-size:13px;font-weight:600;}
.acct-type{font-size:10.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;}
.acct-bal{font-size:18px;font-weight:600;}
.acct-bal.neg{color:var(--status-critical);}
.acct-bal.unknown{color:var(--muted);font-size:13px;font-weight:500;font-style:italic;}
.acct-edit{background:none;border:none;color:var(--accent);font-size:11.5px;cursor:pointer;padding:0;text-align:left;}
.acct-bal-edit{font-size:18px;font-weight:600;font-family:"IBM Plex Mono",monospace;width:100%;border:1px solid transparent;background:none;color:var(--ink);padding:2px 4px;margin:-2px -4px;border-radius:6px;}
.acct-bal-edit:hover,.acct-bal-edit:focus{border-color:var(--border-strong);background:var(--bg);}
.acct-bal-edit::placeholder{color:var(--muted);font-family:"Public Sans",sans-serif;font-weight:500;font-style:italic;}

.bar-row{display:flex;align-items:center;gap:10px;padding:7px 0;}
.bar-dot{width:9px;height:9px;border-radius:50%;flex-shrink:0;}
.bar-label{font-size:13px;width:120px;flex-shrink:0;color:var(--ink-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.bar-track{flex:1;height:9px;border-radius:5px;background:var(--surface-2);overflow:hidden;}
.bar-fill{height:100%;border-radius:5px;}
.bar-value{font-size:12.5px;width:70px;text-align:right;flex-shrink:0;}

table{width:100%;border-collapse:collapse;}
.ledger-wrap{overflow-x:auto;}
th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);font-weight:600;padding:0 10px 8px;border-bottom:1px solid var(--border);white-space:nowrap;}
td{padding:10px 10px;border-bottom:1px solid var(--border);font-size:13.5px;vertical-align:middle;white-space:nowrap;}
tr:last-child td{border-bottom:none;}
tbody tr:hover{background:var(--surface-2);}
td.amt{text-align:right;font-weight:600;}
td.amt.pos{color:var(--status-good);}
.cat-chip{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;color:var(--ink-2);}
.cat-chip .bar-dot{width:8px;height:8px;}
.who-tag{font-size:12px;color:var(--muted);}
.row-actions button{background:none;border:none;color:var(--muted);cursor:pointer;font-size:12px;padding:2px 4px;}
.row-actions button:hover{color:var(--status-critical);}

.filter-row{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px;align-items:center;}
.filter-row select,.filter-row input{font-family:inherit;font-size:13px;padding:7px 9px;border-radius:8px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink);}
.filter-row .date-range{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--muted);}
.filter-row .range-toggle{background:none;border:none;color:var(--accent);font-size:12.5px;font-weight:600;cursor:pointer;padding:4px 2px;}
.ledger-total-row{display:flex;flex-wrap:wrap;gap:18px;padding:12px 14px;margin-bottom:14px;background:var(--surface-2);border-radius:10px;font-size:13px;}
.ledger-total-row b{font-size:15px;display:block;margin-top:1px;}
.ledger-total-row .lt-net.good b{color:var(--status-good);}
.ledger-total-row .lt-net.critical b{color:var(--status-critical);}

/* ---------- Debts ---------- */
.debt-type-group{margin-bottom:22px;}
.debt-type-heading{font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:700;margin:0 0 10px 2px;}
.debt-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;}
.debt-card{padding:18px 20px;display:flex;flex-direction:column;gap:12px;}
.debt-top{display:flex;justify-content:space-between;align-items:flex-start;gap:8px;}
.debt-name-edit{font-size:15px;font-weight:600;border:1px solid transparent;background:none;color:var(--ink);border-radius:6px;padding:2px 4px;margin:-2px -4px;width:100%;font-family:inherit;}
.debt-name-edit:hover,.debt-name-edit:focus{border-color:var(--border-strong);background:var(--bg);}
.debt-sub{font-size:12px;color:var(--muted);margin-top:2px;display:flex;gap:6px;align-items:center;}
.debt-sub select{font-size:11.5px;padding:2px 4px;border-radius:6px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink-2);font-family:inherit;}
.tag{font-size:10.5px;font-weight:700;letter-spacing:.03em;text-transform:uppercase;padding:3px 8px;border-radius:20px;white-space:nowrap;}
.tag.critical{background:var(--status-critical-soft);color:var(--status-critical);}
.tag.muted{background:var(--surface-2);color:var(--ink-2);}
.tag.info{background:var(--accent-soft);color:var(--accent-soft-ink);}
.debt-balance{font-size:24px;font-weight:600;}
.debt-track{height:8px;border-radius:5px;background:var(--surface-2);overflow:hidden;}
.debt-fill{height:100%;background:var(--accent);border-radius:5px;}
.debt-meta{display:flex;justify-content:space-between;font-size:12px;color:var(--ink-2);}
.debt-facts{display:flex;flex-direction:column;gap:6px;font-size:12.5px;color:var(--ink-2);border-top:1px solid var(--border);padding-top:11px;}
.debt-facts div{display:flex;justify-content:space-between;gap:8px;align-items:center;}
.debt-facts b{color:var(--ink);font-weight:600;}
.debt-facts input,.debt-facts select{width:110px;text-align:right;font-family:"IBM Plex Mono",monospace;font-size:12.5px;padding:4px 6px;border-radius:6px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink);}
.debt-facts select{font-family:inherit;text-align:left;}
.debt-payoff{border-top:1px dashed var(--border-strong);padding-top:10px;margin-top:2px;display:flex;flex-direction:column;gap:6px;font-size:12.5px;}
.debt-payoff .po-row{display:flex;justify-content:space-between;}
.debt-payoff .po-caveat{font-size:11px;color:var(--status-warning);background:var(--status-warning-soft);border-radius:6px;padding:5px 7px;margin-top:2px;}
.debt-payoff .po-unavailable{font-size:11.5px;color:var(--muted);font-style:italic;}
.debt-archive-btn{background:none;border:none;color:var(--muted);font-size:11px;cursor:pointer;padding:0;text-align:right;margin-top:2px;}
.debt-archive-btn:hover{color:var(--status-critical);}

.debt-totals-bar{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-top:6px;margin-bottom:20px;}
.debt-totals-bar .stat-tile .stat-foot.warn{color:var(--status-warning);}

/* ---------- Budgets ---------- */
.budget-row{display:flex;align-items:center;gap:14px;padding:13px 0;border-bottom:1px solid var(--border);}
.budget-row:last-child{border-bottom:none;}
.budget-info{width:150px;flex-shrink:0;display:flex;align-items:center;gap:8px;font-size:13.5px;font-weight:500;}
.budget-bar-wrap{flex:1;}
.budget-track{height:10px;border-radius:5px;background:var(--surface-2);overflow:hidden;}
.budget-fill{height:100%;border-radius:5px;}
.budget-fill.good{background:var(--status-good);}
.budget-fill.warning{background:var(--status-warning);}
.budget-fill.critical{background:var(--status-critical);}
.budget-nums{display:flex;justify-content:space-between;font-size:11.5px;color:var(--muted);margin-top:4px;}
.budget-limit-edit{width:88px;text-align:right;font-family:"IBM Plex Mono",monospace;font-size:12.5px;padding:4px 7px;border-radius:6px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink);}

.bill-row{display:flex;align-items:center;gap:14px;padding:13px 4px;border-bottom:1px solid var(--border);}
.bill-edit-panel:not([hidden]) + .bill-row,
.bill-row:has(+ .bill-edit-panel:not([hidden])){border-bottom:none;}
.bill-row:last-child{border-bottom:none;}
.bill-check{width:22px;height:22px;border-radius:7px;border:1.5px solid var(--border-strong);background:var(--surface);cursor:pointer;flex-shrink:0;display:flex;align-items:center;justify-content:center;color:var(--accent-ink);}
.bill-check.paid{background:var(--status-good);border-color:var(--status-good);}
.bill-check svg{width:13px;height:13px;}
.bill-name{font-size:14px;font-weight:600;}
.bill-due{font-size:12px;color:var(--muted);}
.bill-tags{display:flex;gap:6px;margin-top:5px;flex-wrap:wrap;}
.bill-amt{font-size:14.5px;font-weight:600;margin-left:auto;}
.bill-edit-toggle{background:none;border:none;color:var(--muted);cursor:pointer;padding:5px;border-radius:6px;flex-shrink:0;display:flex;}
.bill-edit-toggle:hover{color:var(--ink);background:var(--surface-2);}
.bill-edit-toggle svg{width:15px;height:15px;}
.bill-edit-panel{padding:14px;border-bottom:1px solid var(--border);display:flex;flex-direction:column;gap:10px;background:var(--surface-2);border-radius:10px;margin:2px 0 10px;}
.bill-autopay-row{align-items:center;flex-wrap:wrap;}
.autopay-check{display:flex;align-items:center;gap:8px;font-size:13px;font-weight:500;color:var(--ink-2);white-space:nowrap;cursor:pointer;}
.autopay-check input{width:auto;}
.bill-add-form{background:var(--surface-2);border-radius:12px;padding:16px;margin-bottom:16px;display:flex;flex-direction:column;gap:12px;}
.chip.info{background:var(--accent-soft);color:var(--accent-soft-ink);}
.chip{font-size:11px;font-weight:700;padding:4px 9px;border-radius:20px;letter-spacing:.02em;}
.chip.good{background:var(--status-good-soft);color:var(--status-good);}
.chip.warning{background:var(--status-warning-soft);color:var(--status-warning);}
.chip.muted{background:var(--surface-2);color:var(--muted);}
.one-time-badge{margin-left:6px;vertical-align:middle;}
.row-actions button[data-onetime]{margin-right:4px;}
.row-actions button[data-onetime]:hover{color:var(--accent);}

.sub-row{display:flex;align-items:center;gap:12px;padding:11px 4px;border-bottom:1px solid var(--border);}
.sub-row:last-child{border-bottom:none;}
.sub-name{font-size:13.5px;font-weight:600;}
.sub-owner{font-size:11.5px;color:var(--muted);}
.sub-cost{font-size:14px;font-weight:600;margin-left:auto;}
.sub-action select{font-size:12px;padding:5px 8px;border-radius:7px;border:1px solid var(--border-strong);background:var(--bg);color:var(--ink);}

/* ---------- Settings: manage lists ---------- */
.manage-list{display:flex;flex-direction:column;gap:1px;margin-bottom:12px;max-height:260px;overflow-y:auto;border:1px solid var(--border);border-radius:10px;}
.manage-row{display:flex;align-items:center;gap:10px;padding:9px 12px;background:var(--surface);font-size:13px;}
.manage-row.inactive{opacity:.55;}
.manage-row .mr-name{flex:1;font-weight:600;}
.manage-row .mr-sub{font-size:11px;color:var(--muted);}
.manage-row button{background:none;border:none;color:var(--accent);font-size:11.5px;font-weight:600;cursor:pointer;padding:2px 4px;}
.manage-row button.danger{color:var(--status-critical);}
.color-pick{display:flex;gap:6px;margin:4px 0 10px;}
.color-pick button{width:24px;height:24px;border-radius:50%;border:2px solid transparent;cursor:pointer;padding:0;}
.color-pick button.selected{border-color:var(--ink);}

.modal-backdrop{position:fixed;inset:0;background:rgba(6,10,9,0.44);display:none;align-items:center;justify-content:center;padding:20px;z-index:50;}
.modal-backdrop.open{display:flex;}
.modal{background:var(--surface);border-radius:var(--radius-lg);width:100%;max-width:420px;padding:22px 22px 20px;box-shadow:var(--shadow);border:1px solid var(--border);max-height:90vh;overflow-y:auto;}
.modal h3{font-size:17px;margin-bottom:14px;}
.field-row{display:flex;gap:10px;}
.field-row .field{flex:1;}
.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px;}
.form-error{background:var(--status-critical-soft);color:var(--status-critical);font-size:12.5px;padding:8px 10px;border-radius:8px;margin-bottom:12px;}

/* ---------- More sheet (mobile) ---------- */
.sheet-backdrop{position:fixed;inset:0;background:rgba(6,10,9,0.44);display:none;align-items:flex-end;justify-content:center;z-index:55;}
.sheet-backdrop.open{display:flex;}
.sheet{background:var(--surface);border-radius:18px 18px 0 0;width:100%;max-width:520px;padding:10px 10px calc(14px + env(safe-area-inset-bottom));box-shadow:var(--shadow);}
.sheet-handle{width:36px;height:4px;border-radius:3px;background:var(--border-strong);margin:6px auto 10px;}
.sheet-item{width:100%;display:flex;align-items:center;gap:12px;padding:14px 14px;border-radius:10px;border:none;background:none;color:var(--ink);font-size:15px;font-weight:500;text-align:left;cursor:pointer;}
.sheet-item:active{background:var(--surface-2);}
.sheet-item svg{width:19px;height:19px;color:var(--ink-2);flex-shrink:0;}
.sheet-item.danger{color:var(--status-critical);}
.sheet-item.danger svg{color:var(--status-critical);}

.toast{position:fixed;bottom:24px;left:50%;transform:translateX(-50%) translateY(12px);background:var(--ink);color:var(--bg);font-size:13px;font-weight:600;padding:11px 18px;border-radius:10px;box-shadow:var(--shadow);opacity:0;pointer-events:none;transition:opacity .18s ease,transform .18s ease;z-index:60;}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}
.loading-row{padding:24px;text-align:center;color:var(--muted);font-size:13px;}

/* ============================================================
   MOBILE — bottom tab bar, floating add button, sheet modals,
   card-style ledger rows, stacked stat/hero grids
   ============================================================ */
@media (max-width:900px){
  .shell{flex-direction:column;}
  .nav{position:fixed;bottom:0;left:0;right:0;top:auto;z-index:40;width:100%;flex-direction:row;justify-content:space-around;padding:4px 2px calc(4px + env(safe-area-inset-bottom));border-right:none;border-top:1px solid var(--border);gap:0;box-shadow:0 -2px 12px -4px rgba(12,18,16,0.12);}
  .brand,.nav-foot{display:none;}
  .navlist{flex-direction:row;width:100%;gap:0;}
  .navlist li{display:flex;flex:1;min-width:0;}
  .navbtn{flex-direction:column;gap:3px;font-size:10.5px;padding:8px 6px;border-radius:10px;flex:1;align-items:center;min-height:52px;justify-content:center;}
  .navlist li:nth-child(5),.navlist li:nth-child(6){display:none;}
  .navbtn-more{display:flex;}
  .main{padding-bottom:var(--tabbar-h);}
  .pagehead{padding:16px 16px 2px;flex-wrap:wrap;}
  .pagehead .btn-primary{position:fixed;right:16px;bottom:calc(var(--tabbar-h) + 14px);z-index:41;width:52px;height:52px;padding:0;border-radius:50%;justify-content:center;box-shadow:0 6px 18px -4px rgba(12,18,16,0.35);}
  .pagehead .btn-primary .long{display:none;}
  .pagehead .btn-primary svg{width:22px;height:22px;}
  .pagehead #openSettingsBtn{display:none;}
  .view{padding:14px 16px calc(24px + var(--tabbar-h) + 60px);}
  .stat-grid{grid-template-columns:repeat(2,1fr);}
  .flow-hero{grid-template-columns:1fr;}
  .grid-2{grid-template-columns:1fr;}
  .acct-row{grid-template-columns:1fr;}
  .debt-grid{grid-template-columns:1fr;}
  .debt-totals-bar{grid-template-columns:repeat(2,1fr);}
  .bar-label{width:88px;font-size:12px;}
  .budget-info{width:108px;font-size:12.5px;}

  /* full-screen sheet modals */
  .modal-backdrop{padding:0;align-items:flex-end;}
  .modal{max-width:100%;width:100%;border-radius:18px 18px 0 0;max-height:92vh;padding:18px 18px calc(18px + env(safe-area-inset-bottom));}
  .modal h3{font-size:18px;}
  .field input,.field select{font-size:16px;padding:12px 12px;}

  /* ledger: table rows become cards */
  th{display:none;}
  .ledger-wrap{overflow-x:visible;}
  #fullLedgerBody tr,#dashLedgerBody tr{display:flex;flex-wrap:wrap;align-items:center;gap:1px 10px;padding:12px 2px;}
  #fullLedgerBody td,#dashLedgerBody td{display:block;border:none;padding:0;white-space:normal;font-size:13px;}
  #fullLedgerBody td:nth-child(1),#dashLedgerBody td:nth-child(1){order:3;font-size:11px;color:var(--muted);width:auto;}
  #fullLedgerBody td.desc-cell,#dashLedgerBody td.desc-cell{order:1;font-weight:600;font-size:14.5px;flex:1 1 55%;}
  #fullLedgerBody td:nth-child(3),#dashLedgerBody td:nth-child(3){order:4;font-size:11.5px;}
  #fullLedgerBody td:nth-child(4){display:block !important;order:5;font-size:11px;color:var(--muted);}
  #fullLedgerBody td:nth-child(5),#dashLedgerBody td:nth-child(4){order:6;font-size:11px;color:var(--muted);}
  #fullLedgerBody td.amt,#dashLedgerBody td.amt{order:2;margin-left:auto;font-size:15px;}
  #fullLedgerBody td.row-actions{order:7;width:100%;text-align:right;margin-top:2px;}
  .filter-row{flex-direction:column;align-items:stretch;}
  .filter-row select,.filter-row input{width:100%;}
  .filter-row .date-range{flex-wrap:wrap;}
}
@media (max-width:520px){
  .stat-grid{grid-template-columns:1fr 1fr;}
  .debt-totals-bar{grid-template-columns:1fr 1fr;}
}
