/* Budget — design tokens, then components. Mobile first; one column up to 560px. */
@font-face { font-family: "Inter"; src: url(fonts/inter.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --bg: #f4f4f0; --surface: #ffffff; --surface-2: #f0efea; --ink: #15191b; --ink-2: #3a4246; --muted: #6c7478; --faint: #a0a6a9;
  --line: rgba(20, 30, 35, .09); --line-strong: rgba(20, 30, 35, .16);
  --accent: #0d7a5f; --accent-ink: #ffffff; --accent-soft: #e2f1eb;
  --warn: #9a5f00; --warn-soft: #fbefd9; --bad: #c8372d; --bad-soft: #fbe3e0; --good: #0d7a5f;
  --track: #e9e8e2;
  --shared: #0d7a5f; --shared-soft: #e2f1eb; --private: #6b4bd6; --private-soft: #eeeafc; --outside: #b06a00; --outside-soft: #fbefd9; --unsorted: #8b8f91; --unsorted-soft: #efefec;
  --pending: #c9861c;
  --hero: #12382f; --hero-ink: #f1f7f4; --hero-muted: rgba(241, 247, 244, .68); --hero-track: rgba(255, 255, 255, .16);
  --shadow: 0 1px 2px rgba(16, 24, 28, .05), 0 1px 1px rgba(16, 24, 28, .03);
  --shadow-lg: 0 18px 50px rgba(10, 20, 25, .22);
  --r: 16px; --r-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f10; --surface: #171a1c; --surface-2: #1f2326; --ink: #eef1f2; --ink-2: #c9cfd2; --muted: #959ea3; --faint: #646d72;
    --line: rgba(255, 255, 255, .07); --line-strong: rgba(255, 255, 255, .14);
    --accent: #41c99c; --accent-ink: #062018; --accent-soft: #15322a;
    --warn: #efb555; --warn-soft: #33270f; --bad: #ff7a70; --bad-soft: #3a1c19; --good: #41c99c;
    --track: #262b2e;
    --shared: #41c99c; --shared-soft: #15322a; --private: #a891ff; --private-soft: #262044; --outside: #efb555; --outside-soft: #33270f; --unsorted: #8a9296; --unsorted-soft: #23272a;
    --pending: #e8a944;
    --hero: #15302a; --hero-ink: #eef7f3; --hero-muted: rgba(238, 247, 243, .62); --hero-track: rgba(255, 255, 255, .12);
    --shadow: none; --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, .amount, .big { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13.5px; }
.dim { opacity: .55; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.ico.sm { width: 16px; height: 16px; }
.ico.lg { width: 28px; height: 28px; stroke-width: 1.6; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: 0 1.1rem; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 15px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--accent); padding: 0 .5rem; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 .8rem; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: default; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); padding: 0; }
.iconbtn:hover { background: var(--surface-2); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: .5rem 0; min-height: 40px; }
.link.muted { color: var(--muted); font-weight: 500; }

/* ---- header ---- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); padding: calc(.55rem + env(safe-area-inset-top)) 1rem .55rem; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; max-width: 560px; margin: 0 auto; min-height: 44px; }
.top h1 { font-size: 26px; font-weight: 750; letter-spacing: -.025em; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; padding: 0; }
.period { display: none; align-items: center; gap: .1rem; max-width: 560px; margin: .2rem auto 0; }
body.has-period .period { display: flex; }
.period .iconbtn { width: 32px; height: 32px; color: var(--muted); }
#period-label { font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 0 .2rem; font-variant-numeric: tabular-nums; }
.period .tag { margin-left: .4rem; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: .15rem .5rem; border-radius: 99px; }

main { max-width: 560px; margin: 0 auto; padding: .25rem 1rem 1.5rem; }
main:focus { outline: none; }

/* ---- sections and grouped lists ---- */
.section { margin-top: 1.6rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin: 0 .25rem .5rem; }
.section-head h2 { font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.section-head .link { padding: 0; min-height: 0; font-size: 14px; }
.section-note { color: var(--muted); font-size: 13px; margin: .5rem .25rem 0; }
.group { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.cell { display: flex; align-items: center; gap: .8rem; min-height: 52px; padding: .65rem 1rem; position: relative; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; font: inherit; }
.cell + .cell::before { content: ""; position: absolute; top: 0; right: 0; left: 1rem; border-top: 1px solid var(--line); }
.cell.indent + .cell.indent::before { left: 3.95rem; }
button.cell, .cell.tap { cursor: pointer; }
button.cell:active, .cell.tap:active { background: var(--surface-2); }
.cell-main { flex: 1; min-width: 0; }
.cell-title { font-weight: 550; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-title.wrap { white-space: normal; }
.cell-sub { color: var(--muted); font-size: 13px; margin-top: 1px; display: flex; align-items: center; gap: .35rem; min-width: 0; }
.cell-sub > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-end { flex: none; display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: 14px; }
.cell .chev { color: var(--faint); }
.cell.danger .cell-title { color: var(--bad); }
.cell.accent .cell-title { color: var(--accent); }

/* leading icon tile */
.tile { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--unsorted-soft); color: var(--unsorted); font-weight: 700; font-size: 15px; }
.tile.round { border-radius: 50%; }
.tile.shared { background: var(--shared-soft); color: var(--shared); }
.tile.private { background: var(--private-soft); color: var(--private); }
.tile.outside { background: var(--outside-soft); color: var(--outside); }
.tile.unsorted { background: transparent; color: var(--unsorted); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.tile.split { background: linear-gradient(135deg, var(--shared-soft) 50%, var(--private-soft) 50%); color: var(--ink-2); }
.tile.transfer, .tile.income { background: var(--surface-2); color: var(--muted); }
.tile.warn { background: var(--warn-soft); color: var(--warn); }
.tile.accent { background: var(--accent-soft); color: var(--accent); }
.tile.bad { background: var(--bad-soft); color: var(--bad); }
.tile.plain { background: var(--surface-2); color: var(--ink-2); }

/* a small coloured dot naming a budget */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--unsorted); }
.dot.shared { background: var(--shared); } .dot.private { background: var(--private); } .dot.outside { background: var(--outside); }
.dot.unsorted { background: transparent; box-shadow: inset 0 0 0 1.5px var(--unsorted); }
.pend { display: inline-flex; align-items: center; gap: .2rem; color: var(--pending); font-weight: 550; flex: none; }
.amount { font-weight: 600; font-size: 15px; color: var(--ink); }
.amount.refund { color: var(--good); }
.amount.muted { color: var(--muted); font-weight: 500; }

/* ---- hero (overview) ---- */
.hero { background: var(--hero); color: var(--hero-ink); border-radius: 22px; padding: 1.15rem 1.2rem 1.1rem; margin-top: .35rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(closest-side, rgba(65, 201, 156, .28), transparent); pointer-events: none; }
.hero .eyebrow { color: var(--hero-muted); font-size: 13.5px; font-weight: 500; }
.hero .big { font-size: 40px; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; margin: .15rem 0 .1rem; }
.hero .big small { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-left: .15rem; color: var(--hero-muted); }
.hero .meta { display: flex; gap: 1.2rem; margin-top: .85rem; flex-wrap: wrap; }
.hero .meta div { font-size: 13px; color: var(--hero-muted); }
.hero .meta b { display: block; color: var(--hero-ink); font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hero .days { height: 4px; border-radius: 99px; background: var(--hero-track); margin-top: 1rem; overflow: hidden; }
.hero .days i { display: block; height: 100%; background: var(--hero-ink); opacity: .85; border-radius: 99px; }
.hero .days-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--hero-muted); margin-top: .4rem; }

/* ---- budget rows ---- */
.budget { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: .95rem 1rem 1rem; position: relative; cursor: pointer; }
.budget + .budget::before { content: ""; position: absolute; top: 0; left: 1rem; right: 0; border-top: 1px solid var(--line); }
.budget:active { background: var(--surface-2); }
.budget-top { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.budget-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: .45rem; min-width: 0; }
.budget-left { font-weight: 700; font-size: 17px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-left.neg { color: var(--bad); }
.budget-left small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: .25rem; letter-spacing: 0; }
.budget-sub { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: 13px; margin-top: .55rem; font-variant-numeric: tabular-nums; }
.bar { position: relative; display: flex; height: 8px; border-radius: 99px; background: var(--track); margin-top: .6rem; }
.bar .segs { display: flex; width: 100%; height: 100%; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar .booked { background: var(--c, var(--accent)); }
.bar .pending { background: var(--c, var(--accent)); opacity: .55; }
.bar .manual { background: var(--c, var(--accent)); opacity: .75; }
.bar .unsorted { background: repeating-linear-gradient(-45deg, var(--unsorted) 0 3px, transparent 3px 6px); opacity: .7; }
.bar.over .segs { box-shadow: inset 0 0 0 1px var(--bad); }
.bar.over .booked { background: var(--bad); }
.bar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--ink); opacity: .55; }
.budget.private { --c: var(--private); }
.budget.shared { --c: var(--shared); }
.legend { display: grid; gap: .1rem; }
.legend .cell { min-height: 40px; padding-top: .45rem; padding-bottom: .45rem; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--c, var(--accent)); }
.sw.pending { opacity: .55; } .sw.manual { opacity: .75; }
.sw.unsorted { background: repeating-linear-gradient(-45deg, var(--unsorted) 0 2px, transparent 2px 4px); }

