/* Kosha design system. Mobile first; one stylesheet; every colour comes from a token. */

:root {
  /* surfaces */
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #19212c;
  --surface-3: #212b38;
  --line: rgb(255 255 255 / 7%);
  --line-2: rgb(255 255 255 / 13%);
  /* text */
  --txt: #e9eef4;
  --mut: #a0acba;
  --mut2: #808d9c;
  /* brand + meaning */
  --acc: #5b9bff;
  --acc-ink: #061224;
  --acc-soft: rgb(91 155 255 / 14%);
  --pos: #4fd1a1;
  --pos-soft: rgb(79 209 161 / 13%);
  --neg: #f2837b;
  --neg-soft: rgb(242 131 123 / 13%);
  --warn: #e8b860;
  --warn-soft: rgb(232 184 96 / 14%);
  --violet: #a78bfa;
  --grad: linear-gradient(135deg, #38bdf8 0%, #4c8dff 50%, #a78bfa 100%);
  /* aliases kept for markup rendered by app.js */
  --blue: var(--acc);
  --glass: var(--surface);
  --glass2: var(--surface-2);
  /* shape + rhythm */
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --gap: 12px;
  --pad: 16px;
  --tap: 44px;
  --shadow: 0 18px 48px rgb(0 0 0 / 38%);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: 140ms;
  --enter: 240ms;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--txt); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg, canvas { display: block; max-width: 100%; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnum, .amt, .val, .sval, .dv { font-variant-numeric: tabular-nums; }
.trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warnc { color: var(--warn); }
.blu { color: var(--acc); } .vio { color: var(--violet); }
.muted { color: var(--mut); font-size: 14px; }
.small { font-size: 12.5px; }
.hint { color: var(--mut); font-size: 13.5px; line-height: 1.6; margin-top: 10px; }
.err { color: var(--neg); font-size: 13.5px; min-height: 1.2em; margin-top: 10px; }
.ok { color: var(--pos); font-size: 13.5px; min-height: 1.2em; margin-top: 10px; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: 6px; }

/* ---------- controls ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: var(--tap); padding: 10px 16px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--acc); color: var(--acc-ink); font-size: 14.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; touch-action: manipulation;
  transition: background var(--fast), border-color var(--fast), opacity var(--fast), transform var(--fast);
}
button:hover { filter: brightness(1.07); }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: progress; filter: none; transform: none; }
button.ghost { background: transparent; border-color: var(--line-2); color: var(--txt); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.danger { background: var(--neg-soft); border-color: rgb(242 131 123 / 30%); color: #ffc3bd; }
button.link { min-height: 36px; padding: 6px 4px; background: none; color: var(--acc); font-weight: 600; }
button.block, .block { width: 100%; }
button svg { width: 18px; height: 18px; flex-shrink: 0; }
button.icononly { width: var(--tap); padding: 0; }
button.on.icononly, button.ghost.on { background: var(--acc-soft); border-color: rgb(91 155 255 / 40%); }

label { display: block; font-size: 13.5px; font-weight: 500; color: var(--mut); margin: 0 0 6px; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--bg); border: 1px solid var(--line-2); color: var(--txt);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */ outline: none;
  transition: border-color var(--fast), box-shadow var(--fast);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23a0acba' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
input::placeholder, textarea::placeholder { color: var(--mut2); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
input[aria-invalid="true"] { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
input[type="search"]::-webkit-search-cancel-button { filter: invert(.7); }
input[type="date"] { min-width: 0; }
input.locked { border-style: dashed; color: var(--mut); }

/* ---------- auth + lock ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.auth.lock { position: fixed; inset: 0; z-index: 200; background: var(--bg); }
.authcard { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 22px; box-shadow: var(--shadow); }
.authcard.narrow { max-width: 330px; }
.authcard label { margin-top: 16px; }
.authcard button.block { margin-top: 22px; }
.authlogo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px; }
.authlogo img { width: 64px; height: 64px; border-radius: 18px; }
.authlogo h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; }
.authlogo p { color: var(--mut); font-size: 14px; }
.pin { text-align: center; letter-spacing: .5em; font-size: 22px; }

/* ---------- shell ---------- */
#app { min-height: 100dvh; }
aside.side { display: none; }
.content { min-width: 0; }
header.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 4px;
  padding: calc(8px + var(--safe-t)) 8px 8px 16px; min-height: calc(56px + var(--safe-t));
  background: rgb(11 15 20 / 86%); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
header.top .ttl { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { width: var(--tap); height: var(--tap); padding: 0; background: transparent; color: var(--txt); border-radius: 12px; }
.iconbtn:hover { background: var(--surface-2); filter: none; }
.iconbtn svg { width: 22px; height: 22px; }
#topAdd { display: none; }
main { padding: 16px 16px calc(var(--tabbar-h) + 32px + var(--safe-b)); max-width: 1200px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: var(--gap); }
.view > * { margin: 0; }
.loading { color: var(--mut); text-align: center; padding: 72px 20px; font-size: 14px; }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--acc); margin: 0 auto 14px; animation: spin .8s linear infinite; }

/* ---------- panels + headings ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--pad); min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel .pad, .pad { padding: var(--pad) var(--pad) 0; }
.listfoot.pad { padding: 4px var(--pad) var(--pad); }
.panel.notice, .coverage-note { background: var(--warn-soft); border-color: rgb(232 184 96 / 28%); }
.panel h2, .panel h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 12px; line-height: 1.35; }
.panel h2 .sub, .panel h3 .sub, .panel h3 .muted { display: block; font-size: 13px; font-weight: 400; color: var(--mut); margin-top: 2px; letter-spacing: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.panel-head h2 { margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row > :first-child { min-width: 0; }
.row.stack { flex-direction: column; align-items: stretch; gap: 8px; }
.row.stack label { margin: 0; color: var(--txt); font-size: 14.5px; }
.row.stack label .small { display: block; margin-top: 2px; font-weight: 400; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.row-actions > button { flex: 1 1 auto; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; scroll-padding: 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips button, .subtabs button, .rangebar button {
  flex-shrink: 0; min-height: 38px; padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 550;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--mut);
}
.chips button:hover { color: var(--txt); filter: none; }
.chips button.on, .subtabs button.on, .rangebar button.on { background: var(--txt); border-color: var(--txt); color: var(--bg); }
.subtabs, .rangebar { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- toolbars + forms ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar.end { justify-content: flex-end; }
.toolbar .chips { flex: 1; }
.toolbar .search { flex: 1; min-width: 0; }
.toolbar > .muted { flex: 1; min-width: 0; font-size: 13px; }
.formgrid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.formgrid.two { grid-template-columns: 1fr; gap: 8px; }
.align-end { align-self: end; }
.filters { display: flex; gap: 8px; }
.filters input { flex: 1; }
.addbtn2 { flex-shrink: 0; }
.addbtn { width: 100%; margin-bottom: 14px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.panel .kpi { background: var(--surface-2); border-color: transparent; }
.kpi .lab { font-size: 12.5px; color: var(--mut); line-height: 1.35; }
.kpi .val { display: block; font-size: 19px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; line-height: 1.2; overflow-wrap: anywhere; }
.kpi .sub { font-size: 12px; color: var(--mut2); margin-top: 4px; line-height: 1.4; }

/* ---------- overview hero ---------- */
.snapgrid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.snap {
  display: block; width: 100%; text-align: left; position: relative; overflow: hidden; min-height: 0;
  background: var(--surface); border: 1px solid var(--line); color: var(--txt); border-radius: var(--r-lg); padding: 18px; font-weight: 400;
}
.snap:hover { filter: none; border-color: var(--line-2); }
.snap:active { transform: scale(.99); }
.snap:first-child { padding: 22px 20px; background: radial-gradient(120% 140% at 100% 0%, rgb(76 141 255 / 22%), transparent 55%), radial-gradient(90% 120% at 0% 100%, rgb(167 139 250 / 14%), transparent 60%), var(--surface); border-color: rgb(91 155 255 / 22%); }
.snap .slab { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--mut); font-weight: 500; }
.snap .schip { font-size: 12px; color: var(--mut2); white-space: nowrap; }
.snap .sval { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; color: var(--txt); line-height: 1.1; overflow-wrap: anywhere; }
.snap .sval.neg { color: var(--neg); }
.snap:first-child .sval { font-size: 36px; }
.snap .ssub { font-size: 12.5px; color: var(--mut2); margin-top: 6px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick .quick-main { grid-column: 1 / -1; min-height: 50px; font-size: 15.5px; }

/* ---------- overview dashboard ---------- */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap);
  grid-template-areas: "hero" "month" "quick" "recent" "upcoming" "accts"; }
.ov-hero { grid-area: hero; } .ov-month { grid-area: month; } .ov-quick { grid-area: quick; }
.ov-recent { grid-area: recent; } .ov-accts { grid-area: accts; } .ov-upcoming { grid-area: upcoming; }
.snap.hero .sval { font-size: 38px; }
.ov-hero { display: flex; } .ov-hero .snap.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: stretch; text-align: left; }
.compbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin-top: 16px; gap: 2px; }
.compbar .own { background: var(--pos); border-radius: 999px; }
.compbar .owe { background: var(--neg); border-radius: 999px; }
.comp { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--mut); }
.comp .ci { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.comp b { color: var(--txt); font-weight: 600; }
.comp .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.comp .dot.pos { background: var(--pos); } .comp .dot.neg { background: var(--neg); }
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.mlab { font-size: 12.5px; color: var(--mut); }
.mval { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; overflow-wrap: anywhere; }
.msub { font-size: 12.5px; color: var(--mut2); margin-top: 2px; }
.mcmp { font-size: 13.5px; font-weight: 550; margin-top: 12px; }
.mfoot { padding: 10px 0 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.section-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.section-head .chips.scroll { flex: 1 1 100%; }

/* ---------- lists (transactions, accounts, bills) ---------- */
.list { display: flex; flex-direction: column; }
.list.grouped { gap: 12px; }
.lgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.lhead { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px 6px; font-size: 12.5px; font-weight: 600; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; }
.lhead .tnum { text-transform: none; letter-spacing: 0; }
.lrow {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 16px; text-align: left;
  background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; color: var(--txt); font-weight: 400; cursor: pointer;
}
.lrow:first-child, .lhead + .lrow { border-top: 0; }
.lrow:hover { background: var(--surface-2); filter: none; }
.lrow:active { transform: none; background: var(--surface-3); }
.panel .lrow { padding-left: 0; padding-right: 0; }
.panel.flush .lrow { padding-left: 16px; padding-right: 16px; }
.lico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--mut); font-weight: 700; font-size: 14px; }
.lico svg { width: 18px; height: 18px; }
.lico.in { background: var(--pos-soft); color: var(--pos); }
.lmain { display: block; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.ltitle { display: block; font-size: 15px; font-weight: 550; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lsub { display: block; font-size: 12.5px; line-height: 1.35; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.lamt { display: block; text-align: right; flex: 0 0 auto; max-width: 45%; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lamt .lsub { text-align: right; font-weight: 400; }
.lempty { padding: 28px 16px; text-align: center; color: var(--mut); font-size: 14px; }
.listfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.listfoot .muted { font-size: 13px; }
.lgroup-label { padding: 14px 16px 4px; font-size: 12.5px; font-weight: 600; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; }

/* ---------- tables (desktop-first data, scroll inside panel on phones) ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--mut); background: var(--surface-2); }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tr:last-child td { border-bottom: 0; }
tbody tr[data-id], tr[data-id] { cursor: pointer; }
tr[data-id]:hover td { background: var(--surface-2); }
td.amt, th.amt { text-align: right; }
td.act, th.act { text-align: right; width: 1%; }
.mh { display: none; }
td.act { display: none; }
th.act { display: none; }

/* ---------- bits rendered by app.js ---------- */
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--mut); white-space: nowrap; line-height: 1.6; vertical-align: middle; }
.pill.in, .pill.owed { background: var(--pos-soft); color: var(--pos); }
.pill.out, .pill.owe { background: var(--neg-soft); color: var(--neg); }
.pill.settled { background: var(--surface-3); color: var(--mut); }
.rowact { display: inline-flex; gap: 4px; }
.iconbtn2 { width: var(--tap); min-height: var(--tap); padding: 0; background: transparent; color: var(--mut); border-radius: 10px; }
.iconbtn2:hover { background: var(--surface-3); color: var(--txt); filter: none; }
.iconbtn2.del:hover { color: var(--neg); }
.iconbtn2 svg { width: 18px; height: 18px; }
.blogo { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 800; flex-shrink: 0; font-size: 13px; }
.blogo.sm { width: 22px; height: 22px; border-radius: 7px; font-size: 10px; }
.acctname { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; border-radius: 999px; background: var(--acc); transition: width .6s var(--ease); }
.budgetgrid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 4px; }
.budgtile { background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r); padding: 12px 14px; cursor: pointer; }
.budgtile:hover { border-color: var(--line-2); }
.budgtile .bt-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.budgtile .bt-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budgtile .bt-sub { font-size: 12.5px; color: var(--mut); margin-top: 6px; }
.verdict { border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px; background: var(--surface); }
.verdict .vtop { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict .vdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.verdict .vmsg { color: var(--mut); font-size: 13.5px; margin-top: 6px; }
.verdict.good { border-color: rgb(79 209 161 / 35%); } .verdict.good .vdot { background: var(--pos); }
.verdict.warn { border-color: rgb(232 184 96 / 40%); } .verdict.warn .vdot { background: var(--warn); }
.verdict.bad { border-color: rgb(242 131 123 / 40%); } .verdict.bad .vdot { background: var(--neg); }
.detaillist { display: flex; flex-direction: column; }
.drow { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.drow:last-child { border-bottom: 0; }
.drow .dl { color: var(--mut); font-size: 14px; flex-shrink: 0; }
.drow .dv { font-weight: 600; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 28px 16px; }
.empty .eicon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--mut); margin-bottom: 8px; }
.empty .eicon svg { width: 22px; height: 22px; }
.empty .etitle { font-weight: 600; font-size: 15px; }
.empty .emsg { color: var(--mut); font-size: 13.5px; max-width: 340px; }
.airep { font-size: 14.5px; line-height: 1.6; }
.airep .aih { font-weight: 650; margin: 14px 0 4px; }
.airep .aih:first-child { margin-top: 0; }
.airep .ail { margin: 4px 0 8px; padding-left: 20px; }
.airep code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.aimeta { margin-top: 12px; font-size: 12.5px; }
.chartbox { position: relative; height: 220px; }
.chartbox.tall { height: 260px; }
.chartbox canvas { max-height: 100%; }

