/* Points: iPhone-style grouped lists, serif titles (as the icon), light or dark with the phone. */
:root {
  --bg: #f2f2f7; --cell: #fff; --fill: #e3e3e8; --ink: #111; --muted: #6c6c70; --chev: #c4c4c7;
  --line: #d1d1d6; --bar: rgba(249, 249, 249, 0.94); --accent: #1a6b52;
  --who0: #2a78d6; --who1: #c4521f; --who2: #7a4fc4; --who3: #1f8a5b;
  --soon-bg: #fff1cc; --soon-ink: #7a5300; --soon-text: #8a5d00;
  --urgent-bg: #fde2e0; --urgent-ink: #a3201a;
  --tier-bg: #ecefe9; --tier-ink: #3c4a44;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: -apple-system, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --cell: #1c1c1e; --fill: #2c2c2e; --ink: #f2f2f7; --muted: #98989f; --chev: #5a5a5e;
    --line: #38383a; --bar: rgba(22, 22, 24, 0.94); --accent: #3fb58f;
    --who0: #3987e5; --who1: #d95926; --who2: #9085e9; --who3: #2fae73;
    --soon-bg: #3d2f00; --soon-ink: #ffd60a; --soon-text: #ffd60a;
    --urgent-bg: #3a1312; --urgent-ink: #ff6961;
    --tier-bg: #2c2c2e; --tier-ink: #d1d1d6;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.35 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
main { max-width: 640px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
body.has-tabs main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
button, input { font: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.note { margin: 0 8px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.note code { font: 12px ui-monospace, Menlo, monospace; }
.bad { color: var(--urgent-ink); font-weight: 600; margin: 0; }

/* Titles */
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
h1 { margin: 0; font: 600 34px/1.1 var(--serif); letter-spacing: -0.01em; }
.sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.overline { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.round { width: 44px; height: 44px; border-radius: 22px; background: var(--cell); color: var(--ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 17px; margin: -10px 0 -6px; }
.back span { font-size: 28px; line-height: 1; }

/* Everyone / one person */
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 2px; background: var(--fill); border-radius: 9px; padding: 2px; }
.seg a { min-height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--ink); font-size: 13px; }
.seg a[aria-current] { background: var(--cell); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Badges and person dots */
.badge { border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; background: var(--tier-bg); color: var(--tier-ink); }
.badge.soon { background: var(--soon-bg); color: var(--soon-ink); }
.badge.urgent { background: var(--urgent-bg); color: var(--urgent-ink); }
.avatar { width: 30px; height: 30px; border-radius: 15px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.big { width: 34px; height: 34px; border-radius: 17px; font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; flex-shrink: 0; }
.who0 { background: var(--who0); } .who1 { background: var(--who1); }
.who2 { background: var(--who2); } .who3 { background: var(--who3); }

/* Next to expire */
.hero { display: block; background: var(--cell); border-radius: 14px; padding: 16px; color: var(--ink); }
.hero-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero-name { margin-top: 10px; font: 600 22px/1.2 var(--serif); }
.hero-amount { margin-top: 2px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.hero-amount b { font-size: 28px; font-variant-numeric: tabular-nums; }
.hero-when { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* Grouped lists */
.section-label { display: flex; justify-content: space-between; margin: 4px 16px 6px; }
.section-label span + span { text-transform: none; font-weight: 400; letter-spacing: 0; }
.list { background: var(--cell); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; min-height: 44px; color: var(--ink); }
.list > * + * { border-top: 0.5px solid var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-width: 0; }
.row-sub span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; flex-shrink: 0; }
.row-end b { display: block; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-end small { display: block; font-size: 12px; color: var(--muted); }
.row-end small.soon { color: var(--soon-text); font-weight: 600; }
.chev { color: var(--chev); font-size: 22px; line-height: 1; }
.more { display: flex; justify-content: space-between; padding: 12px 16px; min-height: 44px; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; margin: 0; }

/* Search */
.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 10px; padding: 0 10px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); min-height: 40px; outline: none; font-size: 16px; }

/* A programme */
.total { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.person { background: var(--cell); border-radius: 14px; overflow: hidden; }
.person-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 8px; }
.person-balance { padding: 0 16px 10px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.person-balance b { font-size: 30px; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 16px; border-top: 0.5px solid var(--line); min-height: 44px; }
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; font-weight: 600; }
.kv .soon { color: var(--soon-text); } .kv .urgent { color: var(--urgent-ink); }
.kv small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.spark { padding: 10px 16px 14px; border-top: 0.5px solid var(--line); }
.spark-head, .spark-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.spark-axis { font-size: 12px; }
.spark svg { display: block; width: 100%; height: 54px; margin: 6px 0 2px; overflow: visible; }
.spark polyline { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark .base { stroke: var(--line); stroke-width: 1; }
.spark polyline.who0 { stroke: var(--who0); background: none; } .spark polyline.who1 { stroke: var(--who1); background: none; }
.spark polyline.who2 { stroke: var(--who2); background: none; } .spark polyline.who3 { stroke: var(--who3); background: none; }
.spark circle.who0 { fill: var(--who0); } .spark circle.who1 { fill: var(--who1); }
.spark circle.who2 { fill: var(--who2); } .spark circle.who3 { fill: var(--who3); }
.warn { padding: 10px 16px; border-top: 0.5px solid var(--line); color: var(--urgent-ink); font-size: 13px; }

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--bar); border-top: 0.5px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; justify-content: center; font-size: 10px; font-weight: 600; color: var(--muted); }
.tabs a[aria-current] { color: var(--accent); }

/* Sign-in and settings */
.box { background: var(--cell); border-radius: 14px; padding: 16px; }
.box h2 { margin: 0 0 6px; font: 600 18px/1.3 var(--serif); }
.login { display: flex; flex-direction: column; gap: 10px; }
.login label { color: var(--muted); font-size: 14px; }
.login input { color: var(--ink); background: var(--cell); border: 0.5px solid var(--line); border-radius: 10px; padding: 12px; font-size: 17px; }
.login button, .push-actions button { min-height: 44px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.login button { border: 0; background: var(--accent); color: #fff; }
.push-state { margin: 0; color: var(--muted); }
.push-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.push-actions:not(:has(button:not([hidden]))) { display: none; }
.push-actions button { border: 0; background: var(--fill); color: var(--ink); padding: 0 16px; }
.push-actions button.subtle { background: none; color: var(--muted); }
.signout { display: flex; justify-content: center; }
.signout button { background: none; border: 0; color: var(--urgent-ink); font-size: 15px; min-height: 44px; cursor: pointer; }
.box .note { margin: 12px 0 0; }
.sub.stale { color: var(--soon-text); font-weight: 600; }
.sub.stale svg { vertical-align: -2px; }
.sub code { font: 12px ui-monospace, Menlo, monospace; }
