@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/archivo-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/archivo-latin-wght-normal.woff2) format("woff2");
  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;
}
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/archivo-latin-ext-wght-normal.woff2) format("woff2-variations"), url(fonts/archivo-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, 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;
}

:root {
  --ground: #c9cccb;   /* pewter */
  --panel: #d6d8d7;
  --hi: #e3e5e4;
  --ink: #1b1e20;
  --ink-2: #3c4245;
  --ink-3: #5a6165;
  --rule: rgba(27, 30, 32, .22);
  --rule-2: rgba(27, 30, 32, .12);
  --red: #a3241c;
  --amber: #8a5a00;
  --amber-bar: #b9800e;
  --ok: #3e5c4f;
  --bar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gut: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); }
body {
  margin: 0; min-height: 100vh; background: var(--ground); color: var(--ink);
  font: 400 16px/1.45 "Archivo", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--bar-h) + var(--safe-b) + 24px);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums lining-nums; }
[hidden] { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--gut) 10px; background: var(--ground); border-bottom: 1px solid var(--rule);
}
.top h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
main { max-width: 640px; margin: 0 auto; padding: 0 var(--gut); }
.screen { padding-top: 8px; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 32px 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }

/* type */
.label { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.big { margin: 2px 0 0; font-size: clamp(44px, 14vw, 64px); font-weight: 500; letter-spacing: -.03em; line-height: 1.05; }
.big.red { color: var(--red); }
.big.small { font-size: 28px; letter-spacing: -.01em; color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 14px; margin: 8px 0; }
.hint.foot { margin-top: 32px; }
.sub { font-weight: 400; color: var(--ink-3); font-size: 13px; }
.hero { padding: 20px 0 16px; border-bottom: 1px solid var(--rule); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 0; }
.pair div { min-width: 0; border-top: 1px solid var(--rule); padding-top: 8px; }
.pair dt { font-size: 13px; color: var(--ink-3); }
.pair dd { margin: 2px 0 0; font-size: 20px; font-weight: 500; }
.empty { padding: 24px 0; color: var(--ink-2); }
.empty p { margin: 0 0 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--hi); font-weight: 600; font-size: 15px; border-radius: 0; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); }
.btn.wide { width: 100%; margin-top: 16px; }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible, .bar button:focus-visible, .seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.link { background: none; border: 0; padding: 12px 4px; min-height: 44px; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; cursor: pointer; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row-btns .btn { flex: 1 1 140px; }
.file { position: relative; overflow: hidden; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* entry list */
.day { margin-top: 16px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--ink); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.row {
  display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 0 12px; align-items: center; width: 100%;
  padding: 10px 0; min-height: 56px; border: 0; border-bottom: 1px solid var(--rule-2); background: none; text-align: left; cursor: pointer;
}
.row .sw { align-self: stretch; background: var(--c, var(--ink-3)); }
.row .what { min-width: 0; }
.row .t1 { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { display: block; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 600; text-align: right; white-space: nowrap; }
.row.minus .amt { color: var(--ok); }
.row.neutral .amt { color: var(--ink-3); font-weight: 500; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; border: 1px solid var(--rule); padding: 1px 5px; margin-left: 4px; color: var(--ink-2); vertical-align: 1px; }
.tag.regret { border-color: var(--red); color: var(--red); }

/* sums table */
.sums { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sums th, .sums td { padding: 12px 0; border-bottom: 1px solid var(--rule-2); text-align: left; font-weight: 400; }
.sums td { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 12px; }
.sums tr.total th, .sums tr.total td { border-top: 1px solid var(--ink); font-weight: 600; }

/* ruler progress */
.meter { padding: 12px 0 14px; border-bottom: 1px solid var(--rule-2); }
.meter-h { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.meter-h b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-h span { white-space: nowrap; color: var(--ink-2); }
.ruler { position: relative; height: 14px; margin-top: 8px; border-bottom: 1px solid var(--ink); }
.ruler::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--ink) 1px, transparent 1px) 0 100% / 10% 6px repeat-x, linear-gradient(90deg, var(--ink) 1px, transparent 1px) 0 100% / 50% 12px repeat-x;
  opacity: .5;
}
.ruler i { position: absolute; left: 0; bottom: 0; height: 8px; background: var(--ink-2); width: var(--w, 0%); max-width: 100%; }
.meter.warn .ruler i { background: var(--amber-bar); }
.meter.over .ruler i { background: var(--red); }
.meter.warn .meter-h span { color: var(--amber); font-weight: 600; }
.meter.over .meter-h span { color: var(--red); font-weight: 600; }
.meter .note { font-size: 13px; color: var(--ink-3); margin: 6px 0 0; }
.meter.lead .meter-h b { font-size: 18px; }
.cat-dot { display: inline-block; width: 10px; height: 10px; background: var(--c, var(--ink-3)); margin-right: 8px; vertical-align: 0; }

/* review */
.card { border: 1px solid var(--ink); background: var(--panel); padding: 14px; margin-top: 16px; }
.card h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.card .big { font-size: 40px; }
.card p { margin: 6px 0; }
.card ul { list-style: none; margin: 8px 0 0; padding: 0; }
.card li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--rule-2); }
.card li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up { color: var(--red); }
.down { color: var(--ok); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--ink); margin-top: 20px; }
.seg button { min-height: 44px; border: 0; border-left: 1px solid var(--ink); background: transparent; font-weight: 600; cursor: pointer; }
.seg button:first-child { border-left: 0; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--ink); color: var(--hi); }
.stepper { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin: 8px 0; }
.stepper p { margin: 0; text-align: center; font-weight: 600; }
.stepper .btn { min-width: 64px; padding: 0 10px; }
.chart { display: block; width: 100%; height: 140px; margin: 8px 0 4px; }
.chart .b { fill: var(--ink-2); }
.chart .b.today { fill: var(--ink); }
.chart .axis { stroke: var(--ink); stroke-width: 1; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart text { font: 500 10px "Archivo", sans-serif; fill: var(--ink-3); }
.split { display: flex; height: 10px; margin: 8px 0 4px; border: 1px solid var(--ink); }
.split i { display: block; height: 100%; }
.split .need { background: var(--ink-2); }
.split .want { background: var(--amber-bar); }
.split .unset { background: var(--hi); }

/* settings */
.grid-form { display: grid; gap: 0; }
.grid-form label { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule-2); }
.grid-form label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input:not([type=checkbox]):not([type=file]) {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 0; background: var(--hi); font-size: 16px;
}
input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.grid-form input { text-align: right; }
.inline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.cat { padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
.cat-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cat-top input { border-left: 6px solid var(--c, var(--ink-3)); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.swatches button { width: 32px; height: 32px; border: 1px solid var(--rule); background: var(--c); cursor: pointer; padding: 0; }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.msg { border: 1px solid var(--ink); background: var(--hi); padding: 10px 12px; font-size: 14px; white-space: pre-line; }
.msg.bad { border-color: var(--red); }

/* bottom bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr 1.4fr 1fr 1fr;
  align-items: stretch; height: calc(var(--bar-h) + var(--safe-b)); padding: 0 4px var(--safe-b);
  background: var(--panel); border-top: 1px solid var(--ink);
}
.bar button { border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--ink-3); cursor: pointer; min-width: 0; }
.bar button[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.bar .add { margin: 8px 4px; background: var(--ink); color: var(--hi); font-size: 17px; letter-spacing: .02em; }
.bar .add::before { content: "+"; font-weight: 400; font-size: 22px; margin-right: 6px; line-height: 0; }

/* sheet */
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100vh - 24px); margin: auto auto 0; padding: 0; border: 0; border-top: 1px solid var(--ink);
  background: var(--ground); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(20, 22, 24, .45); }