/* bento collapses to one column on phones */
.bento { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
.bento > div { display: flex; min-width: 0; }
.bento > div > .panel { flex: 1; }

/* account review + statement import */
.balance-guide, .statement-hub, .review-heading, .statement-row { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.balance-guide h2, .statement-hub h2 { margin-bottom: 4px; }
.review-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; }
.review-item p { margin: 4px 0 8px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.statement-rows { margin-top: 16px; }
.statement-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.statement-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.statement-amount { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.statement-amount .tnum { font-size: 16px; font-weight: 600; margin-right: auto; }
.statement-balances { margin-top: 20px; }
.statement-balances summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--mut); }
.file-button { display: inline-flex; align-items: center; justify-content: center; position: relative; min-height: var(--tap); padding: 10px 16px; margin: 0; border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--txt); font-weight: 600; cursor: pointer; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.sel { user-select: all; -webkit-user-select: all; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.keybox { margin-top: 12px; padding: 14px; border-radius: var(--r-sm); background: var(--bg); border: 1px dashed var(--line-2); }
.keybox code { font-size: 14px; color: var(--txt); }
.codebox { margin: 6px 0 0; padding: 12px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--mut); white-space: pre-wrap; overflow-wrap: anywhere; }
.lrow > button.ghost { flex-shrink: 0; min-height: 38px; padding: 6px 12px; }
.file-button:focus-within { outline: 2px solid var(--acc); outline-offset: 3px; }

/* new-entry hub + smart add */
.entry-primary { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 16px 0 8px; }
.entry-primary button { justify-content: flex-start; gap: 14px; padding: 16px; text-align: left; min-height: 64px; }
.entry-primary strong, .entry-primary small { display: block; }
.entry-primary strong { font-size: 15.5px; }
.entry-primary small { font-size: 12.5px; font-weight: 400; opacity: .8; margin-top: 2px; }
.entry-primary .arrow { margin-left: auto; }
.entry-icon svg { width: 22px; height: 22px; }
.entry-smart { width: 100%; justify-content: flex-start; gap: 12px; padding: 14px 16px; text-align: left; }
.entry-smart svg { width: 20px; height: 20px; }
.entry-details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.entry-details summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--mut); font-weight: 600; }
.entry-details .sheetgrid { margin-top: 6px; }
.scrow { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sclabel { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 14.5px; margin: 0; color: var(--txt); }
.sclabel svg { width: 18px; height: 18px; }
#scMic.rec { background: var(--neg-soft); border-color: rgb(242 131 123 / 50%); }

/* ---------- modal: centred card on desktop, bottom sheet on phones ---------- */
.modal-back { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / 62%); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--enter) var(--ease), visibility 0s linear var(--enter); }
.modal-back.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--enter) var(--ease), visibility 0s; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100dvh - 24px - var(--safe-t)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-b)); box-shadow: var(--shadow);
  transform: translateY(24px); transition: transform var(--enter) var(--ease);
}
.modal::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 4px auto 10px; }
.modal-back.show .modal { transform: none; }
.modal .mhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.modal .mhead h3 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal .mclose { width: var(--tap); height: var(--tap); padding: 0; flex-shrink: 0; background: var(--surface-2); color: var(--mut); border-radius: 50%; font-size: 18px; }
.modal .formgrid { margin-top: 14px; }
.modal .mactions {
  position: sticky; bottom: calc(-18px - var(--safe-b)); display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 18px -18px calc(-18px - var(--safe-b)); padding: 12px 18px calc(12px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
}
.modal .mactions .grow { flex: 1; }
.modal .mactions button { flex: 1 1 auto; }
.modal .mactions button.danger { flex: 0 0 auto; }
.modal .mactions .grow + button.ghost { flex: 0 1 auto; }
.confirm-layer { z-index: 150; }
.confirm-layer .modal::before { display: none; }

/* ---------- bottom navigation ---------- */
nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 6px var(--safe-b);
  background: rgb(14 19 26 / 90%); backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
}
nav.tabbar .tb { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; background: none; border: 0; border-radius: 0; color: var(--mut2); font-size: 11px; font-weight: 600; }
nav.tabbar .tb svg { width: 24px; height: 24px; }
nav.tabbar .tb.on { color: var(--txt); }
nav.tabbar .tb.on svg { color: var(--acc); }
nav.tabbar .tb .dot { display: none; }
nav.tabbar .fab-slot { flex: 0 0 72px; visibility: hidden; }
.fab {
  position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); z-index: 42; transform: translateX(-50%);
  width: 56px; height: 56px; padding: 0; border-radius: 18px; background: var(--grad); color: #fff; box-shadow: 0 10px 26px rgb(76 141 255 / 40%);
}
.fab:active { transform: translateX(-50%) scale(.96); }
/* signed out or still loading: no navigation chrome */
#app.hidden ~ nav.tabbar, #app.hidden ~ .fab { display: none; }
.fab svg { width: 26px; height: 26px; }

