/* The Family Budget — "Green Midnight" */
:root {
  color-scheme: dark;
  --page: #111413; --card: #1A1E1C; --soft: #232826; --border: #2C322F; --line: #262B29; --track: #2A302D;
  --text: #EEF2EF; --muted: #A3ADA7; --dark: #0A0C0B;
  --green: #15803D; --bright: #4ADE80; --yellow: #FFD25A; --on-yellow: #111413; --on-yellow-2: #4A3B00;
  --becca: #173A28; --becca-track: #1F5A3A; --becca-muted: #B4C7BC;
  --warn: #F59E4B; --warn-soft: #FDBA74; --warn-bg: #3D2A14;
  --head: 'Bricolage Grotesque', system-ui, sans-serif; --body: 'Figtree', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text); font-family: var(--body); }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--bright); }
a:hover { color: #86EFAC; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { background: var(--card); }
:focus-visible { outline: 2px solid var(--bright); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fig { font-family: var(--head); font-weight: 800; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.sq { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; display: inline-block; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.nolink { color: inherit; text-decoration: none; }
.nolink:hover { color: inherit; }

/* ---------- web shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.side { width: 216px; flex: none; background: var(--dark); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: block; flex: none; }
.brand-name { font-family: var(--head); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-a { height: 44px; border-radius: 12px; padding: 0 12px; display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 700; color: var(--muted); text-decoration: none; }
.nav-a .sq { border-radius: 3px; }
.nav-a.sub { height: 36px; padding-left: 34px; font-size: 14px; font-weight: 500; color: #8E9A93; }
.nav-a.sub .sq { width: 6px; height: 6px; }
.nav-a[aria-current="page"] { background: #1F2A24; color: #fff; }
.nav-a:hover { color: #fff; }
.side-data { margin-top: auto; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #1F2421; padding-top: 14px; }
.side-data .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #7D8882; padding: 0 4px; }
.side-btn { height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; padding: 0 10px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.side-btn:hover { background: #1F2A24; color: #fff; }
.side-saved { font-size: 11px; color: #7D8882; padding: 0 4px; }
.main { flex: 1; min-width: 0; height: 100%; overflow: auto; padding: 20px clamp(16px, 2vw, 28px) 16px; display: flex; flex-direction: column; gap: 14px; }

/* headers */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.head-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.head-r { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.h1 { margin: 0; font-family: var(--head); font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.h2 { margin: 0; font-family: var(--head); font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.h2.sm { font-size: 18px; } .h2.xs { font-size: 17px; } .h2.xxs { font-size: 16px; }
.sub-note { font-size: 14px; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.btn { height: 40px; border: 0; border-radius: 12px; padding: 0 16px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { color: #fff; background: #16903F; }
.btn-ghost { background: var(--card); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { color: var(--text); border-color: #3A413D; }
.btn-warn { background: transparent; color: var(--warn); }
.btn-tall { height: 44px; }
.icon-btn { width: 44px; height: 40px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--text); }
.back-btn { width: 40px; height: 40px; }
.mnav { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.mnav button { width: 36px; height: 34px; border: 0; border-radius: 9px; background: transparent; display: flex; align-items: center; justify-content: center; }
.mnav button:hover { background: var(--soft); }
.mnav .lbl { min-width: 118px; text-align: center; font-size: 14px; font-weight: 700; }
.seg { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg button { height: 34px; border: 0; border-radius: 9px; padding: 0 14px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--dark); color: #fff; }
.seg.green button[aria-pressed="true"] { background: var(--green); }

/* cards + tiles */
.card { background: var(--card); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpis.w170 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis.w160 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); min-width: 0; }
.kpi:hover { color: inherit; }
.kpi .k { font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi .v { font-family: var(--head); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi.yellow { background: var(--yellow); color: var(--on-yellow); } .kpi.yellow .k { color: var(--on-yellow-2); }
.kpi.green { background: var(--green); color: #fff; } .kpi.green .k { color: #CFF5DD; }
.kpi.dark { background: var(--dark); color: #fff; }
.kpi.becca { background: var(--becca); } .kpi.becca .k { color: var(--becca-muted); }
.cols { flex: 1; display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; min-height: 0; }
.col { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }
.stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; }
.stack > i { display: block; height: 100%; }
.row { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.th { display: flex; align-items: center; gap: 12px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.who { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.who.x { background: var(--dark); color: var(--yellow); } .who.b { background: var(--becca); color: var(--bright); }
.badge { width: 22px; height: 20px; border-radius: 6px; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.badge.x { background: var(--dark); color: var(--yellow); } .badge.b { background: var(--becca); color: var(--bright); }
.dot { width: 12px; height: 12px; border-radius: 999px; border: 2px solid #4A524E; flex-shrink: 0; }
.dot.part { border-color: var(--warn); background: var(--warn-bg); }
.dot.covered { border: 0; background: #2E9E5B; }
.look { background: var(--card); border: 2px dashed var(--warn); border-radius: 18px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.look .pill { background: var(--warn); color: #1E1300; }
.look p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.look b { color: var(--text); }
.add-dash { height: 44px; border: 2px dashed #3A413D; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--muted); text-decoration: none; background: transparent; width: 100%; }
.add-dash:hover { color: var(--text); border-color: #4A524E; }
.empty-note { font-size: 14px; color: var(--muted); line-height: 1.5; padding: 8px 0; }

/* money inputs */
.money-in { display: flex; align-items: center; gap: 4px; height: 34px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--card); }
.money-in > span { font-size: 14px; color: var(--muted); }
.money-in input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; text-align: right; font-family: var(--head); font-size: 15px; font-weight: 800; padding: 0; }
.money-in input:focus { outline: none; }
.money-in:focus-within { border-color: var(--bright); }
.money-in.covered { border-color: #9BD3AE; background: #15291F; }
.money-in.part { border-color: #F2B66B; background: #2E2416; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.field input[type="text"], .field select, .field textarea, .field .money-in { height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; font-size: 16px; font-weight: 500; }
.field .money-in { padding: 0 14px; }
.field .money-in input { text-align: left; font-size: 20px; }
.field select { padding: 0 10px; }
.field textarea { height: auto; padding: 10px 12px; resize: none; }
.check { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 700; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.chip { height: 40px; border: 2px solid var(--border); border-radius: 999px; padding: 0 14px; background: var(--card); color: var(--text); font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-checked="true"], .chip[aria-selected="true"] { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip[aria-checked="true"] .sq, .chip[aria-selected="true"] .sq { outline: 1px solid var(--card); }
.tabbtn { height: 40px; border: 0; border-radius: 12px; padding: 0 14px; background: var(--card); color: var(--text); font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tabbtn[aria-selected="true"] { background: var(--dark); color: #fff; }
.tabbtn .n { font-weight: 500; opacity: 0.75; }
.payer { border: 3px solid transparent; border-radius: 16px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; }
.payer.x { background: var(--dark); color: #fff; border-color: var(--dark); }
.payer.b { background: var(--becca); color: var(--text); border-color: var(--becca); }
.payer.x[aria-pressed="true"], .payer.x[aria-checked="true"] { border-color: var(--yellow); }
.payer.b[aria-pressed="true"], .payer.b[aria-checked="true"] { border-color: var(--green); }

/* accounts table */
.tbl-wrap { overflow: auto; min-height: 0; flex: 1; }
.tbl { min-width: 1080px; display: flex; flex-direction: column; }
.tbl .tr { display: flex; align-items: center; gap: 12px; height: 38px; border-top: 1px solid var(--line); font-size: 14px; }
.tbl select { width: 100%; height: 30px; border: 1px solid var(--border); border-radius: 8px; padding: 0 6px; background: var(--card); font-size: 13px; font-weight: 700; color: #7D8882; }
.tbl select.set { border-color: #2F6B4A; color: var(--text); }
.tbl .money-in { height: 30px; width: 112px; border-radius: 8px; padding: 0 8px; }
.tbl .money-in input { font-family: var(--body); font-size: 14px; font-weight: 700; }
.mini-add { height: 28px; border: 1px dashed #3A413D; border-radius: 8px; padding: 0 10px; background: transparent; font-size: 12px; font-weight: 700; color: var(--muted); }
.cov { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--track); color: var(--muted); }
.cov.covered { background: #183C29; color: var(--bright); }
.cov.part { background: var(--warn-bg); color: var(--warn-soft); }

/* ---------- phone shell ---------- */
.phone { flex-direction: column; }
.p-head { padding: 22px 16px 8px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; padding-top: max(22px, env(safe-area-inset-top)); }
.p-head.sub { padding: 20px 16px 8px; justify-content: flex-start; padding-top: max(20px, env(safe-area-inset-top)); }
.p-head .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.p-head .status { font-size: 13px; color: var(--muted); }
.p-h1 { margin: 0; font-family: var(--head); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.p-head.sub .p-h1 { font-size: 24px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-mnav { display: flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; flex: none; }
.p-mnav button { width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; display: flex; align-items: center; justify-content: center; }
.p-mnav .lbl { min-width: 74px; text-align: center; font-size: 14px; font-weight: 700; }
.p-mnav.compact button { width: 36px; } .p-mnav.compact .lbl { min-width: 66px; font-size: 13px; } .p-mnav.compact .lbl.yr { min-width: 44px; }
.p-back { width: 44px; height: 44px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text); }
.p-main { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.p-main > * { flex-shrink: 0; }
.p-tabs { flex-shrink: 0; height: calc(76px + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.p-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; }
.p-tabs a[aria-current="page"] { color: var(--bright); font-weight: 700; }
.p-card { background: var(--card); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.p-h2 { margin: 0; font-family: var(--head); font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.p-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.p-tile { border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); background: var(--card); min-width: 0; }
.p-tile:hover { color: inherit; }
.p-tile .k { font-size: 12px; font-weight: 700; color: var(--muted); }
.p-tile .v { font-family: var(--head); font-size: 22px; font-weight: 800; line-height: 1; }
.p-tile .s { font-size: 12px; color: var(--muted); }
.p-tile.dark { background: var(--dark); color: #fff; }
.p-tile.becca { background: var(--becca); } .p-tile.becca .k { color: var(--becca-muted); }
.p-tile.yellow { background: var(--yellow); color: var(--on-yellow); } .p-tile.yellow .k, .p-tile.yellow .s { color: var(--on-yellow-2); }
.p-tile.green { background: var(--green); color: #fff; } .p-tile.green .k { color: #CFF5DD; }
.acc { background: var(--card); border-radius: 18px; overflow: hidden; }
.acc-btn { width: 100%; min-height: 60px; border: 0; background: transparent; padding: 10px 16px; display: flex; align-items: center; gap: 12px; text-align: left; }
.acc-btn .chev { transition: transform .15s; flex: none; }
.acc-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.p-foot { flex-shrink: 0; background: var(--card); border-top: 1px solid var(--border); padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.p-foot .btn { height: 52px; border-radius: 14px; font-size: 15px; }

/* dialogs + toast */
dialog { border: 1px solid var(--border); border-radius: 20px; background: var(--card); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog::backdrop { background: rgba(5, 7, 6, 0.72); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--dark); color: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; font-size: 14px; font-weight: 700; z-index: 50; box-shadow: none; max-width: calc(100vw - 32px); }
.phone + .toast, .toast.phone-toast { bottom: calc(92px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* inputs nested inside a money field don't get their own box */
.field .money-in input[type="text"] { height: auto; border: 0; border-radius: 0; padding: 0; background: transparent; }
.dlg .field .money-in input[type="text"] { font-size: 18px; }
.p-mnav.compact { padding: 2px; gap: 0; }
.p-head.sub .p-h1 { font-size: 21px; }
.side-user { font-size: 13px; font-weight: 700; color: #fff; padding: 0 4px; }
code { font-size: 0.92em; background: var(--soft); padding: 1px 5px; border-radius: 6px; }

/* Phone: pin the whole app to the screen so only the middle scrolls and the bottom bar never moves */
html, body { overscroll-behavior: none; }
.app.phone { position: fixed; inset: 0; height: auto; }
/* Phone menu (☰) */
.p-head-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-menu { width: 42px; height: 42px; flex: none; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center; }
.p-drawer-wrap { position: fixed; inset: 0; z-index: 60; }
.p-drawer-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.p-drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); background: var(--page); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; padding: max(16px, env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; animation: drawer-in .18s ease-out; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .p-drawer { animation: none; } }
.p-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px 12px; }
.p-drawer-head .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-drawer-head .brand-mark { border-radius: 8px; }
.p-drawer-head .brand-name { font-family: var(--head, inherit); font-weight: 800; font-size: 18px; }
.p-drawer-a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 600; }
.p-drawer-a.sub { min-height: 42px; padding-left: 34px; font-size: 15px; font-weight: 500; color: var(--muted); }
.p-drawer-a[aria-current="page"] { background: var(--card); color: var(--bright, #4ADE80); }
.p-drawer-a .sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.p-drawer-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
/* the ☰ button takes room from the title: let long titles shrink instead of running under the month switcher */
.p-head-l { flex: 1 1 auto; }
.p-head-l .titles { min-width: 0; }
.p-head-l .p-h1 { font-size: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .p-head-l .p-h1 { font-size: 24px; } .p-head .p-mnav .lbl { min-width: 60px; } }
.acct-tile { color: inherit; text-decoration: none; transition: background .15s; } .acct-tile:hover { background: #2A302D !important; } .acct-tile:focus-visible { outline: 2px solid #4ADE80; outline-offset: 2px; }
