/* Kitsouk Budget. Phone-first (min-width queries), Kitsouk palette.
   No font weight above 500 anywhere: hierarchy comes from size, colour and space. */

/* Bricolage Grotesque (SIL Open Font License, fonts/OFL.txt), shipped inside the app so it works offline. */
@font-face {
  font-family: "Bricolage Grotesque"; src: url('../fonts/bricolage-grotesque.woff2') format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}

:root {
  --ink: #1F2A37;
  --ink-2: #3E4A58;
  --muted: #5F6773;
  --bg: #F4EDE1;
  --card: #FFFCF7;
  --card-2: #FAF4EA;
  --sand-2: #EDE3D3;
  --line: #E2D6C3;
  --teal: #1F6F6B;
  --teal-hover: #185955;
  --teal-ink: #1F6F6B;
  --on-teal: #FFFFFF;
  --teal-soft: #E1EEEC;
  --saffron: #E3A72F;
  --saffron-soft: #FBEBC4;
  --terra: #C0533A;
  --terra-ink: #A3412B;
  --terra-soft: #FBEDE8;
  --good: #1F6F6B;
  --focus: #1F6F6B;
  --chart-1: #008A7E;
  --chart-2: #B8771A;
  --chart-grid: #E9DFCF;
  --shadow: 0 1px 2px rgba(31, 42, 55, .05), 0 8px 24px rgba(31, 42, 55, .06);
  --shadow-lg: 0 2px 6px rgba(31, 42, 55, .06), 0 18px 40px rgba(31, 42, 55, .12);
  --line-soft: #EAE0D0;
  --backdrop: rgba(31, 42, 55, .45);
  --radius: 22px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Bricolage Grotesque", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-num: var(--display);
  /* the hero panel keeps its own dark ground in both themes */
  --hero-a: #1F6F6B; --hero-b: #164F4C; --hero-glow: rgba(227, 167, 47, .22);
  --hero-ink: #FFFCF7; --hero-ink-2: #E3EFEC; --hero-chip: rgba(10, 30, 32, .3); --hero-track: rgba(255, 252, 247, .2);
  --short-a: #9A4430; --short-b: #7A3022; --short-ink-2: #F8E6E0;
  /* category marks: tint and letter, by group */
  --g-income-bg: #E1EEEC; --g-income-fg: #1F6F6B;
  --g-bills-bg: #E3EAF1; --g-bills-fg: #34506B;
  --g-everyday-bg: #FBEBC4; --g-everyday-fg: #765010;
  --g-savings-bg: #E4EEE5; --g-savings-fg: #3D6444;
  --g-debt-bg: #FBEDE8; --g-debt-fg: #A3412B;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #F4EDE1; --ink-2: #D9D0C2; --muted: #ABA396; --bg: #141B24; --card: #1C2531; --card-2: #222D3A;
    --sand-2: #2A3544; --line: #313D4C; --teal: #5FB3AC; --teal-hover: #79C3BD; --teal-ink: #6FC0B9; --on-teal: #0F1720;
    --teal-soft: #203A3D; --saffron: #E3A72F; --saffron-soft: #3A3122; --terra: #E07A62; --terra-ink: #EE927C; --terra-soft: #3A2620;
    --good: #6FC0B9; --focus: #E3A72F; --chart-1: #14A091; --chart-2: #BE851A; --chart-grid: #2C3846;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --backdrop: rgba(0, 0, 0, .6); color-scheme: dark;
    --line-soft: #283342; --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .45);
    --hero-a: #18534F; --hero-b: #0F3A38; --hero-glow: rgba(227, 167, 47, .16); --short-a: #7E3424; --short-b: #5E251A;
    --g-income-bg: #203A3D; --g-income-fg: #8FD3CC; --g-bills-bg: #243243; --g-bills-fg: #A9C3DD; --g-everyday-bg: #3A3122; --g-everyday-fg: #EBC57A;
    --g-savings-bg: #23362A; --g-savings-fg: #A6CDAE; --g-debt-bg: #3A2620; --g-debt-fg: #EE927C;
  }
}
:root[data-theme="dark"] {
  --ink: #F4EDE1; --ink-2: #D9D0C2; --muted: #ABA396; --bg: #141B24; --card: #1C2531; --card-2: #222D3A;
  --sand-2: #2A3544; --line: #313D4C; --teal: #5FB3AC; --teal-hover: #79C3BD; --teal-ink: #6FC0B9; --on-teal: #0F1720;
  --teal-soft: #203A3D; --saffron: #E3A72F; --saffron-soft: #3A3122; --terra: #E07A62; --terra-ink: #EE927C; --terra-soft: #3A2620;
  --good: #6FC0B9; --focus: #E3A72F; --chart-1: #14A091; --chart-2: #BE851A; --chart-grid: #2C3846;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --backdrop: rgba(0, 0, 0, .6); color-scheme: dark;
  --line-soft: #283342; --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .45);
  --hero-a: #18534F; --hero-b: #0F3A38; --hero-glow: rgba(227, 167, 47, .16); --short-a: #7E3424; --short-b: #5E251A;
  --g-income-bg: #203A3D; --g-income-fg: #8FD3CC; --g-bills-bg: #243243; --g-bills-fg: #A9C3DD; --g-everyday-bg: #3A3122; --g-everyday-fg: #EBC57A;
  --g-savings-bg: #23362A; --g-savings-fg: #A6CDAE; --g-debt-bg: #3A2620; --g-debt-fg: #EE927C;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5;
  font-weight: 400; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4, strong, b, th, legend, summary, dt, optgroup { font-weight: 500; }
optgroup { font-style: normal; }
h1, h2 { font-family: var(--display); letter-spacing: -0.015em; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 8px; }
h2 { font-size: 19px; line-height: 1.3; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--teal-ink); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { width: 22px; height: 22px; flex: none; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }
.sr-only, .offscreen { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.offscreen { left: -9999px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.noscript { padding: 24px; }
.boot-msg { padding: 40px 0; color: var(--muted); text-align: center; }
html.booting .boot-msg { opacity: .7; }

/* ------------------------------------------------------------------ layout */
.layout { min-height: 100vh; min-height: 100dvh; }
.main { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(var(--tab-h) + var(--safe-b) + 44px); }
.main:focus { outline: none; }
body.in-setup .main { padding-bottom: 40px; }
.sidebar { display: none; }

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); z-index: 20; max-width: 560px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 26px; box-shadow: var(--shadow-lg);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar { background: color-mix(in srgb, var(--card) 84%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); }
}
body.in-setup .tabbar { display: none; }
.tabbar ul { list-style: none; margin: 0; padding: 0 6px; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tab-h);
  color: var(--muted); text-decoration: none; font-size: 12px; background: none; border: 0; width: 100%; cursor: pointer; position: relative;
}
.tab .icon { width: 46px; height: 28px; padding: 3px 12px; border-radius: 14px; transition: background-color .2s; }
.tab[aria-current="page"] { color: var(--teal-ink); }
.tab[aria-current="page"] .icon { background: var(--teal-soft); }
.tab-add { color: var(--ink-2); }
.tab-add .icon { width: 52px; height: 52px; padding: 13px; border-radius: 18px; background: var(--saffron); color: #1F2A37; margin-top: -26px;
  box-shadow: 0 0 0 5px var(--bg), 0 8px 18px rgba(176, 120, 20, .35); }