.sheet form { padding: 8px var(--gut) calc(16px + var(--safe-b)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; padding: 0; border: 0; color: var(--ink); font-size: 15px; }
.sheet .seg { margin-top: 4px; }
.amount { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--ink); margin: 12px 0 14px; }
.amount .cur { font-size: 36px; font-weight: 500; color: var(--ink-3); }
.amount input, .amount input:not([type=checkbox]):not([type=file]) {
  border: 0; background: transparent; padding: 0; min-height: 64px; font-size: 52px; font-weight: 500; letter-spacing: -.02em; outline: 0; min-width: 0;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--rule); background: var(--hi);
  font-size: 15px; font-weight: 500; cursor: pointer; max-width: 100%;
}
.chip .d { width: 10px; height: 10px; background: var(--c, var(--ink-3)); flex: none; }
.chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--hi); }
.methods .chip { flex: 1 1 0; justify-content: center; }
.more { margin-top: 8px; border-top: 1px solid var(--rule); }
.more summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-3); margin: 8px 0; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--red); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.err { color: var(--red); font-weight: 600; margin: 8px 0; }
.sheet-act { display: flex; gap: 8px; margin-top: 12px; }
.sheet-act .save { flex: 1; min-height: 56px; font-size: 18px; }

/* snackbar */
.snack {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--bar-h) + var(--safe-b) + 12px); z-index: 30; max-width: 616px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px 4px 14px; background: var(--ink); color: var(--hi);
}
.snack .link { color: var(--hi); }

@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } }
}
@media (min-width: 700px) {
  .sheet { margin: auto; border: 1px solid var(--ink); }
}
.cat-top + .colour summary { min-height: 36px; display: inline-flex; align-items: center; font-size: 13px; color: var(--ink-3); cursor: pointer; }