/* "More" sheet */
.sheet-back { position: fixed; inset: 0; z-index: 45; background: rgb(0 0 0 / 55%); opacity: 0; pointer-events: none; transition: opacity var(--enter); }
.sheet-back.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-top: 1px solid var(--line-2); border-radius: 22px 22px 0 0;
  padding: 6px 16px calc(20px + var(--safe-b)); transform: translateY(105%); visibility: hidden;
  transition: transform var(--enter) var(--ease), visibility 0s linear var(--enter);
}
.sheet.show { transform: none; visibility: visible; transition: transform var(--enter) var(--ease), visibility 0s; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 6px auto 12px; }
.sheetgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sheetgrid .navgroup { grid-column: 1 / -1; padding: 10px 2px 2px; }
.sheetitem { flex-direction: column; gap: 8px; min-height: 78px; padding: 12px 6px; border-radius: var(--r); background: var(--surface-2); border: 1px solid transparent; color: var(--txt); font-size: 12.5px; font-weight: 550; text-align: center; }
.sheetitem svg { width: 22px; height: 22px; color: var(--mut); }
.sheetitem.on { border-color: rgb(91 155 255 / 40%); background: var(--acc-soft); }
.sheetitem.on svg { color: var(--acc); }
.navgroup { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--mut2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + var(--safe-b)); z-index: 300; transform: translate(-50%, 16px); max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-2); color: var(--txt); font-size: 14px; font-weight: 550; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity var(--enter), transform var(--enter) var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- larger phones + tablets ---------- */
@media (min-width: 420px) {
  .quick { grid-template-columns: 2fr 1fr 1fr; }
  .quick .quick-main { grid-column: auto; }
  .budgetgrid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 600px) {
  :root { --pad: 20px; --gap: 14px; }
  main { padding: 20px 20px calc(var(--tabbar-h) + 32px + var(--safe-b)); }
  .chips.scroll { margin: 0; padding: 2px 0; flex-wrap: wrap; overflow: visible; }
  .section-head .chips.scroll { flex: 0 1 auto; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .snapgrid { grid-template-columns: 1.4fr 1fr; }
  .formgrid { grid-template-columns: 1fr 1fr; }
  .formgrid.two { grid-template-columns: 2fr 1fr; }
  .mh, td.act, th.act { display: table-cell; }
  .balance-guide, .statement-hub, .review-heading, .statement-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .statement-amount .tnum { margin-right: 0; }
  .entry-primary { grid-template-columns: 1fr 1fr; }
  .modal-back { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; border-bottom: 1px solid var(--line-2); padding: 22px 24px 24px; max-height: calc(100dvh - 48px); }
  .modal::before { display: none; }
  .modal .mactions { bottom: -24px; margin: 20px -24px -24px; padding: 14px 24px; }
  .modal .mactions button { flex: 0 0 auto; }
}

/* ---------- desktop: sidebar replaces tab bar ---------- */
@media (min-width: 900px) {
  :root { --pad: 22px; --gap: 16px; }
  aside.side {
    display: flex; flex-direction: column; gap: 2px; position: fixed; top: 0; left: 0; z-index: 35; width: 248px; height: 100dvh; overflow-y: auto;
    padding: 22px 14px; background: var(--bg); border-right: 1px solid var(--line);
  }
  .side .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 20px; }
  .side .brand img { width: 36px; height: 36px; border-radius: 10px; }
  .side .brand b { font-size: 17px; font-weight: 700; display: block; }
  .side .brand small { font-size: 12px; color: var(--mut2); }
  .side .navgroup { padding: 16px 12px 6px; }
  .side .who { margin-top: auto; padding: 14px 12px 0; font-size: 12px; color: var(--mut2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .navitem { width: 100%; justify-content: flex-start; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: 10px; background: transparent; color: var(--mut); font-size: 14px; font-weight: 550; }
  .navitem:hover { background: var(--surface); color: var(--txt); filter: none; }
  .navitem.on { background: var(--surface-2); color: var(--txt); }
  .navitem.on svg { color: var(--acc); }
  .navitem svg { width: 19px; height: 19px; }
  .content { margin-left: 248px; }
  header.top { padding: 14px 28px; min-height: 64px; background: rgb(11 15 20 / 92%); }
  header.top .ttl { font-size: 22px; }
  #topAdd { display: inline-flex; }
  main { padding: 24px 28px 48px; }
  nav.tabbar, .fab { display: none; }
  main { margin: 0; max-width: 1440px; }
  .ov-quick { display: none; }
  .ov-grid { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
    grid-template-areas: "hero month" "recent accts" "recent upcoming"; align-items: start; }
  .ov-recent { align-self: stretch; }
  .ov-hero { align-self: stretch; }
  .snap.hero { height: 100%; }
  .ov-month { height: 100%; }
  .toast { bottom: 28px; }
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .bento .b2 { grid-column: span 2; } .bento .b3 { grid-column: span 3; }
  .bento .b4 { grid-column: span 4; } .bento .b6 { grid-column: span 6; }
  .chartbox { height: 260px; }
  .chartbox.tall { height: 300px; }
  .budgetgrid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ---------- motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .view:not(.hidden) { animation: view-in 200ms var(--ease); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