.tab-add:active .icon { transform: scale(.94); }

#banner .banner { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: center; padding: 10px 16px; font-size: 14px; background: var(--saffron-soft); color: var(--ink); text-align: center; }
#banner .banner-warn { background: var(--terra-soft); }
#banner .banner a { color: var(--ink); }

@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: 248px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; height: 100vh; overflow: auto;
    background: var(--card); border-right: 1px solid var(--line); padding: 24px 16px;
  }
  body.in-setup .sidebar { display: none; }
  body.in-setup .layout { display: block; }
  .tabbar { display: none; }
  .main { max-width: 1040px; width: 100%; padding: 32px 40px 64px; }
  .sidebar ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
  .side-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; padding: 0 8px 8px; }
  .side-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink-2); text-decoration: none; }
  .side-link:hover { background: var(--card-2); }
  .side-link[aria-current="page"] { background: var(--teal-soft); color: var(--teal-ink); }
  .btn.side-add { width: 100%; background: var(--saffron); color: #1F2A37; }
  .btn.side-add:hover { background: #EDB443; }
}

.logo { flex: none; border-radius: 22%; }

/* ------------------------------------------------------------------ text helpers */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.center { text-align: center; }
.warn-text { color: var(--terra-ink); }
.good-text { color: var(--good); }
.lead { font-size: 17px; color: var(--ink-2); }
.eyebrow { font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--teal-ink); margin-bottom: 6px; }
.today-line { color: var(--muted); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 6px 2px 14px; }
.page-head { margin: 4px 0 18px; }
.page-head h1 { font-size: 32px; }
.page-head .intro { color: var(--muted); max-width: 60ch; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--teal-ink); text-decoration: none; margin-left: -6px; }
.back-link .icon { width: 20px; height: 20px; }
@media (min-width: 960px) { .back-link { display: none; } }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 14px; border: 1px solid transparent; font-size: 16px; font-weight: 500; line-height: 1.2; cursor: pointer;
  text-decoration: none; background: var(--card-2); color: var(--ink); transition: background-color .15s, transform .1s; text-align: center;
}
.btn .icon { width: 20px; height: 20px; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--teal); color: var(--on-teal); }
.btn-primary:hover { background: var(--teal-hover); }
.btn-secondary { background: var(--teal-soft); color: var(--teal-ink); }
.btn-secondary:hover { border-color: var(--teal); }
.btn-ghost { background: transparent; color: var(--teal-ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--card-2); }
.btn-ghost.danger { color: var(--terra-ink); }
.btn-danger { background: var(--terra-ink); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1A1210; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #1A1210; } }
.btn-big { min-height: 56px; font-size: 18px; width: 100%; border-radius: 16px; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row.end { justify-content: flex-end; }
.btn-row.spread { justify-content: space-between; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--ink-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--card-2); }
.icon-spacer { width: 44px; }
.linkish { background: none; border: 0; padding: 10px 2px; min-height: 44px; color: var(--teal-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-more { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-top: 4px; text-decoration: none; }
.link-more .icon { width: 18px; height: 18px; }
.stack { display: grid; gap: 10px; margin-top: 22px; }

/* ------------------------------------------------------------------ cards and panels */
.card, .panel { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(31, 42, 55, .04); }
.panel { padding: 18px 18px; margin: 0 0 16px; }
.panel-title { font-size: 18px; margin-bottom: 10px; }
.panel-head .panel-title { margin-bottom: 6px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.panel-total { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.panel-foot { color: var(--muted); font-size: 14px; margin: 10px 0 12px; }
.sub-title { font-size: 16px; margin: 22px 0 8px; }
.card-note { padding: 16px; margin-bottom: 14px; border-left: 4px solid var(--saffron); }
.card-note h2 { font-size: 16px; margin-bottom: 4px; }
.card-note p { color: var(--ink-2); }
.card-note .btn-row { margin-top: 8px; }

/* hero: the one number, on its own teal ground */
.hero {
  position: relative; overflow: hidden; isolation: isolate; color: var(--hero-ink); border-radius: 28px; padding: 22px 20px 20px; margin-bottom: 14px;
  background: radial-gradient(120% 90% at 100% 0%, var(--hero-glow), transparent 55%), linear-gradient(160deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 2px 6px rgba(22, 79, 76, .18), 0 22px 48px rgba(22, 79, 76, .28); animation: hero-in .5s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes hero-in { from { transform: translateY(10px) scale(.985); } to { transform: none; } }
.hero.is-short { background: radial-gradient(120% 90% at 100% 0%, rgba(255, 196, 160, .18), transparent 55%), linear-gradient(160deg, var(--short-a), var(--short-b));
  box-shadow: 0 2px 6px rgba(122, 48, 34, .2), 0 22px 48px rgba(122, 48, 34, .3); }
.hero :focus-visible { outline-color: var(--hero-ink); }
.hero a { color: var(--hero-ink); }
.hero-label { color: var(--hero-ink-2); font-size: 15px; margin: 0; }
.hero-number {
  font-family: var(--display); font-weight: 500; font-size: clamp(60px, 19vw, 88px); line-height: 1; letter-spacing: -0.035em; margin: 12px 0 10px;
  color: var(--hero-ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
.hero-number .cents { font-size: .46em; letter-spacing: -0.01em; color: var(--hero-ink-2); margin-left: 2px; }
.hero-number.is-text { font-size: clamp(38px, 11vw, 56px); letter-spacing: -0.025em; }
.hero-sub { font-size: 17px; color: var(--hero-ink-2); margin: 0 0 4px; }
.hero.is-short .hero-sub, .hero.is-short .hero-label, .hero.is-short .cycle-row, .hero.is-short .hero-help { color: var(--short-ink-2); }
.cycle { margin: 16px 0 4px; }
.cycle-track { display: block; height: 6px; border-radius: 3px; background: var(--hero-track); overflow: hidden; }
.cycle-fill { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--saffron); transition: width .6s cubic-bezier(.2, .7, .2, 1); }
.cycle-row { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin: 8px 0 0; font-size: 13px; color: var(--hero-ink-2); }
.btn-hero { width: 100%; min-height: 56px; margin-top: 16px; border-radius: 18px; font-size: 18px; background: var(--saffron); color: #1F2A37;
  box-shadow: 0 6px 16px rgba(10, 30, 32, .25); }
.btn-hero:hover { background: #EDB443; }
.hero-help { font-size: 14px; color: var(--hero-ink-2); margin: 12px 0 0; }

/* the warning about a pay period ahead */
.alert { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; border-radius: 18px; background: var(--saffron-soft); color: var(--ink); font-size: 15px; }
.alert .icon { width: 20px; height: 20px; margin-top: 1px; color: #8A5A0C; flex: none; }
.alert a { color: var(--ink); }

/* the breakdown under the number */
.how { padding: 4px 18px; }
.how summary { display: flex; align-items: center; gap: 10px; min-height: 52px; cursor: pointer; color: var(--teal-ink); list-style: none; font-weight: 400; }
.how summary span { flex: 1; }
.how summary::-webkit-details-marker { display: none; }
.how summary .icon { width: 20px; height: 20px; }
.how summary .chev { color: var(--muted); transition: transform .2s; }
.how[open] summary .chev { transform: rotate(90deg); }
.how[open] { padding-bottom: 16px; }
.how-list { margin: 4px 0 8px; }
.how-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.how-row dt { font-weight: 400; color: var(--ink-2); }
.how-row dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.how-row.sub { padding-left: 14px; font-size: 14px; }
.how-row.sub dt { color: var(--muted); }
.how-row.strong dt, .how-row.total dt { color: var(--ink); font-weight: 500; }
.how-row.total { border-bottom: 0; border-top: 1px solid var(--ink-2); margin-top: 4px; font-weight: 500; }
.how .btn { margin-top: 10px; }

@media (min-width: 960px) {
  .home-grid { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 24px; align-items: start; }
  .home-main { position: sticky; top: 24px; }
  .hero { padding: 28px 28px 24px; }
}

/* rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.rows > .row:last-child { border-bottom: 0; }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.row-title { overflow-wrap: anywhere; }
.row-sub { font-size: 14px; color: var(--muted); }
.row-sub.warn-text { color: var(--terra-ink); }
.row-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-amt.pos { color: var(--good); }
.row .row-amt { font-family: var(--display); font-size: 17px; letter-spacing: -0.01em; }
.date-tile { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 46px; height: 50px; flex: none;
  border-radius: 14px; background: var(--card-2); border: 1px solid var(--line-soft); line-height: 1.1; }
.dt-wd { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dt-d { font-family: var(--display); font-size: 20px; color: var(--ink); }
.date-tile.late { background: var(--terra-soft); border-color: transparent; }
.check-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--teal); background: transparent; color: var(--teal-ink); cursor: pointer; transition: background-color .15s, color .15s; }
.check-btn .icon { width: 20px; height: 20px; }
.check-btn:hover, .check-btn:active { background: var(--teal); color: var(--on-teal); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  font-family: var(--display); font-size: 17px; background: var(--g-everyday-bg); color: var(--g-everyday-fg); }
.avatar.g-income { background: var(--g-income-bg); color: var(--g-income-fg); }
.avatar.g-bills { background: var(--g-bills-bg); color: var(--g-bills-fg); }
.avatar.g-savings { background: var(--g-savings-bg); color: var(--g-savings-fg); }
.avatar.g-debt { background: var(--g-debt-bg); color: var(--g-debt-fg); }
.row-bar { flex-wrap: wrap; }
.row-bar .row-main { flex-basis: calc(100% - 60px); }
.row-bar .bar { order: 3; flex-basis: calc(100% - 56px); }
.rank { width: 28px; height: 28px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-ink); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none; }
.mini-rows { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.mini-rows li { display: flex; gap: 10px; padding: 4px 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mini-rows .grow { flex: 1; }

.bar { display: block; height: 8px; border-radius: 4px; background: var(--sand-2); overflow: hidden; }
.bar.big { height: 12px; border-radius: 6px; margin: 8px 0 12px; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--teal); }
.bar.over .bar-fill { background: var(--terra); }
.bar.noplan .bar-fill { background: var(--muted); opacity: .45; }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tile { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 14px; border-radius: 16px; background: var(--card-2); color: var(--ink); text-decoration: none; }
.tile .icon:first-child { width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--teal-soft); }
.tile span { flex: 1; }
.tile .chev { width: 18px; height: 18px; color: var(--muted); }
.tile .icon:first-child { color: var(--teal-ink); }

.menu { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.menu li + li { border-top: 1px solid var(--line-soft); }
.menu-link { display: flex; align-items: center; gap: 14px; min-height: 62px; padding: 0 16px; color: var(--ink); text-decoration: none; }
.menu-link span { flex: 1; }
.menu-link .icon:first-child { color: var(--teal-ink); width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--teal-soft); }
.menu-link .chev { color: var(--muted); width: 18px; height: 18px; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--saffron-soft); color: var(--ink); font-size: 13px; margin-right: 8px; }

/* ------------------------------------------------------------------ forms */
.field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field > label, legend { display: block; margin-bottom: 6px; color: var(--ink); font-weight: 500; font-size: 15px; padding: 0; }
input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 16px; appearance: none; -webkit-appearance: none;
}
input[type="date"] { min-width: 0; display: block; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--terra); }
input::placeholder { color: var(--muted); opacity: 1; }
.error { color: var(--terra-ink); font-size: 14px; margin: 6px 0 0; }
.money-input { position: relative; display: flex; align-items: center; }
.money-input input { padding-left: 34px; }
.money-input .money-sym { position: absolute; left: 12px; color: var(--muted); pointer-events: none; max-width: 40px; overflow: hidden; }
.money-input .money-sym.after { left: auto; right: 12px; }
.money-input:has(.money-sym.after) input { padding-left: 12px; padding-right: 48px; }
.two-col { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 480px) { .two-col { grid-template-columns: 1fr 1fr; } }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-list { display: grid; gap: 8px; }
.choice { position: relative; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; }
.choice input { width: 20px; height: 20px; accent-color: var(--teal); margin: 0; flex: none; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input:focus-visible { outline: none; }
.choice-text { display: flex; flex-direction: column; }
.choice-hint { font-size: 14px; color: var(--muted); }
.choice-list.compact .choice { min-height: 44px; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); margin: 1px 0 0; flex: none; }
.sub-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.sub-box legend { padding: 0 4px; }
.field.inline { display: grid; gap: 6px; }
.file-pick { position: relative; margin: 6px 0 4px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon.flip-y { transform: scaleY(-1); }
.confirm, .confirm-box { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); }
.danger-zone { border-color: var(--terra); }

/* chips */
.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
@media (min-width: 720px) { .chips.scroll2 { display: flex !important; flex-wrap: wrap; overflow: visible; } }
.chips.scroll2 { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: max-content; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-soft); background: var(--card-2); color: var(--ink); cursor: pointer; white-space: nowrap; font-size: 15px; scroll-snap-align: start; }
.chip-radio { padding: 0; position: relative; }
.chip-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radio span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; }
.chip-radio:has(input:checked) { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.chip-radio:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 0; margin: 0 0 8px; background: var(--card-2); border-radius: 14px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 10px; color: var(--ink-2); cursor: pointer; font-size: 15px; }
.seg-opt input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(31, 42, 55, .12); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ------------------------------------------------------------------ sheet (dialog) */
.sheet {
  border: 0; padding: 0; margin: 0; color: var(--ink); background: var(--card); width: 100%; max-width: 100%;
  max-height: 94vh; max-height: 94dvh; position: fixed; inset: auto 0 0 0; border-radius: 26px 26px 0 0; overflow: auto;
  overscroll-behavior: contain; box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
}
.sheet::backdrop { background: var(--backdrop); }
.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-inner { padding: 6px 16px calc(18px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; background: var(--card); padding-top: 8px; z-index: 2; }
.sheet-head h2 { margin: 0; font-size: 20px; }
body.sheet-open { overflow: hidden; }
@media (min-width: 720px) {
  .sheet { inset: 0; margin: auto; width: min(480px, calc(100vw - 48px)); max-height: min(860px, calc(100vh - 48px)); border-radius: 22px; height: fit-content; }
  .sheet.sheet-wide { width: min(640px, calc(100vw - 48px)); }
  .sheet-inner { padding: 8px 24px 24px; }
}

/* quick add */
.qa-amount { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 6px 0 2px; }
.qa-sym { font-family: var(--font-num); font-size: 30px; color: var(--muted); }
.qa-amount input {
  font-family: var(--font-num); font-size: 52px; letter-spacing: -0.02em; line-height: 1.1; text-align: center; border: 0; background: transparent; width: 3ch;
  max-width: 100%; min-height: 60px; padding: 0; color: var(--ink); border-radius: 12px; caret-color: var(--teal);
}
.qa-touch .qa-amount input { caret-color: transparent; }
.qa-amount input:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--teal); border-radius: 0; }
.qa-cats { border: 0; padding: 0; margin: 6px 0 2px; min-width: 0; }
.qa-link { min-height: 0; }
.qa-link .check { font-size: 15px; padding: 6px 0; }
.qa-extra { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin: 6px 0 10px; }
.qa-date label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.qa-date input { width: 160px; min-height: 44px; }
.qa-note input { min-height: 44px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 12px; }
.key {
  min-height: 56px; border-radius: 16px; border: 0; background: var(--card-2); color: var(--ink); font-family: var(--font-num); font-size: 26px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--sand-2); }
.key .icon { width: 26px; height: 26px; }
.key-blank { background: transparent; }
@media (max-height: 700px) { .key { min-height: 46px; } .qa-amount input { font-size: 40px; min-height: 52px; } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 26px); transform: translate(-50%, 16px); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; width: max-content; max-width: calc(100vw - 32px);
}
body.in-setup .toast, body.sheet-open .toast { bottom: calc(var(--safe-b) + 16px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-inner { display: flex; align-items: center; gap: 14px; background: #1F2A37; color: #F4EDE1; padding: 10px 10px 10px 16px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast-undo { background: transparent; border: 0; color: var(--saffron); min-height: 40px; padding: 0 10px; cursor: pointer; font-weight: 500; }
@media (min-width: 960px) { .toast { bottom: 28px; left: calc(50% + 124px); } }

/* ------------------------------------------------------------------ pay periods */
.periods { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.period { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(31, 42, 55, .04); }
.period.is-current { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal), 0 10px 26px rgba(22, 79, 76, .12); }
.period.is-current .badge { background: var(--teal); color: var(--on-teal); }
.period.is-short { border-color: var(--terra); background: var(--terra-soft); box-shadow: 0 0 0 1px var(--terra); }
.period-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.period-range { margin: 0; font-size: 16px; font-weight: 500; }
.period-meta { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.period-left { text-align: right; }
.period-left-label { margin: 0; font-size: 13px; color: var(--muted); }
.period-left-num { margin: 0; font-family: var(--font-num); font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; white-space: nowrap; }
.period.is-short .period-left-num { color: var(--terra-ink); font-size: 20px; }
.period-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.period-rows div { background: var(--card-2); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.period.is-short .period-rows div { background: var(--card); }
.period-rows dt { font-size: 13px; color: var(--muted); font-weight: 400; display: flex; align-items: center; gap: 6px; }
.pkey { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--teal); }
.pkey-bills { background: var(--g-bills-fg); }
.pkey-save { background: var(--saffron); }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--sand-2); margin: 14px 0 2px; gap: 2px; }
.sp { display: block; height: 100%; width: 0; flex: none; }
.sp-bills { background: var(--g-bills-fg); }
.sp-save { background: var(--saffron); }
.sp-left { background: var(--teal); }
.period.is-short .split { box-shadow: 0 0 0 2px var(--terra); }
.period-rows dd { margin: 0; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; letter-spacing: -0.01em; }
@media (max-width: 420px) { .period-rows { gap: 6px; } .period-rows div { padding: 8px 8px; } .period-rows dd { font-size: 14px; } }
.period-bills summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--teal-ink); font-weight: 400; }
.period-foot { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 12px; margin-top: 2px; }
.period-foot > p { margin: 12px 0 0; }
.period-foot details[open] { grid-column: 1 / -1; }
.period-foot .linkish { justify-self: end; }
@media (min-width: 960px) { .periods { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------------ month */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px 0 12px; }
.month-name { margin: 0; font-size: 20px; }
.stat-tiles { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line-soft); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; }
.stat.stat-left { grid-column: 1 / -1; border: 0; color: var(--hero-ink); background: linear-gradient(160deg, var(--hero-a), var(--hero-b)); }
.stat.stat-left.warn { background: linear-gradient(160deg, var(--short-a), var(--short-b)); }
.stat.stat-left .stat-label { color: var(--hero-ink-2); }
.stat.stat-left .stat-num, .stat.stat-left.warn .stat-num { color: var(--hero-ink); font-size: 30px; letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-num { font-family: var(--font-num); font-size: 20px; overflow-wrap: anywhere; }
.stat.warn .stat-num { color: var(--terra-ink); }
@media (min-width: 640px) { .stat-tiles { grid-template-columns: repeat(5, 1fr); } .stat.stat-left { grid-column: auto; } .stat.stat-left .stat-num { font-size: 22px; } }
.month-cols { display: grid; gap: 16px; }

/* ------------------------------------------------------------------ debts */
.debt-hero { border-radius: 20px; padding: 18px 18px 20px; margin-bottom: 14px; color: var(--hero-ink);
  background: radial-gradient(120% 90% at 100% 0%, var(--hero-glow), transparent 55%), linear-gradient(160deg, var(--hero-a), var(--hero-b)); }
.debt-hero-label { margin: 0; color: var(--hero-ink-2); font-size: 14px; }
.debt-hero-date { margin: 4px 0 0; font-family: var(--font-num); font-size: 38px; line-height: 1.1; letter-spacing: -0.02em; color: var(--hero-ink); }
.kv { margin: 0; display: grid; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv div:last-child { border-bottom: 0; }
.kv dt { font-weight: 400; color: var(--ink-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
@media (min-width: 960px) { .debt-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; align-items: start; } }
.legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 8px; }
.lkey { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--chart-1); vertical-align: middle; flex: none; }
.lkey-min { border-top: 2px dashed var(--chart-2); }
.chart { position: relative; margin: 0; }
.chart-svg { width: 100%; touch-action: pan-y; border-radius: 12px; }
.chart-svg svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .ln-plan { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln-min { fill: none; stroke: var(--chart-2); stroke-width: 2; stroke-dasharray: 6 5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area-plan { fill: var(--chart-1); opacity: .1; }
.chart .dot-plan { fill: var(--chart-1); stroke: var(--card); stroke-width: 2; }
.chart .dot-min { fill: var(--chart-2); stroke: var(--card); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; top: 8px; transform: translateX(10px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow); pointer-events: none; min-width: 150px; }
.chart-tip.flip { transform: translateX(calc(-100% - 10px)); }
.chart-tip p { margin: 0; display: flex; align-items: center; gap: 6px; }
.chart-tip .tip-head { color: var(--muted); margin-bottom: 2px; }
.chart-tip .tip-val { font-variant-numeric: tabular-nums; font-weight: 500; }
.table-view { margin-top: 10px; }
.table-view summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--teal-ink); font-weight: 400; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); font-weight: 400; }
.table-view th:first-child { text-align: left; }
.table-view thead th { color: var(--muted); }

/* goals */
.goal-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.goal { padding: 16px; }
.goal-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.goal-head h2 { margin: 0; }
.goal-amount { font-family: var(--font-num); font-size: 26px; letter-spacing: -0.015em; margin: 8px 0 0; }

/* activity */
.day-group { margin-bottom: 8px; }
.day-title { font-size: 14px; color: var(--muted); margin: 18px 0 2px; font-weight: 400; }
.row-balance .row-title { color: var(--muted); }

/* ------------------------------------------------------------------ setup */
.setup-wrap { max-width: 520px; margin: 0 auto; padding-top: 12px; }
.setup { padding: 8px 0 24px; }
.setup h1 { font-size: 28px; }
.setup-welcome { text-align: left; padding-top: 16px; }
.setup-welcome h1 { font-size: 34px; line-height: 1.12; margin-bottom: 14px; }
.welcome-mark { margin-bottom: 18px; }
.welcome-panel { color: var(--hero-ink); border-radius: 28px; padding: 26px 22px 22px; margin-bottom: 4px;
  background: radial-gradient(120% 90% at 100% 0%, var(--hero-glow), transparent 55%), linear-gradient(160deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 2px 6px rgba(22, 79, 76, .18), 0 22px 48px rgba(22, 79, 76, .28); animation: hero-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.welcome-panel .eyebrow { color: var(--saffron); }
.welcome-panel h1 { color: var(--hero-ink); font-size: 34px; }
.welcome-panel .lead { color: var(--hero-ink-2); }
.welcome-time { color: var(--hero-ink-2); font-size: 14px; }
.welcome-panel :focus-visible { outline-color: var(--hero-ink); }
.welcome-mark .logo { box-shadow: 0 0 0 3px rgba(255, 252, 247, .25); }
.setup-progress { margin-bottom: 18px; }
.step-count { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--sand-2); overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--teal); border-radius: 4px; transition: width .4s cubic-bezier(.2, .7, .2, 1); }
.progress-fill.p1 { width: 20%; } .progress-fill.p2 { width: 40%; } .progress-fill.p3 { width: 60%; } .progress-fill.p4 { width: 80%; } .progress-fill.p5 { width: 100%; }
.setup-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
.setup-nav .btn-primary { flex: 1; max-width: 260px; margin-left: auto; }
.bill-mini { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0 8px; }
.list-title { font-size: 16px; margin: 18px 0 4px; }
.irr-list { list-style: none; margin: 0; padding: 0; }
.irr-row { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: end; }
.irr-row .field { margin-bottom: 8px; }
.irr-row .icon-btn { margin-bottom: 10px; }

/* ------------------------------------------------------------------ motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}
@media (forced-colors: active) {
  .bar-fill, .cycle-fill, .tab-add .icon { forced-color-adjust: none; }
  .hero { border: 2px solid CanvasText; }
  .chip-radio:has(input:checked) { outline: 2px solid CanvasText; }
}
