@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #e8edf0;
  --row: #f4f7f8;
  --ink: #12263a;
  --on-ink: #e8edf0;
  --muted: #566a79;
  --rule: #c3cfd7;
  --track: #cfd9df;
  --alarm: #c9391b;
  --alarm-on-ink: #ff9a7c;
  --ok: #1b7a54;
  --band-track: rgba(232, 237, 240, 0.22);
  --focus: #12263a;
}
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1923;
    --row: #13222e;
    --ink: #e4ecf1;
    --on-ink: #12263a;
    --muted: #8da1af;
    --rule: #263a49;
    --track: #223645;
    --alarm: #ff8f6f;
    --alarm-on-ink: #c9391b;
    --ok: #53c28f;
    --band-track: rgba(18, 38, 58, 0.22);
    --focus: #e4ecf1;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.4 "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.app { max-width: 560px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* header */
.top { padding: 14px 16px 12px; display: grid; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { min-height: 44px; border: 0; background: transparent; font-weight: 600; letter-spacing: -0.005em; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.months { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 12px; display: grid; place-items: center; }
.month-label { position: relative; display: block; text-align: center; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; padding: 6px 0; min-height: 44px; }
.month-label input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.month-label:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* summary band */
.band { background: var(--ink); color: var(--on-ink); padding: 20px 16px 18px; }
.band .kicker { font-size: 15px; font-weight: 500; opacity: 0.8; margin: 0; }
.band .big { margin: 2px 0 14px; font-size: clamp(40px, 13vw, 58px); line-height: 1; font-weight: 800; letter-spacing: -0.035em; }
.band .big.over { color: var(--alarm-on-ink); }
.pace { position: relative; height: 26px; }
.pace .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-radius: 4px; background: var(--band-track); overflow: hidden; }
.pace .fill { display: block; height: 100%; width: var(--w); background: var(--on-ink); border-radius: 4px; transform-origin: left; }
.pace .fill.over { background: var(--alarm-on-ink); }
.notch { position: absolute; bottom: -3px; width: 2px; height: 14px; margin-left: -1px; background: var(--on-ink); border-radius: 1px; box-shadow: 0 0 0 2px var(--ink); left: var(--x); }
.notch-label { position: absolute; top: 0; left: var(--x); transform: translateX(var(--shift, -50%)); font-size: 12px; font-weight: 500; opacity: 0.85; white-space: nowrap; }
.figures { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 15px; }
.figures span { opacity: 0.85; }
.figures b { font-weight: 700; opacity: 1; }

/* reimbursement */
.owes { margin: 0; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--rule); min-height: 56px; }
.owes p { margin: 0; font-weight: 500; }
.owes strong { font-weight: 700; }
.owes .ok { color: var(--ok); font-weight: 600; }
.owes .acts { display: flex; gap: 8px; flex: none; }
.btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--ink); background: transparent; font-weight: 600; }
.btn.solid { background: var(--ink); color: var(--on-ink); }
.owes-list { display: grid; }
.owes-list .owes { border-bottom: 1px solid var(--rule); }

/* groups */
.group { border-bottom: 1px solid var(--rule); }
.group > summary { list-style: none; display: grid; grid-template-columns: 1fr auto 18px; align-items: baseline; gap: 10px; padding: 14px 16px; cursor: pointer; min-height: 56px; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.group .sum { font-size: 15px; text-align: right; }
.group .sum b { font-weight: 700; }
.group .sum span { color: var(--muted); }
.chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); align-self: center; justify-self: center; margin-top: -4px; transition: transform 0.15s; }
.group[open] > summary .chev { transform: rotate(-135deg); margin-top: 3px; }

.cat { background: var(--row); border-top: 1px solid var(--rule); }
.cat-btn { width: 100%; text-align: left; border: 0; background: transparent; padding: 12px 16px 14px; display: grid; gap: 8px; min-height: 56px; }
.cat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cat-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cat-name small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 1px; }
.cat-name small.over-text { color: var(--alarm); font-weight: 600; }
.cat-fig { text-align: right; white-space: nowrap; font-size: 15px; }
.cat-fig b { font-weight: 700; }
.cat-fig.over b { color: var(--alarm); }
.cat-fig span { color: var(--muted); }
.meter { height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--w); background: var(--ink); border-radius: 2px; transform-origin: left; }
.meter i.over { background: var(--alarm); }
.cat-btn[aria-expanded="false"] .meter { margin-bottom: 0; }

.tx-list { margin: 0; padding: 0 16px 8px; list-style: none; background: var(--row); }
.tx { display: grid; grid-template-columns: 48px 1fr auto; gap: 4px 10px; padding: 10px 0; border-top: 1px dashed var(--rule); font-size: 15px; }
.tx .d { color: var(--muted); }
.tx .n { min-width: 0; overflow-wrap: anywhere; }
.tx .n small, .tx .a small { display: block; color: var(--muted); font-size: 13px; }
.tx .a { text-align: right; white-space: nowrap; font-weight: 600; }
.tx .a small { font-weight: 400; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; border: 1px solid var(--muted); color: var(--muted); border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.tx-empty, .tx-loading { padding: 10px 0 14px; color: var(--muted); font-size: 15px; }

.toggle-empty { width: 100%; text-align: left; border: 0; border-top: 1px solid var(--rule); background: transparent; color: var(--muted); padding: 0 16px; min-height: 44px; font-weight: 500; font-size: 15px; }

.state { padding: 28px 16px; color: var(--muted); }
.state button { margin-top: 10px; }
.foot { display: flex; justify-content: space-between; align-items: center; padding: 18px 16px 0; color: var(--muted); font-size: 14px; }
.foot form { margin: 0; }
.link-btn { border: 0; background: transparent; color: var(--muted); text-decoration: underline; padding: 12px 0 12px 12px; min-height: 44px; }

/* one reveal on load: bars grow */
@media (prefers-reduced-motion: no-preference) {
  .reveal .fill, .reveal .meter i { animation: grow 0.7s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
}

/* login */
.login-page { display: grid; min-height: 100vh; align-items: start; }
.login { width: 100%; max-width: 360px; margin: 0 auto; padding: 18vh 16px 32px; }
.login h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.035em; margin: 0 0 24px; }
.login label { display: block; font-weight: 600; margin: 14px 0 6px; }
.login input { width: 100%; min-height: 48px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--row); }
.login .primary { width: 100%; min-height: 48px; margin-top: 22px; border: 0; border-radius: 10px; background: var(--ink); color: var(--on-ink); font-weight: 700; }
.form-error { color: var(--alarm); font-weight: 600; margin: 14px 0 0; }

@media (min-width: 600px) {
  .band { border-radius: 18px; margin: 0 16px; padding-left: 20px; padding-right: 20px; }
  .owes, .group > summary { padding-left: 20px; padding-right: 20px; }
}