/* ---- purchases ---- */
.toolbar { position: sticky; top: var(--top-h, 96px); z-index: 4; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); margin: 0 -1rem; padding: .25rem 1rem .5rem; }
.searchbox { position: relative; }
.searchbox .ico { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbox input { width: 100%; height: 40px; border-radius: 11px; border: 0; background: var(--surface-2); padding: 0 .9rem 0 2.4rem; font-size: 15px; }
.searchbox input::placeholder { color: var(--muted); }
.chips { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; margin: .55rem -1rem 0; padding: 0 1rem; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: .4rem; height: 32px; padding: 0 .8rem; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
.chip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed=true] .dot.unsorted { box-shadow: inset 0 0 0 1.5px var(--bg); }
.list-summary { display: flex; justify-content: space-between; align-items: baseline; margin: .9rem .25rem .2rem; font-size: 13.5px; color: var(--muted); }
.list-summary b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.day { display: flex; justify-content: space-between; align-items: baseline; margin: 1.1rem .25rem .4rem; font-size: 13px; font-weight: 650; color: var(--muted); }
.day .num { font-weight: 550; }
.year { font-size: 12px; color: var(--faint); margin-left: .3rem; }

/* ---- sorting ---- */
.sort-progress { display: flex; align-items: center; gap: .9rem; margin-top: .4rem; }
.sort-progress .big { font-size: 34px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.sort-progress .sub { line-height: 1.3; }
.sortcard { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); margin-top: .7rem; overflow: hidden; }
.sortcard .cell { padding-top: .8rem; padding-bottom: .55rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: .4rem; padding: 0 .75rem .75rem; }
.choice { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; height: 40px; border-radius: 11px; border: 0; background: var(--surface-2); font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding: 0 .5rem; white-space: nowrap; }
.choice .dot { width: 8px; height: 8px; }
.choice.shared:hover, .choice.shared:active { background: var(--shared-soft); color: var(--shared); }
.choice.private:hover, .choice.private:active { background: var(--private-soft); color: var(--private); }
.choice.outside:hover, .choice.outside:active { background: var(--outside-soft); color: var(--outside); }
.choice.more { width: 40px; padding: 0; color: var(--muted); }
.empty-state { text-align: center; padding: 3.5rem 1.5rem 2rem; }
.empty-state .tile { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 1rem; }
.empty-state h2 { font-size: 20px; font-weight: 700; }
.empty-state p { color: var(--muted); margin: .35rem 0 1.2rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---- notices ---- */
.notice { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .9rem; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: 13.5px; color: var(--ink-2); margin-top: .7rem; }
.notice .ico { margin-top: 1px; color: var(--muted); }
.notice.warn { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.notice.warn .ico { color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); box-shadow: none; font-weight: 600; }
.notice.bad .ico { color: var(--bad); }
.alerts { max-width: 560px; margin: 0 auto; padding: 0 1rem; }
.alerts:empty { display: none; }
.sync-line { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: 1.6rem 0 .5rem; color: var(--muted); font-size: 13px; }
.sync-line .stale { color: var(--warn); font-weight: 600; }
.sync-line button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: .4rem .2rem; display: inline-flex; align-items: center; gap: .25rem; }
.sync-line button[disabled] { color: var(--muted); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- forms ---- */
.field { display: block; margin-top: 1rem; }
.field > span, .label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 .25rem .4rem; }
.input, input[type=text], input[type=email], input[type=date], input[type=search], input:not([type]), select { min-height: 48px; width: 100%; padding: 0 .9rem; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.amount-entry { text-align: center; padding: 1.4rem 1rem 1rem; }
.amount-entry .wrap { display: inline-flex; align-items: baseline; justify-content: center; gap: .35rem; max-width: 100%; }
.amount-entry input { border: 0; background: transparent; box-shadow: none !important; font-size: 52px; font-weight: 750; letter-spacing: -.035em; text-align: right; width: 5.2ch; min-width: 2ch; padding: 0; min-height: 0; font-variant-numeric: tabular-nums; caret-color: var(--accent); }
.amount-entry input::placeholder { color: var(--faint); }
.amount-entry .cur { font-size: 26px; font-weight: 650; color: var(--muted); }
.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted); padding: 0 .5rem; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; white-space: nowrap; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.seg button[disabled] { opacity: .4; }
.datechips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.datechips input[type=date] { width: auto; min-height: 32px; height: 32px; border-radius: 99px; font-size: 13.5px; padding: 0 .7rem; }
.error-text { color: var(--bad); min-height: 1.3em; font-size: 13.5px; margin: .5rem .25rem 0; }
.form-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: .2rem 1rem 1.1rem; }

