/* Thriftlark: household expense tracker (concept demo)
   Design system in one file.
   Type scale   12 / 13 / 15 / 17 / 22 / 30 / 44   (line heights 16 / 18 / 22 / 24 / 28 / 36 / 48)
   Space scale  4 / 8 / 12 / 16 / 20 / 24 / 32 / 40 / 56
   Radius       6 small parts · 10 controls · 14 tiles · 22 sheets · 999 pills
   Shadow       one soft lift for floating things only (menus, toasts, sheets, the drag pill) */

:root {
  --font: "DM Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "DM Serif Display", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px;
  --r1: 6px; --r2: 10px; --r3: 14px; --r4: 22px;
  --col: 480px;
  --pad: 20px;

  /* surfaces */
  --bg: #F2F0E3;
  --paper: #FBFAF4;
  --raised: #FFFEFA;
  --sunk: #F1EFE2;
  --line: #E4E1D0;
  --line-2: #CFCBB4;

  /* ink */
  --ink: #23281A;
  --ink-2: #555A47;
  --ink-3: #6B6F5E;

  /* brand */
  --olive: #56692B;
  --olive-deep: #435320;
  --olive-soft: #E9EDD8;
  --olive-ink: #3D4B1E;
  --on-olive: #FFFFFF;
  --butter: #F2D45C;
  --butter-deep: #E0BC36;
  --butter-soft: #FAF0C2;
  --on-butter: #2B2A12;
  --focus: #2F3B14;

  /* status */
  --ok: #2F7A4D;      --ok-soft: #E0F0E3;
  --warn: #9A5B0B;    --warn-soft: #F8EAD0;
  --over: #B3402B;    --over-soft: #F8E1DB;
  --info: #36688A;    --info-soft: #DEEAF2;

  --scrim: rgba(28, 32, 18, .42);
  --lift: 0 10px 30px rgba(35, 40, 26, .14), 0 2px 6px rgba(35, 40, 26, .06);
  --lift-up: 0 -14px 40px rgba(35, 40, 26, .16);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #111309;
  --paper: #181B11;
  --raised: #21251A;
  --sunk: #13160D;
  --line: #2D3223;
  --line-2: #434935;
  --ink: #ECEBDD;
  --ink-2: #BDBFAA;
  --ink-3: #969985;
  --olive: #A9BF6C;
  --olive-deep: #BBD07F;
  --olive-soft: #2A321A;
  --olive-ink: #C6D896;
  --on-olive: #171C0C;
  --butter: #F2D45C;
  --butter-deep: #F2D45C;
  --butter-soft: #3A3414;
  --on-butter: #2B2A12;
  --focus: #F2D45C;
  --ok: #7CC08F;      --ok-soft: #1B2E20;
  --warn: #E2AC60;    --warn-soft: #33270F;
  --over: #F0907C;    --over-soft: #3A1D17;
  --info: #8BBADB;    --info-soft: #172733;
  --scrim: rgba(0, 0, 0, .58);
  --lift: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  --lift-up: 0 -14px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* category tints: one muted hue each, a deep tone for the icon and a wash for its tile */
.cat-groceries { --c: #4E7A2E; --cs: #E6F0D9; }
.cat-eating    { --c: #B0532A; --cs: #F8E5D8; }
.cat-transport { --c: #33658A; --cs: #DDEAF3; }
.cat-home      { --c: #7A5A32; --cs: #F0E6D4; }
.cat-utilities { --c: #8F6B0E; --cs: #F7EBC5; }
.cat-help      { --c: #55695E; --cs: #E4ECE7; }
.cat-health    { --c: #2A7573; --cs: #D9EFEC; }
.cat-shopping  { --c: #7A4C8C; --cs: #EDE1F2; }
.cat-fun       { --c: #A6497F; --cs: #F5DFEB; }
.cat-subs      { --c: #4B58A0; --cs: #E1E4F5; }
.cat-gifts     { --c: #B23A55; --cs: #F8DEE3; }
.cat-misc      { --c: #6B6F5E; --cs: #ECEBDF; }
[data-theme="dark"] .cat-groceries { --c: #A9CF85; --cs: #26331B; }
[data-theme="dark"] .cat-eating    { --c: #EBA27C; --cs: #3A241A; }
[data-theme="dark"] .cat-transport { --c: #8FBDE0; --cs: #1B2B38; }
[data-theme="dark"] .cat-home      { --c: #D3B487; --cs: #33291A; }
[data-theme="dark"] .cat-utilities { --c: #E3C469; --cs: #352D12; }
[data-theme="dark"] .cat-help      { --c: #A9C2B4; --cs: #222C26; }
[data-theme="dark"] .cat-health    { --c: #86CFCB; --cs: #17302F; }
[data-theme="dark"] .cat-shopping  { --c: #CBA3DB; --cs: #2E2135; }
[data-theme="dark"] .cat-fun       { --c: #E59CC6; --cs: #391E2D; }
[data-theme="dark"] .cat-subs      { --c: #A5AEEA; --cs: #20243D; }
[data-theme="dark"] .cat-gifts     { --c: #EE99AB; --cs: #3A1C24; }
[data-theme="dark"] .cat-misc      { --c: #B9BBA6; --cs: #2A2D22; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-y: scroll; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/22px var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r1); }
::selection { background: var(--butter); color: var(--on-butter); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 90; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--r2); font-weight: 600; }
.skip:focus { top: 12px; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r1); background: var(--raised); font: 600 11px/1 var(--font); color: var(--ink-2); }
.muted { color: var(--ink-3); }
.fine { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.eyebrow { font: 600 12px/16px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* serif amounts: digits in the display face, the rupee sign set smaller in the text face */
.amt-xl, .amt-lg, .amt-md { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; font-variant-numeric: normal; white-space: nowrap; }
.amt-xl { font-size: 44px; line-height: 48px; }
.amt-lg { font-size: 30px; line-height: 36px; }
.amt-md { font-size: 22px; line-height: 28px; }
.cur { font-family: var(--font); font-weight: 500; font-size: .56em; margin-right: .08em; vertical-align: .36em; color: var(--ink-2); }
.mark { background: linear-gradient(transparent 56%, var(--butter) 56%, var(--butter) 90%, transparent 90%); padding: 0 3px; margin: 0 -3px; }
[data-theme="dark"] .mark { background: linear-gradient(transparent 62%, #6B5C17 62%, #6B5C17 92%, transparent 92%); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r2); border: 1px solid transparent; font-weight: 600; font-size: 15px; line-height: 20px; white-space: nowrap; transition: background-color .14s, border-color .14s, color .14s, transform .08s; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--olive); color: var(--on-olive); }
.btn-primary:hover:not(:disabled) { background: var(--olive-deep); }
.btn-butter { background: var(--butter); color: var(--on-butter); }
.btn-butter:hover:not(:disabled) { background: var(--butter-deep); }
.btn-secondary { background: var(--raised); border-color: var(--line-2); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-3); }
.btn-quiet { color: var(--olive-ink); padding: 0 10px; }
.btn-quiet:hover:not(:disabled) { background: var(--olive-soft); }
.btn-danger { background: var(--raised); border-color: var(--line-2); color: var(--over); }
.btn-danger:hover:not(:disabled) { background: var(--over-soft); border-color: var(--over); }
.btn-danger.solid { background: var(--over); color: #fff; border-color: transparent; }
[data-theme="dark"] .btn-danger.solid { color: #2A0F0A; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; min-height: 48px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--on-olive); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-secondary.loading::after { border-color: var(--ink-2); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r2); color: var(--ink-2); transition: background-color .14s, color .14s; }
.icon-btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.link { color: var(--olive-ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }

/* tooltips on icon buttons (desktop pointers only) */
@media (hover: hover) {
  [data-tip] { position: relative; }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); z-index: 30; padding: 4px 8px; border-radius: var(--r1); background: var(--ink); color: var(--paper); font: 500 12px/16px var(--font); white-space: nowrap; pointer-events: none; }
  [data-tip].tip-up:hover::after, [data-tip].tip-up:focus-visible::after { top: auto; bottom: calc(100% + 6px); }
  [data-tip].tip-left:hover::after, [data-tip].tip-left:focus-visible::after { left: auto; right: 0; transform: none; }
}

/* ---------- form controls ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-weight: 600; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.input, .select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r2); background: var(--raised); color: var(--ink); transition: border-color .14s, box-shadow .14s; }
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover { border-color: var(--ink-3); }
.input:focus, .select:focus { border-color: var(--olive); box-shadow: 0 0 0 3px var(--olive-soft); outline: none; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236B6F5E' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 8l4.5 4.5L14.5 8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23969985' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 8l4.5 4.5L14.5 8'/%3E%3C/svg%3E"); }
.select option { background: var(--raised); color: var(--ink); }
.help { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.err { font-size: 12px; line-height: 16px; color: var(--over); font-weight: 500; }
.field.bad .input, .field.bad .select { border-color: var(--over); }
.money { position: relative; }
.money .input { padding-left: 28px; }
.money::before { content: "\20B9"; position: absolute; left: 12px; top: 11px; color: var(--ink-3); font-weight: 500; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); align-items: start; }
.stack { display: grid; gap: var(--s4); }

.seg { display: inline-flex; padding: 3px; border-radius: var(--r2); background: var(--sunk); border: 1px solid var(--line); gap: 2px; max-width: 100%; }
.seg button { min-height: 32px; padding: 0 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background-color .14s, color .14s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.seg .ic { width: 16px; height: 16px; }
.seg.fill { display: flex; }
.seg.fill button { flex: 1; justify-content: center; padding: 0 6px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--raised); font-weight: 500; font-size: 13px; white-space: nowrap; transition: background-color .14s, border-color .14s; }
.chip .ic { width: 18px; height: 18px; color: var(--c, var(--ink-2)); }
.chip:hover { border-color: var(--ink-3); }
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--cs, var(--olive-soft)); border-color: var(--c, var(--olive)); box-shadow: inset 0 0 0 1px var(--c, var(--olive)); font-weight: 600; }
.chip.plain { padding: 0 12px; }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-weight: 600; font-size: 12px; line-height: 16px; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.over { background: var(--over-soft); color: var(--over); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag .ic { width: 12px; height: 12px; stroke-width: 2; }

.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--line-2); transition: background-color .16s; flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .16s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch[aria-checked="true"] { background: var(--olive); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
[data-theme="dark"] .switch::after { background: #181B11; }
[data-theme="dark"] .switch:not([aria-checked="true"])::after { background: #ECEBDD; }

.glyph { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r2); background: var(--cs, var(--sunk)); color: var(--c, var(--ink-2)); flex: none; }
.glyph.sm { width: 28px; height: 28px; border-radius: 8px; }
.glyph.sm .ic { width: 16px; height: 16px; }
.av { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--olive-soft); color: var(--olive-ink); font-weight: 700; font-size: 13px; flex: none; }
.av.m1 { background: var(--info-soft); color: var(--info); }
.av.m2 { background: var(--over-soft); color: var(--over); }
.av.m3 { background: var(--warn-soft); color: var(--warn); }
.av.sm { width: 24px; height: 24px; font-size: 10px; }

.bar { position: relative; height: 8px; border-radius: 999px; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--olive); transition: width .2s ease-out; }
.bar.low > i { background: var(--warn); }
.bar.over > i { background: var(--over); }
.bar > b { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--ink); opacity: .55; }
.bar.thin { height: 4px; }

/* ---------- skeleton, empty ---------- */
.skel { display: grid; gap: 14px; padding: 20px var(--pad); }
.skel i { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--sunk) 0%, var(--line) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
.skel .row { display: grid; grid-template-columns: 36px 1fr 64px; gap: 12px; align-items: center; }
.skel .row i:first-child { height: 36px; border-radius: var(--r2); }
.skel .w40 { width: 40%; } .skel .w60 { width: 60%; } .skel .tall { height: 44px; width: 52%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 28px 48px; }
.empty svg.art { width: 120px; height: 84px; margin-bottom: 8px; }
.empty h3 { font: 400 22px/28px var(--serif); }
.empty p { color: var(--ink-2); max-width: 320px; }
.empty .btn { margin-top: 8px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 6px 6px 6px 16px; border-radius: var(--r3); background: #262B1C; color: #F4F3E6; box-shadow: var(--lift); font-size: 14px; line-height: 20px; position: relative; overflow: hidden; animation: toast-in .18s ease-out; }
[data-theme="dark"] .toast { background: #ECEBDD; color: #1B1F12; }
.toast.err { background: #5B1F14; color: #FBE9E4; }
[data-theme="dark"] .toast.err { background: #F6D5CD; color: #4A160D; }
.toast-msg { flex: 1; min-width: 0; padding: 6px 0; }
.toast-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 8px; font-weight: 700; color: var(--butter); white-space: nowrap; }
[data-theme="dark"] .toast-btn { color: #4C5E22; }
.toast.err .toast-btn { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.toast-btn:hover { background: rgba(255, 255, 255, .1); }
.toast-btn .ic { width: 16px; height: 16px; stroke-width: 2; }
.toast-x { display: grid; place-items: center; width: 32px; height: 36px; border-radius: 8px; color: inherit; opacity: .6; }
.toast-x:hover { opacity: 1; }
.toast-x .ic { width: 16px; height: 16px; }
.toast-life { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--butter); transform-origin: left; animation: life linear forwards; }
[data-theme="dark"] .toast-life { background: #56692B; }
@keyframes life { to { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
/* a toast must never sit on a sheet's buttons: while a sheet is open it moves to the top of the column */
html.sheet-open #toasts { bottom: auto; top: 12px; }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; }
.sheet-wrap .dim { position: absolute; inset: 0; background: rgba(28, 32, 18, .14); opacity: 0; transition: opacity .18s; }
.sheet-wrap .scrim { position: absolute; top: 0; bottom: 0; left: 50%; width: min(100vw, var(--col)); transform: translateX(-50%); background: var(--scrim); opacity: 0; transition: opacity .18s; }
.sheet { position: absolute; left: 50%; bottom: 0; width: min(100vw, var(--col)); max-height: 94vh; max-height: 94dvh; transform: translate(-50%, 24px); opacity: 0; display: flex; flex-direction: column; background: var(--paper); border-radius: var(--r4) var(--r4) 0 0; box-shadow: var(--lift-up); transition: transform .2s ease-out, opacity .2s ease-out; }
.sheet-wrap.in .dim, .sheet-wrap.in .scrim { opacity: 1; }
.sheet-wrap.in .sheet { transform: translate(-50%, 0); opacity: 1; }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 12px 8px var(--pad); flex: none; }
.sheet-h h2 { font: 400 22px/28px var(--serif); padding-top: 6px; }
.sheet-h p { color: var(--ink-2); font-size: 13px; line-height: 18px; margin-top: 2px; }
.sheet-b { padding: 8px var(--pad) 16px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.sheet-f { display: flex; gap: var(--s3); padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); flex: none; }
.sheet-f .btn { flex: 1; min-height: 48px; }
.sheet-f .btn.narrow { flex: 0 0 auto; }
.sheet-note { text-align: center; margin-top: 12px; }

/* palette sits near the top of the column instead of the bottom */
.sheet-wrap.pal .sheet { bottom: auto; top: 72px; border-radius: var(--r4); max-height: min(560px, calc(100vh - 120px)); width: min(calc(100vw - 24px), var(--col)); }
.sheet-wrap.pal .grab { display: none; }

/* ---------- menus ---------- */
.menu { position: fixed; z-index: 70; min-width: 200px; padding: 6px; border-radius: var(--r3); background: var(--raised); border: 1px solid var(--line-2); box-shadow: var(--lift); animation: toast-in .12s ease-out; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border-radius: 8px; font-weight: 500; }
.menu button:hover, .menu button:focus-visible { background: var(--sunk); }
.menu button.danger { color: var(--over); }
.menu .ic { width: 18px; height: 18px; color: var(--ink-3); }
.menu button.danger .ic { color: inherit; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ---------- shell: nav · column · rail ---------- */
.shell { display: grid; grid-template-columns: 1fr var(--col) 1fr; min-height: 100vh; }
.nav { justify-self: end; width: 208px; margin-right: var(--s8); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 0 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 400 24px/28px var(--serif); letter-spacing: -.01em; padding: 0 8px; margin-bottom: var(--s6); align-self: flex-start; }
.brand svg { width: 32px; height: 32px; }
.nav-add { width: 100%; justify-content: flex-start; min-height: 44px; padding: 0 12px; margin-bottom: var(--s5); }
.nav-add kbd { margin-left: auto; background: rgba(255, 255, 255, .5); border-color: rgba(43, 42, 18, .28); color: var(--on-butter); }
.nav-list { display: grid; gap: 2px; }
.nav-list a { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 10px; border-radius: var(--r2); color: var(--ink-2); font-weight: 500; transition: background-color .14s, color .14s; }
.nav-list a:hover { background: rgba(86, 105, 43, .08); color: var(--ink); }
.nav-list a.on { color: var(--ink); font-weight: 700; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
.nav-list a.on .ic { color: var(--olive); }
.nav-list small { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.nav-list small.dot { color: var(--over); }
.nav-foot { margin-top: auto; display: grid; gap: var(--s3); }
.who { display: flex; align-items: center; gap: 10px; padding: 0 8px; min-width: 0; }
.who b { display: block; font-size: 14px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-3); }
.nav-tools { display: flex; gap: 2px; padding: 8px 0 0; border-top: 1px solid var(--line-2); }
.nav-tools .icon-btn { width: 36px; height: 36px; }

.col { background: var(--paper); border-inline: 1px solid var(--line); min-height: 100vh; min-width: 0; padding-bottom: 72px; position: relative; }
.col:focus { outline: none; }
.screen { animation: fade .16s ease-out; }
@keyframes fade { from { opacity: 0; } }

.rail { justify-self: start; width: 336px; margin-left: var(--s8); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 32px 0 20px; display: flex; flex-direction: column; scrollbar-width: none; }
.rail-sec { padding: 0 0 var(--s5); margin-bottom: var(--s5); border-bottom: 1px solid var(--line-2); }
.rail-sec > .eyebrow { margin-bottom: var(--s2); }
.rail-sec > p { color: var(--ink-2); font-size: 14px; line-height: 20px; margin-top: 6px; }
.rail-sec > p b { color: var(--ink); font-weight: 600; }
.rail-list { display: grid; }
.rail-list a { display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; }
.rail-list a:hover { background: rgba(86, 105, 43, .08); }
.rail-list span { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-list b { font-weight: 600; }
.rail-list small { grid-column: 1 / -1; font-size: 12px; line-height: 16px; color: var(--ink-3); }
.rail-list small.late { color: var(--over); font-weight: 600; }
.rail-list .bar { grid-column: 1 / -1; margin-top: 6px; }
.rail-more { display: inline-block; margin-top: 8px; font-size: 13px; }
.rail-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-3); align-items: center; }
.rail-foot span { display: inline-flex; align-items: center; gap: 6px; }

.tabbar { display: none; }

/* ---------- screen headers ---------- */
.shead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 24px var(--pad) 16px; }
.shead h1 { font: 400 30px/36px var(--serif); letter-spacing: -.01em; }
.shead p { color: var(--ink-2); margin-top: 2px; }
.shead-acts { display: flex; gap: 4px; align-items: center; padding-top: 0; flex: none; }
.sub-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 20px var(--pad) 8px; }
.sub-h h2 { font: 600 12px/16px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.sub-h small { font-size: 13px; color: var(--ink-3); }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 16px 0 0 12px; padding: 6px 10px 6px 4px; border-radius: 8px; }
.back:hover { background: var(--sunk); }
.back .ic { width: 18px; height: 18px; }
.hint { display: flex; gap: 10px; align-items: flex-start; margin: 0 var(--pad) 16px; padding: 10px 12px; border-radius: var(--r2); background: var(--butter-soft); color: var(--on-butter); font-size: 13px; line-height: 18px; }
[data-theme="dark"] .hint { color: #EFE3A6; }
.hint .ic { width: 18px; height: 18px; margin-top: 0; }
.hint button { margin-left: auto; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; flex: none; }

/* ---------- month ---------- */
.mhead { padding: 20px var(--pad) 16px; }
.mswitch { display: flex; align-items: center; gap: 2px; margin: 0 0 12px -10px; }
.mtitle { font: 400 22px/28px var(--serif); padding: 0 6px; min-width: 0; white-space: nowrap; }
.mtitle span { color: var(--ink-3); }
.mswitch .grow { flex: 1; }
.mtotal { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mtotal p { color: var(--ink-2); }
.pace { margin-top: 14px; }
.pace .bar { height: 10px; }
.pace-legend { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.pace-legend b { color: var(--ink); font-weight: 700; }
.pace-legend .neg { color: var(--over); }

.strip { display: grid; grid-template-columns: 28px 1fr 28px; align-items: stretch; border-block: 1px solid var(--line); background: var(--raised); }
.strip-arrow { display: grid; place-items: center; color: var(--ink-3); }
.strip-arrow:hover { color: var(--ink); background: var(--sunk); }
.strip-arrow .ic { width: 16px; height: 16px; }
.strip-days { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 10px 2px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent); mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent); }
.strip-days::-webkit-scrollbar { display: none; }
.day { flex: 0 0 40px; display: grid; justify-items: center; gap: 4px; padding: 6px 0; border-radius: var(--r2); color: var(--ink-2); transition: background-color .14s; }
.day:hover { background: var(--sunk); }
.day i { display: flex; align-items: flex-end; width: 8px; height: 32px; border-radius: 4px; background: var(--line); overflow: hidden; }
.day i u { display: block; width: 100%; border-radius: 4px; background: var(--olive); text-decoration: none; }
.day.clip i u { background: linear-gradient(to top, var(--olive) 0, var(--olive) calc(100% - 7px), var(--raised) calc(100% - 7px), var(--raised) calc(100% - 5px), var(--olive) calc(100% - 5px)); }
.day b { font-weight: 600; font-size: 14px; line-height: 22px; width: 26px; text-align: center; border-radius: 50%; color: var(--ink); }
.day small { font-size: 11px; line-height: 12px; color: var(--ink-3); }
.day.today b { background: var(--butter); color: var(--on-butter); }
.day.future { opacity: .45; }
.day[aria-pressed="true"] { background: var(--olive-soft); box-shadow: inset 0 0 0 1.5px var(--olive); }
.day[aria-pressed="true"] small { color: var(--olive-ink); }

.listbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--pad) 4px; flex-wrap: wrap; }
.daynote { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.dgroup { padding-top: 8px; }
.dhead { display: flex; align-items: baseline; gap: 8px; padding: 12px var(--pad) 6px; font-size: 13px; line-height: 18px; }
.dhead span { font-weight: 700; }
.dhead small { color: var(--ink-3); font-size: 13px; }
.dhead b { margin-left: auto; font-weight: 600; color: var(--ink-2); }

.tx { position: relative; overflow: hidden; }
.tx + .tx::before { content: ""; position: absolute; left: calc(var(--pad) + 48px); right: var(--pad); top: 0; border-top: 1px solid var(--line); z-index: 1; }
.tx-under { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-right: 24px; background: var(--over); color: #fff; font-weight: 700; visibility: hidden; }
.tx.swiping .tx-under { visibility: visible; }
.tx-row { position: relative; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 10px var(--pad); background: var(--paper); touch-action: pan-y; transition: background-color .14s; }
.tx-row:hover { background: var(--raised); }
.tx-row:focus-visible { outline-offset: -2px; }
.tx-main { min-width: 0; display: grid; }
.tx-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main small { display: flex; align-items: center; gap: 5px; font-size: 13px; line-height: 18px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.tx-main small span { overflow: hidden; text-overflow: ellipsis; }
.tx-main small .ic { width: 13px; height: 13px; stroke-width: 1.8; }
.tx-amt { text-align: right; display: grid; }
.tx-amt b { font-weight: 600; }
.tx-amt small { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.tx-amt.in b { color: var(--ok); }
.tx.new .tx-row { animation: row-new 1.2s ease-out; }
@keyframes row-new { 0%, 35% { background: var(--butter-soft); } }
.more-row { display: grid; justify-items: center; padding: 16px; }

/* ---------- envelopes ---------- */
.envs { display: grid; gap: var(--s3); padding: 0 var(--pad); }
.env { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 12px 12px; align-items: center; padding: 18px 14px 14px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); transition: border-color .14s, background-color .14s, box-shadow .14s; }
.env .flap { position: absolute; left: 0; right: 0; top: -1px; width: 100%; height: 12px; fill: none; stroke: var(--line); stroke-width: 1; pointer-events: none; }
.env-open { display: flex; align-items: center; gap: 12px; min-width: 0; border-radius: var(--r2); }
.env-name { display: grid; min-width: 0; }
.env-name b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-name small { font-size: 13px; line-height: 18px; color: var(--ink-3); white-space: nowrap; }
.env .bar { grid-column: 1 / -1; }
.pill-drag { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px 0 6px; border-radius: 999px; background: var(--butter-soft); color: var(--on-butter); font-weight: 700; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: background-color .14s, transform .14s; }
[data-theme="dark"] .pill-drag { color: #F4E7A5; }
.pill-drag:hover { background: var(--butter); color: var(--on-butter); }
.pill-drag .ic { width: 16px; height: 16px; opacity: .6; }
.pill-drag small { font-weight: 500; font-size: 12px; opacity: .8; margin-left: 2px; }
.env.over .pill-drag { background: var(--over-soft); color: var(--over); cursor: pointer; }
.env.over .pill-drag .ic { display: none; }
.env.over .pill-drag { padding-left: 12px; }
.env.src { opacity: .55; }
.env.drop { border-color: var(--olive); background: var(--olive-soft); box-shadow: 0 0 0 2px var(--olive); }
.env.drop .flap { stroke: var(--olive); }
.env.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { background: var(--butter-soft); border-color: var(--butter-deep); } }
body.dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
body.dragging .pill-drag { cursor: grabbing; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 75; pointer-events: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; background: var(--butter); color: var(--on-butter); font-weight: 700; box-shadow: var(--lift); white-space: nowrap; }
.drag-ghost small { font-weight: 500; font-size: 12px; }
.moves { padding: 0 var(--pad); }
.moves li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.moves li:first-child { border-top: 0; }
.moves .ic { width: 16px; height: 16px; color: var(--ink-3); }
.moves span { flex: 1; min-width: 0; }
.moves small { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.mv-pair { display: grid; gap: 4px; }
.mv-pair .arrow { display: grid; place-items: center; height: 16px; color: var(--ink-3); transform: rotate(90deg); margin-bottom: -14px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.preview { display: grid; gap: 6px; padding: 12px 14px; border-radius: var(--r2); background: var(--sunk); font-size: 14px; }
.preview div { display: flex; justify-content: space-between; gap: 12px; }
.preview b { font-weight: 600; }
.preview .neg { color: var(--over); }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; }
.stepper .icon-btn { width: 44px; height: 44px; border: 1px solid var(--line-2); background: var(--raised); }
.stepper .input { text-align: center; font-weight: 600; }
.mini-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.mini-months div { display: grid; gap: 4px; font-size: 12px; color: var(--ink-3); }
.mini-months i { display: block; border-radius: 4px 4px 0 0; background: var(--line-2); min-height: 3px; }
.mini-months .now i { background: var(--olive); }
.mini-months b { font-size: 14px; color: var(--ink); font-weight: 600; }

/* ---------- bills ---------- */
.bills { padding: 0 var(--pad); }
.bill { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.bill:first-child { border-top: 0; }
.cal { display: grid; justify-items: center; width: 44px; padding: 5px 0 4px; border-radius: var(--r2); border: 1px solid var(--line-2); background: var(--raised); line-height: 1; }
.cal small { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); line-height: 12px; }
.cal b { font: 400 20px/22px var(--serif); font-variant-numeric: normal; }
.bill.late .cal { border-color: var(--over); background: var(--over-soft); }
.bill.late .cal small, .bill.late .cal b { color: var(--over); }
.bill.paid .cal { background: transparent; border-style: dashed; }
.bill.paid .cal b, .bill.paid .bill-main b { color: var(--ink-3); }
.bill-main { min-width: 0; display: grid; }
.bill-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-main small { font-size: 13px; line-height: 18px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bill-main small.late { color: var(--over); font-weight: 600; }
.bill-side { display: flex; align-items: center; gap: 6px; }
.bill-amt { text-align: right; display: grid; margin-right: 4px; }
.bill-amt b { font-weight: 600; }
.bill-amt small { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.bill-side .icon-btn { width: 32px; height: 36px; }
.statline { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0 var(--pad) 8px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.statline > div { padding: 14px 16px; }
.statline > div + div { border-left: 1px solid var(--line); }
.statline small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-3); margin-top: 2px; }

/* ---------- split ---------- */
.verdict { padding: 0 var(--pad) 8px; }
.verdict p { font: 400 22px/30px var(--serif); }
.verdict p + p { margin-top: 2px; }
.verdict p.fine { font: 400 13px/18px var(--font); color: var(--ink-3); margin-top: 8px; }
.mates { padding: 8px var(--pad) 0; display: grid; gap: var(--s3); }
.mate { display: grid; grid-template-columns: 36px 1fr; gap: 4px 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.mate-main { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; min-width: 0; }
.mate-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mate-main span { font-weight: 600; white-space: nowrap; }
.mate-main .pos { color: var(--ok); }
.mate-main .neg { color: var(--warn); }
.mate-acts { grid-column: 2; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.share-grid { display: grid; gap: 8px; }
.share-row { display: grid; grid-template-columns: 24px 1fr 120px; gap: 10px; align-items: center; }
.share-row .input { height: 40px; text-align: right; }
.share-row span { font-weight: 500; }
.sumline { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); padding-top: 4px; }
.sumline.bad { color: var(--over); font-weight: 600; }

/* ---------- accounts ---------- */
.accts { padding: 0 var(--pad); }
.acct { display: grid; grid-template-columns: 36px 1fr auto 16px; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); width: 100%; }
.acct:first-child { border-top: 0; }
.acct:hover .acct-main b { text-decoration: underline; text-underline-offset: 3px; }
.acct-main { display: grid; min-width: 0; }
.acct-main b { font-weight: 600; }
.acct-main small { font-size: 13px; line-height: 18px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-bal { text-align: right; display: grid; }
.acct-bal b { font-weight: 600; }
.acct-bal small { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.acct-bal .neg { color: var(--over); }
.acct > .ic { width: 16px; height: 16px; color: var(--ink-3); }
.acct .bar { grid-column: 2 / 4; margin-top: -4px; }
.hero { padding: 0 var(--pad) 16px; }
.hero p { color: var(--ink-2); margin-top: 2px; }
.act-row { display: flex; gap: 8px; padding: 0 var(--pad) 8px; flex-wrap: wrap; }

/* ---------- summary ---------- */
.lede { padding: 0 var(--pad) 16px; font: 400 22px/30px var(--serif); }
.lede small { display: block; font: 400 14px/20px var(--font); color: var(--ink-2); margin-top: 8px; }
.chart { position: relative; margin: 0 var(--pad); padding: 12px 8px 8px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.chart svg { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font: 500 11px var(--font); }
.chart .l-plan { stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 1.5 4; stroke-linecap: round; fill: none; }
.chart .l-prev { stroke: var(--ink-3); stroke-width: 1.4; stroke-dasharray: 5 4; fill: none; }
.chart .l-now { stroke: var(--olive); stroke-width: 2.4; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .a-now { fill: var(--olive); opacity: .08; }
.chart .dot { fill: var(--butter); stroke: var(--olive); stroke-width: 2; }
.chart .guide { stroke: var(--ink-2); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart-tip { position: absolute; top: 8px; z-index: 2; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--paper); font-size: 12px; line-height: 16px; white-space: nowrap; pointer-events: none; transform: translateX(-50%); }
.chart-tip b { display: block; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 8px 4px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2.4px solid var(--olive); }
.legend i.prev { border-top: 1.4px dashed var(--ink-3); }
.legend i.plan { border-top: 1.4px dotted var(--ink-3); }
.facts { margin: 0 var(--pad); display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.facts > div { padding: 12px 14px; border-top: 1px solid var(--line); min-width: 0; }
.facts > div:nth-child(-n+2) { border-top: 0; }
.facts > div:nth-child(even) { border-left: 1px solid var(--line); }
.facts dt { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.facts dd { font-weight: 600; margin-top: 2px; }
.facts dd small { display: block; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranks { padding: 0 var(--pad); }
.rank { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; }
.rank:first-child { border-top: 0; }
.rank-name { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-name small { font-weight: 400; color: var(--ink-3); font-size: 13px; margin-left: 6px; }
.rank-amt { text-align: right; font-weight: 600; }
.rank .bar { grid-column: 2 / 4; }
.rank .bar > i { background: var(--c, var(--olive)); }
.rank-delta { grid-column: 2 / 4; font-size: 12px; line-height: 16px; color: var(--ink-3); }
.rank-delta .up { color: var(--warn); font-weight: 600; }
.rank-delta .down { color: var(--ok); font-weight: 600; }

/* ---------- search ---------- */
.searchbox { position: relative; margin: 0 var(--pad); }
.searchbox .ic { position: absolute; left: 12px; top: 12px; color: var(--ink-3); pointer-events: none; }
.searchbox .input { padding-left: 40px; padding-right: 40px; height: 44px; }
.searchbox button { position: absolute; right: 2px; top: 2px; }
.filters { display: flex; gap: 8px; padding: 12px var(--pad) 4px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .select { width: auto; height: 36px; border-radius: 999px; font-size: 13px; font-weight: 500; padding: 0 30px 0 12px; background-size: 16px; background-position: right 8px center; flex: none; }
.filters .select.set { border-color: var(--olive); background-color: var(--olive-soft); font-weight: 600; }
.filters .chip { flex: none; }
.amt-range { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 8px var(--pad) 0; align-items: center; }
.amt-range .input { height: 40px; }
.totalbar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--pad); background: var(--paper); border-top: 1px solid var(--line-2); margin-top: 8px; }
.totalbar b { font-weight: 700; }
.totalbar span { color: var(--ink-2); font-size: 14px; }

/* ---------- settings ---------- */
.set-group { margin: 0 var(--pad) var(--s5); border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 56px; }
.set-row:first-child { border-top: 0; }
.set-row > div:first-child { min-width: 0; }
.set-row b { font-weight: 600; display: block; }
.set-row small { display: block; font-size: 13px; line-height: 18px; color: var(--ink-3); }
.set-row .input, .set-row .select { width: 190px; height: 40px; flex: none; }
.set-row .btn { flex: none; }
.saved { font-size: 12px; color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }
.saved .ic { width: 14px; height: 14px; stroke-width: 2; }
.about { padding: 0 var(--pad) 24px; }

/* ---------- quick add ---------- */
.qa { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.qa-amt { display: flex; align-items: baseline; justify-content: center; min-height: 64px; padding: 4px 0 0; font: 400 56px/64px var(--serif); font-variant-numeric: normal; letter-spacing: -.01em; border-radius: var(--r3); cursor: text; }
.qa-amt.zero #qa-amt-v { color: var(--ink-3); }
.qa-amt:focus-visible { outline: none; }
.amt-caret { display: inline-block; width: 2px; height: 44px; margin-left: 3px; background: var(--olive); align-self: center; animation: blink 1.1s steps(1) infinite; }
.qa-amt:not(:focus) .amt-caret { visibility: hidden; }
@keyframes blink { 50% { opacity: 0; } }
.qa-sub { text-align: center; font-size: 13px; line-height: 18px; color: var(--ink-3); margin-top: -8px; min-height: 18px; }
.qa-sub button { color: var(--olive-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.qa-note { position: relative; display: block; }
.qa-note .ic { position: absolute; left: 12px; top: 12px; color: var(--ink-3); pointer-events: none; }
.qa-note .input { padding-left: 40px; }
.qa-guess { display: flex; align-items: center; gap: 6px; min-height: 18px; margin: -4px 0 -2px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.qa-guess b { font-weight: 700; color: var(--ink); }
.qa-guess .ic { width: 14px; height: 14px; color: var(--butter-deep); stroke-width: 2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.guessed { box-shadow: inset 0 0 0 1px var(--c), 0 0 0 3px var(--butter); }
.qa-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.qa-row .input { width: 150px; height: 40px; padding: 0 8px; font-size: 13px; font-weight: 500; }
.qa-extra { display: flex; gap: 8px; flex-wrap: wrap; }
.qa-split { display: grid; gap: 12px; padding: 12px; border-radius: var(--r3); background: var(--sunk); border: 1px solid var(--line); }
.qa-split .seg { background: var(--paper); }
.qa-split .line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.qa-split .line > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pad button { height: 46px; border-radius: var(--r2); background: var(--raised); border: 1px solid var(--line); font: 500 22px/1 var(--font); display: grid; place-items: center; transition: background-color .1s; user-select: none; -webkit-user-select: none; }
.pad button:hover { background: var(--sunk); }
.pad button:active, .pad button.hit { background: var(--butter-soft); border-color: var(--butter-deep); }
.pad button.fn { background: transparent; border-color: transparent; color: var(--ink-2); }
.pad .ic { width: 24px; height: 24px; }
/* the split editor needs the room: the pad steps aside until the amount is tapped again */
.qa.split-on:not(.pad-forced) .pad { display: none; }
.qa.split-on .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 3px var(--pad); }
.qa.split-on .chips::-webkit-scrollbar { display: none; }

/* ---------- transaction detail and receipt ---------- */
.tx-hero { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 0 0 16px; }
.tx-hero .glyph { width: 44px; height: 44px; border-radius: var(--r3); margin-bottom: 4px; }
.tx-hero h3 { font-size: 17px; line-height: 24px; font-weight: 600; }
.tx-hero p { color: var(--ink-3); font-size: 13px; }
.kv { display: grid; border: 1px solid var(--line); border-radius: var(--r3); background: var(--raised); }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 14px; border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--ink-3); flex: none; }
.kv dd { font-weight: 500; text-align: right; min-width: 0; }
.rcpt-wrap { display: grid; justify-items: center; padding: 20px 0 4px; }
.rcpt { width: min(100%, 296px); padding: 18px 18px 22px; background: #FFFEF8; color: #2A2A22; font: 400 12px/18px var(--mono); position: relative; box-shadow: 0 1px 0 rgba(0, 0, 0, .04), 0 6px 18px rgba(35, 40, 26, .1); transform: rotate(-.6deg); }
.rcpt::before, .rcpt::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background: linear-gradient(135deg, #FFFEF8 25%, transparent 25%) -6px 0 / 12px 8px, linear-gradient(225deg, #FFFEF8 25%, transparent 25%) -6px 0 / 12px 8px; }
.rcpt::before { top: -8px; transform: rotate(180deg); }
.rcpt::after { bottom: -8px; }
.rcpt h4 { font: 700 13px/18px var(--mono); text-align: center; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.rcpt .c { text-align: center; color: #6A6A5C; }
.rcpt hr { border: 0; border-top: 1px dashed #B9B8A6; margin: 8px 0; }
.rcpt .l { display: flex; justify-content: space-between; gap: 12px; }
.rcpt .l.t { font-weight: 700; font-size: 13px; }
.rcpt .code { height: 30px; margin: 10px 0 4px; background: repeating-linear-gradient(90deg, #2A2A22 0 2px, transparent 2px 3px, #2A2A22 3px 4px, transparent 4px 7px, #2A2A22 7px 10px, transparent 10px 12px); }
.rcpt-add { display: grid; justify-items: center; gap: 8px; padding: 20px; margin-top: 16px; border: 1.5px dashed var(--line-2); border-radius: var(--r3); text-align: center; color: var(--ink-2); font-size: 13px; }
.rcpt-add.busy { position: relative; overflow: hidden; }
.rcpt-add.busy::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--olive); animation: scan .9s ease-in-out infinite alternate; }
@keyframes scan { from { top: 8%; } to { top: 92%; } }

/* ---------- palette, shortcuts ---------- */
.pal-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pal-in .ic { color: var(--ink-3); }
.pal-in input { flex: 1; min-width: 0; border: 0; background: none; font-size: 17px; line-height: 24px; outline: none; }
.pal-in input::placeholder { color: var(--ink-3); }
.pal-list { padding: 6px; overflow-y: auto; }
.pal-list .sep { padding: 8px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 4px 10px; border-radius: var(--r2); }
.pal-item .ic { color: var(--ink-3); width: 18px; height: 18px; }
.pal-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pal-item small { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.pal-item.on { background: var(--olive-soft); }
.pal-item.on .ic { color: var(--olive); }
.pal-empty { padding: 20px 16px; color: var(--ink-2); }
.keys { display: grid; gap: 0; }
.keys div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.keys div:first-child { border-top: 0; }
.keys span.k { display: inline-flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: 12px; }
.more-list { display: grid; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 4px; border-top: 1px solid var(--line); font-weight: 500; width: 100%; }
.more-list > :first-child { border-top: 0; }
.more-list .ic { color: var(--ink-2); }
.more-list small { margin-left: auto; color: var(--ink-3); font-size: 13px; }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) var(--col) minmax(0, 1fr); background: var(--bg); }
.login-col { grid-column: 2; background: var(--paper); border-inline: 1px solid var(--line); padding: 40px 32px 32px; display: flex; flex-direction: column; min-height: 100vh; }
.login-col .brand { margin: 0 0 var(--s9); padding: 0; }
.login h1 { font: 400 44px/48px var(--serif); letter-spacing: -.015em; }
.login h1 em { font-style: normal; white-space: nowrap; }
.login .pitch { color: var(--ink-2); font-size: 17px; line-height: 26px; margin: 16px 0 28px; max-width: 380px; }
.login form { display: grid; gap: 14px; }
.or { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; color: var(--ink-3); font-size: 12px; margin: 20px 0; }
.or::before, .or::after { content: ""; border-top: 1px solid var(--line-2); }
.login-foot { margin-top: auto; padding-top: 32px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.login-side { grid-column: 3; align-self: center; justify-self: start; margin-left: 56px; width: 300px; }
.slip { background: var(--raised); border: 1px solid var(--line); padding: 20px 20px 18px; transform: rotate(1.6deg); box-shadow: var(--lift); position: relative; border-radius: 3px; }
.slip::before { content: ""; position: absolute; left: 50%; top: -11px; width: 76px; height: 22px; transform: translateX(-50%) rotate(-2deg); background: var(--butter); opacity: .85; }
.slip h2 { font: 400 22px/28px var(--serif); margin-bottom: 2px; }
.slip .fine { margin-bottom: 12px; }
.slip li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-top: 1px dashed var(--line-2); font-size: 14px; }
.slip li .bar { grid-column: 1 / -1; height: 5px; margin-top: 4px; }
.slip li b { font-weight: 600; }
.slip .tot { display: flex; justify-content: space-between; align-items: baseline; border-top: 1.5px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 600; }
.login-left { grid-column: 1; align-self: end; justify-self: end; margin: 0 48px 40px 0; max-width: 240px; color: var(--ink-3); font-size: 13px; line-height: 20px; }
.login-left b { display: block; color: var(--ink-2); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1231px) {
  .rail, .login-side, .login-left { display: none; }
}
@media (max-width: 943px) {
  :root { --col: 560px; }
  .shell { display: block; }
  .nav { display: none; }
  .col { max-width: var(--col); margin: 0 auto; padding-bottom: 104px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100vw, var(--col)); z-index: 40; background: var(--raised); border-top: 1px solid var(--line-2); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 4px 0; min-height: 48px; border-radius: var(--r2); font-size: 11px; line-height: 14px; font-weight: 600; color: var(--ink-3); }
  .tabbar .on { color: var(--olive-ink); }
  .tabbar .on .ic { color: var(--olive); }
  .tabbar .tab-add { position: relative; }
  .tabbar .tab-add span { display: grid; place-items: center; width: 56px; height: 56px; margin-top: -22px; border-radius: 50%; background: var(--butter); color: var(--on-butter); box-shadow: 0 0 0 5px var(--raised), 0 6px 14px rgba(35, 40, 26, .22); }
  .tabbar .tab-add .ic { width: 26px; height: 26px; stroke-width: 2; }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .only-wide { display: none !important; }
  html.sheet-open { overflow: hidden; }
  .filters { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); padding-right: 28px; }
  .login { display: block; }
  .login-col { max-width: var(--col); margin: 0 auto; }
  .totalbar { bottom: calc(68px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  :root { --pad: 16px; }
  .col, .login-col { border: 0; }
  .login-col { padding: 28px 20px 24px; }
  .login-col .brand { margin-bottom: var(--s8); }
  .login h1 { font-size: 38px; line-height: 42px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .set-row .input, .set-row .select { width: 150px; }
  .amt-xl { font-size: 40px; line-height: 44px; }
  .day { flex-basis: 38px; }
  .qa-row .seg .ic { display: none; }
  .qa-row .input { width: 136px; }
}
@media (min-width: 944px) { .only-phone { display: none !important; } .filters { flex-wrap: wrap; overflow: visible; } }
/* short or narrow screens: the pad folds away while the note is being typed */
@media (max-width: 943px), (max-height: 859px) {
  .qa:not(.pad-closed) .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--pad)); padding: 3px var(--pad); }
  .qa:not(.pad-closed) .chips::-webkit-scrollbar { display: none; }
  .qa.pad-closed .pad { display: none; }
  .qa-amt { font-size: 48px; line-height: 56px; min-height: 56px; }
}

/* small phones: tighten quick add so the pad and the save button stay on screen together */
@media (max-height: 760px) {
  .qa { gap: 8px; }
  .pad button { height: 42px; }
  .qa-amt { font-size: 40px; line-height: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