/* toggle switch */
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--track); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; border: 0; min-height: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.radio-check { color: var(--accent); }
.cell[aria-checked=false] .radio-check { visibility: hidden; }

/* ---- tab bar ---- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line); padding: 0 .25rem env(safe-area-inset-bottom); }
.tabs button { flex: 1; max-width: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 58px; border: 0; background: transparent; font-size: 10.5px; font-weight: 550; color: var(--faint); padding: 0; position: relative; letter-spacing: .005em; }
.tabs button .ico { width: 24px; height: 24px; stroke-width: 1.7; }
.tabs button[aria-current=page] { color: var(--accent); }
.tabs button[aria-current=page] .ico { stroke-width: 2.1; }
.tabs .count { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; background: var(--ink); color: var(--bg); padding: .7rem 1.05rem; border-radius: 14px; max-width: calc(100% - 2rem); box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550; display: flex; align-items: center; gap: .5rem; animation: rise .22s ease-out; }
.toast.error { background: var(--bad); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---- sheet ---- */
dialog { border: 0; border-radius: 22px 22px 0 0; padding: .5rem 1rem calc(1rem + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; margin: auto auto 0; background: var(--bg); color: var(--ink); max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
dialog[open] { animation: sheet .26s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet { from { transform: translateY(30%); opacity: .4; } }
dialog::backdrop { background: rgba(5, 10, 12, .42); }
.grabber { width: 38px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 0 auto .6rem; }
.sheet-head { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: .2rem; }
.sheet-head .cell-main { padding-top: .1rem; }
.sheet-head h2 { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.25; }
.sheet-head .iconbtn { background: var(--surface-2); width: 32px; height: 32px; margin-left: auto; color: var(--muted); }
.sheet-head .iconbtn .ico { width: 18px; height: 18px; }
.sheet-amount { font-size: 38px; font-weight: 750; letter-spacing: -.03em; margin: .7rem 0 .1rem; font-variant-numeric: tabular-nums; }
.sheet-amount.refund { color: var(--good); }
.raw { font-size: 12.5px; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.btns { display: flex; gap: .5rem; margin-top: 1.1rem; }
.btns > * { flex: 1; }
.quiet-actions { display: flex; justify-content: center; gap: 1.2rem; flex-wrap: wrap; margin-top: .8rem; font-size: 14px; }
.quiet-actions .label { margin: 0; align-self: center; font-weight: 500; }
.preview { margin-top: .9rem; }
.preview .cell { min-height: 44px; }
.note { color: var(--muted); font-size: 13px; margin: .6rem .25rem 0; }

/* ---- login ---- */
body.loggedout .top, body.loggedout .tabs { display: none; }
body.loggedout { padding-bottom: 0; }
.login { max-width: 360px; margin: 0 auto; min-height: 88vh; display: flex; flex-direction: column; justify-content: center; gap: .9rem; padding: 2rem 0; }
.brand { display: flex; flex-direction: column; align-items: center; gap: .8rem; margin-bottom: 1.2rem; text-align: center; }
.mark { width: 64px; height: 64px; border-radius: 18px; background: var(--hero); display: grid; place-items: center; box-shadow: 0 10px 30px rgba(13, 122, 95, .25); }
.mark svg { width: 38px; height: 38px; }
.brand h1 { font-size: 26px; font-weight: 750; letter-spacing: -.03em; }
.brand p { margin: 0; color: var(--muted); }
.login form { display: grid; gap: .6rem; }
.login input { min-height: 52px; font-size: 17px; }
.login input[inputmode=numeric] { font-size: 28px; letter-spacing: .45em; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; padding-left: 1.2rem; }
.login .btn { min-height: 52px; font-size: 16px; }
.login .links { display: flex; justify-content: center; gap: 1.2rem; }
.login .status { text-align: center; color: var(--muted); }
.toast[hidden] { display: none; }
.searchbox input[type=search] { min-height: 40px; height: 40px; border: 0; background: var(--surface-2); padding: 0 .9rem 0 2.4rem; border-radius: 11px; }
.searchbox input[type=search]:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.sort-head { margin: .3rem .25rem 0; }
.sort-head h2 { font-size: 20px; font-weight: 700; }
.more-row { justify-content: center; color: var(--accent); font-weight: 600; }
.cell.multiline .cell-sub > span { white-space: normal; }
.cell.multiline .cell-title { white-space: normal; }

/* ---- round 2 ---- */
.top { background: var(--bg); transition: box-shadow .2s; }
body.scrolled .top { box-shadow: 0 1px 0 var(--line); }
.top h1 { transition: font-size .18s ease; }
body.scrolled .top h1 { font-size: 19px; }
.toolbar { background: var(--bg); }
.hero .big.neg { color: #ffb4ab; }
.hero-sub { color: var(--hero-muted); font-size: 13.5px; }
.hero .meta b { font-size: 14px; }
.tile.sm { width: 26px; height: 26px; border-radius: 8px; }
.tile.sm .ico { width: 15px; height: 15px; }
.budget-name { gap: .55rem; }
.pace-ok { color: var(--good); font-weight: 550; }
.pace-warn { color: var(--warn); font-weight: 550; }
.pace-bad { color: var(--bad); font-weight: 600; }
.budget-sub span:last-child { color: var(--muted); }
.bar-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .6rem .25rem 0; font-size: 12px; color: var(--muted); }
.bar-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.bar-legend .sw { width: 12px; height: 6px; border-radius: 99px; --c: var(--muted); }
.bar-legend .tick { width: 2px; height: 10px; border-radius: 2px; background: var(--ink); opacity: .55; display: inline-block; }
.fineprint { display: flex; gap: .45rem; align-items: flex-start; color: var(--muted); font-size: 12.5px; margin: 1.2rem .25rem 0; line-height: 1.4; }
.fineprint .ico { margin-top: 1px; flex: none; }
.radio { color: var(--faint); display: grid; }
.cell[aria-checked=true] .radio { color: var(--accent); }
.cell[aria-checked=true] .cell-title { font-weight: 650; }
.choices { grid-template-columns: 1fr 1fr 1fr auto; }
.choice { font-size: 14px; }
.choice.more { width: auto; padding: 0 .85rem; color: var(--ink-2); }
.choice.guess.shared { background: var(--shared); color: #fff; }
.choice.guess.private { background: var(--private); color: #fff; }
@media (prefers-color-scheme: dark) { .choice.guess.shared, .choice.guess.private { color: #0d0f10; } }
.sortcard.leaving { opacity: .35; transform: scale(.98); transition: all .2s; }
.route { display: flex; align-items: center; gap: .3rem; font-size: 13px; color: var(--ink-2); margin-top: 2px; flex-wrap: wrap; }
.route .ico { color: var(--faint); }
.cell-end.col { flex-direction: column; align-items: flex-end; gap: .4rem; }
.plan-line { align-items: flex-start; padding-top: .85rem; padding-bottom: .85rem; }
.plan-line.done .cell-title, .plan-line.done .amount { color: var(--muted); }
.link.back { display: inline-flex; align-items: center; gap: .2rem; margin-left: -.3rem; }
.chips.tight { margin-top: .55rem; }
.mini-avatar { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.amount-entry { position: relative; }
.amount-entry::after { content: ""; display: block; width: 120px; height: 2px; border-radius: 2px; margin: .4rem auto 0; background: var(--line-strong); transition: background .2s, width .2s; }
.amount-entry:focus-within::after { background: var(--accent); width: 160px; }
.count-pill { background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; border-radius: 99px; min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; }

/* ---- round 3 ---- */
.tabs { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 .55rem; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); flex: none; }
.pill.ok { background: var(--accent-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.shared { background: var(--shared-soft); color: var(--shared); }
.pill.private { background: var(--private-soft); color: var(--private); }
.pill.outside { background: var(--outside-soft); color: var(--outside); }
.budget-sub { align-items: center; }
.title-row { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.title-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.round-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); padding: 0; flex: none; }
.round-btn.yes { background: var(--accent); color: var(--accent-ink); }
.round-btn.yes.private { background: var(--private); color: #fff; }
.round-btn.yes.outside { background: var(--outside); color: #fff; }
.choices { grid-template-columns: 1fr 1fr 1fr; }
.choice.guess { background: transparent; }
.choice.guess.shared { background: var(--shared-soft); color: var(--shared); box-shadow: inset 0 0 0 1.5px var(--shared); }
.choice.guess.private { background: var(--private-soft); color: var(--private); box-shadow: inset 0 0 0 1.5px var(--private); }
@media (prefers-color-scheme: dark) { .choice.guess.shared { color: var(--shared); } .choice.guess.private { color: var(--private); } }
.suggest-bar { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; padding: .6rem .6rem .6rem .9rem; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.suggest-bar span { color: var(--ink-2); }
.summary { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-top: .4rem; }
.summary-big { font-size: 36px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: .1rem 0; }
.plan-line { padding: 0; }
.plan-line + .plan-line { border-top: 1px solid var(--line); }
.plan-line .cell { align-items: center; }
.plan-actions { display: flex; gap: .5rem; padding: 0 1rem 1rem; }
.plan-actions .btn.block { flex: 1; }
.plan-status { display: flex; align-items: center; gap: .4rem; padding: 0 1rem .9rem 3.95rem; color: var(--good); font-size: 13.5px; font-weight: 550; }
.plan-status .link { margin-left: auto; padding: 0; min-height: 0; }
.sheet-amount.neg { color: var(--bad); }
.sheet-amount-label { font-size: 17px; font-weight: 650; margin-left: .4rem; letter-spacing: -.01em; color: var(--muted); }
.sheet-amount.neg .sheet-amount-label { color: var(--bad); }
dialog .bar { margin: .3rem 0 .4rem; }
.more-budgets { display: block; margin: .3rem auto 0; }
dialog .seg + .link, dialog .seg + .group { margin-top: .6rem; }

/* ---- round 4 ---- */
.top-row { justify-content: flex-start; }
.top-row .avatar { margin-left: auto; }
.top-row .back { margin-left: -.6rem; color: var(--accent); }
.top-row .back[hidden] { display: none; }
.tabs button { color: var(--muted); }
.hero .big.neg { color: var(--hero-ink); }
.pill.sm { height: 19px; font-size: 11.5px; padding: 0 .45rem; }
.cell-sub .pill { flex: none; }
.choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seg button.guess.shared { color: var(--shared); background: var(--shared-soft); }
.seg button.guess.private { color: var(--private); background: var(--private-soft); }
.seg-note { color: var(--muted); font-size: 13px; margin: .5rem .25rem .6rem; }
.datechoice { display: grid; gap: .5rem; }
.plan-line.solo .solo-amount { padding: 1.1rem 1rem .2rem; }
.plan-line.solo .solo-amount .summary-big { margin-bottom: 0; }
.pill.plain { background: var(--surface-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.choice.guess .ico { width: 14px; height: 14px; }
.cell.multiline .cell-sub { flex-wrap: wrap; row-gap: .15rem; }
.hero-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; position: relative; z-index: 1; }
.hero-col + .hero-col { border-left: 1px solid var(--hero-track); padding-left: 1rem; }
.hero-col .eyebrow { display: flex; align-items: center; gap: .4rem; }
.hero-col .big { font-size: 32px; }
.hero-col .big small { font-size: 16px; }
.hero .dot.shared { background: #41c99c; } .hero .dot.private { background: #b8a6ff; }
.hero-col:only-child { grid-column: 1 / -1; }
.sync-chip { margin-left: auto; display: inline-flex; align-items: center; gap: .3rem; height: 30px; padding: 0 .7rem; border-radius: 99px; border: 0; background: var(--surface-2); color: var(--ink-2); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sync-chip[hidden] { display: none; }
.sync-chip[disabled] { color: var(--muted); }
.sort-block { margin: .6rem 0 1.4rem; }
.sort-block .section-head { margin-top: .4rem; }
.sort-block .suggest-bar { margin-top: .5rem; }

/* ---- wide screens: the open iPhone Duo, tablets, desktop ---- */
.pane { display: none; }
.cell.selected { background: var(--accent-soft); }
.cell.selected .cell-title { color: var(--accent); }
.cols, .col { display: contents; }

@media (min-width: 700px) {
  body { padding-bottom: 0; padding-left: calc(88px + env(safe-area-inset-left)); }
  /* the tab bar becomes a rail */
  .tabs { top: 0; bottom: 0; right: auto; width: calc(88px + env(safe-area-inset-left)); flex-direction: column; justify-content: flex-start; gap: .35rem; padding: calc(1rem + env(safe-area-inset-top)) 0 1rem env(safe-area-inset-left); border-top: 0; border-right: 1px solid var(--line); }
  .tabs button { flex: none; height: 64px; max-width: none; width: 100%; font-size: 11px; }
  .tabs button[aria-current=page]::before { content: ""; position: absolute; left: 10px; right: 10px; top: 4px; bottom: 4px; border-radius: 14px; background: var(--accent-soft); z-index: -1; }
  .tabs button { z-index: 0; }
  .tabs .count { left: calc(50% + 8px); }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); left: calc(50% + 44px); }
  .top-row, .period, main, .alerts { max-width: 1040px; }
  main { padding-left: 1.5rem; padding-right: 1.5rem; }
  .top { padding-left: 1.5rem; padding-right: 1.5rem; }
  .top h1 { font-size: 30px; }

  /* overview in two columns */
  .cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 1.75rem; align-items: start; }
  .col { display: block; }
  .col > .section:first-child { margin-top: .35rem; }
  .hero-col .big { font-size: 40px; }

  /* settings flow into two columns */
  .settings-cols { columns: 2; column-gap: 1.75rem; }
  .settings-cols .section { break-inside: avoid; display: inline-block; width: 100%; margin-top: 0; margin-bottom: 1.6rem; }
  .settings-cols .section:first-child { margin-top: .35rem; }

  /* forms stay readable width */
  body[data-view=add] main { max-width: 600px; }
  body[data-view=plan] main { max-width: 640px; }

  /* sort cards side by side */
  .sort-block { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 .9rem; }
  .sort-block > .section-head, .sort-block > .section-note, .sort-block > .suggest-bar { grid-column: 1 / -1; }

  /* sheets become centred cards */
  dialog { margin: auto; border-radius: 22px; max-width: 520px; max-height: 86vh; padding-bottom: 1.25rem; }
  dialog .grabber { display: none; }
  dialog[open] { animation: pop .2s cubic-bezier(.2, .8, .2, 1); }
  @keyframes pop { from { transform: scale(.97); opacity: 0; } }
}

/* Köp: list and a detail pane side by side */
@media (min-width: 900px) {
  body[data-view=buy] { --pane-w: min(420px, 40vw); }
  body[data-view=buy] main, body[data-view=buy] .top-row, body[data-view=buy] .period, body[data-view=buy] .alerts { max-width: none; margin-left: 0; margin-right: calc(var(--pane-w) + 1rem); }
  body[data-view=buy] .pane { display: block; position: fixed; z-index: 7; top: 0; right: 0; bottom: 0; width: var(--pane-w); overflow-y: auto; background: var(--bg); border-left: 1px solid var(--line); padding: calc(1rem + env(safe-area-inset-top)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); }
  body[data-view=buy] .sort-block { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .pane-empty { height: 70vh; display: grid; place-content: center; justify-items: center; gap: .6rem; text-align: center; color: var(--muted); padding: 0 2rem; }
  .pane-empty .ico { color: var(--faint); }
  .pane .sheet-head .iconbtn { display: none; }
}

/* Installed app on iOS draws under the status bar (black-translucent). On the folded iPhone Duo that bar is a
   strip on the right: content runs under it, while the header keeps its buttons clear of the clock and Wi-Fi. */
.top { padding-right: max(1rem, env(safe-area-inset-right)); padding-left: max(1rem, env(safe-area-inset-left)); }
@media (min-width: 700px) { .top { padding-right: max(1.5rem, env(safe-area-inset-right)); } }
.toast { max-width: calc(100% - 2rem - env(safe-area-inset-right)); }
dialog { padding-right: max(1rem, env(safe-area-inset-right)); }
