/* Family Tracker - mobile only. Plain ASCII. */
:root, [data-theme="light"] {
  --bg: #F4F5F7; --card: #FFFFFF; --text: #14181D; --muted: #5F6873; --sub: #4A525C;
  --line: #E3E6EA; --border: #CDD2D8; --nav: #FFFFFF;
  --owe: #B45309; --paid: #1D4ED8; --track: #E3E6EA;
  --we-btn: #F59E0B; --we-btn-t: #111418; --they-btn: #2563EB; --they-btn-t: #FFFFFF;
  --inv: #14181D; --inv-t: #FFFFFF; --chip: #E8EBEF; --chip-t: #4A525C; --chip-on: #CDD2D8;
  --danger: #B91C1C;
}
[data-theme="dark"] {
  --bg: #111418; --card: #1C2026; --text: #F2F4F6; --muted: #9AA3AD; --sub: #B4BCC5;
  --line: #2A3038; --border: #3A414B; --nav: #171B20;
  --owe: #F59E0B; --paid: #60A5FA; --track: #2A3038;
  --we-btn: #F59E0B; --we-btn-t: #111418; --they-btn: #60A5FA; --they-btn-t: #111418;
  --inv: #F2F4F6; --inv-t: #111418; --chip: #2A3038; --chip-t: #B4BCC5; --chip-on: #3A414B;
  --danger: #F87171;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.35; -webkit-text-size-adjust: 100%;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; }

.c-owe { color: var(--owe); }
.c-paid { color: var(--paid); }
.c-muted, .muted { color: var(--muted); }
.sm { font-size: 13px; }
.xs { font-size: 12px; }
.sub { font-size: 13px; color: var(--sub); }
.pad { padding-left: 20px; padding-right: 20px; }
.gap-t { margin-top: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 10px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.lbl { display: block; font-size: 12px; color: var(--muted); letter-spacing: 1px; font-weight: 600; }

/* header */
.top { padding: calc(20px + env(safe-area-inset-top)) 20px 12px; display: flex; justify-content: space-between; align-items: center; }
.h1 { margin: 0; font-size: 26px; font-weight: 800; }
.bar-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; }
.back { justify-self: start; height: 44px; display: inline-flex; align-items: center; gap: 2px;
  padding: 0 16px 0 10px; border-radius: 22px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); font-size: 15px; font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.back:active { transform: scale(0.97); }
.back .chev { flex-shrink: 0; }
.back-x { padding: 0 16px; color: var(--sub); }
.back-sp { justify-self: end; }
.head-t { flex: 1; text-align: center; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* cards */
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card-t { font-size: 18px; font-weight: 700; }
.kid { display: flex; flex-direction: column; gap: 8px; }
.kid-top { display: flex; justify-content: space-between; align-items: baseline; }
.kid-n { font-size: 20px; font-weight: 700; }
.kid-bal { font-size: 40px; font-weight: 800; line-height: 1.1; }
.big-bal { font-size: 46px; font-weight: 800; line-height: 1.1; }
.mid { font-size: 18px; font-weight: 700; }
.bar { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--they-btn); border-radius: 4px; }
.bar-l { height: 10px; }

/* quick add buttons */
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.qbtn { height: 72px; border-radius: 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; }
.qbtn b { font-size: 18px; font-weight: 800; }
.qbtn span { font-size: 12px; font-weight: 600; }
.quick-s { margin-top: 12px; }
.quick-s .qbtn { height: 52px; }
.quick-s .qbtn b { font-size: 15px; }
.q-we { background: var(--we-btn); color: var(--we-btn-t); }
.q-they { background: var(--they-btn); color: var(--they-btn-t); }
.qbtn:active, .btn:active, .chip:active { transform: scale(0.98); }

/* lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.row-l { min-width: 0; }
.row-t { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-s { font-size: 12px; color: var(--muted); }
.row-amt { font-size: 16px; font-weight: 700; white-space: nowrap; }
.row-r { text-align: right; }
.row-after { font-size: 12px; color: var(--muted); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips-s { margin-top: 10px; }
.chips + .pad { margin-top: 14px; }
.chip { height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--border); background: transparent;
  color: var(--text); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; }
.chip.on { background: var(--inv); color: var(--inv-t); border-color: var(--inv); font-weight: 700; }
.chip-l { height: 44px; padding: 0 22px; font-size: 15px; }
.chip-s { height: 36px; padding: 0 14px; font-size: 13px; border: 0; background: var(--chip); color: var(--chip-t); }
.chip-s.on { background: var(--chip-on); color: var(--text); border: 0; }
.chip-x { padding-right: 4px; font-weight: 700; }
.chip-x.c-owe { color: var(--owe); }
.chip-x.c-paid { color: var(--paid); }
.chip-del { border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; font-size: 14px; font-weight: 700; }
.cat-h { margin-top: 10px; }

/* segmented */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
.seg-b { height: 52px; border: 0; background: var(--chip); color: var(--chip-t); font-size: 15px; font-weight: 700; }
.seg-b:first-child { border-radius: 12px 0 0 12px; }
.seg-b:last-child { border-radius: 0 12px 12px 0; }
.seg-b.on { background: var(--inv); color: var(--inv-t); }
.seg-b.on-we { background: var(--we-btn); color: var(--we-btn-t); font-weight: 800; }
.seg-b.on-they { background: var(--they-btn); color: var(--they-btn-t); font-weight: 800; }
.hint { margin-top: 8px; }

/* form */
.amt { margin: 4px 20px 0; display: flex; align-items: baseline; gap: 4px; border-bottom: 2px solid var(--they-btn); }
.amt-we { border-color: var(--we-btn); }
.amt-d { font-size: 36px; font-weight: 700; color: var(--muted); }
.amt-i { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: 52px; font-weight: 800; padding: 0; height: 72px; }
.amt-i::placeholder { color: var(--border); }
.inp { width: 100%; height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); padding: 0 14px; margin-top: 8px; -webkit-appearance: none; appearance: none; }
.inp:focus { outline: 2px solid var(--they-btn); outline-offset: 0; }
input[type="date"].inp { display: flex; align-items: center; line-height: 52px; }
.fld { display: block; min-width: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 0; font-size: 16px; font-weight: 700; }
.btn-big { width: 100%; min-height: 60px; border-radius: 16px; font-size: 17px; font-weight: 800; }
.btn-primary { background: var(--inv); color: var(--inv-t); }
.btn-we { background: var(--we-btn); color: var(--we-btn-t); }
.btn-they { background: var(--they-btn); color: var(--they-btn-t); }
.btn-danger { width: 100%; background: transparent; border: 1px solid var(--border); color: var(--danger); }
.btn-dash { width: 100%; margin-top: 10px; background: transparent; border: 1px dashed var(--border); color: var(--text); }
.save-wrap { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); }

/* settings lists */
.list-c { padding: 0; display: flex; flex-direction: column; }
.lrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); min-height: 52px; }
.lrow:last-child { border-bottom: 0; }
.lrow-l { min-width: 0; }
.lrow-b { display: flex; gap: 6px; flex-shrink: 0; }
.lrow-btn { width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 600; }
.pill { height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--border); background: transparent;
  color: var(--text); font-size: 13px; font-weight: 600; }
.pill-x { width: 36px; padding: 0; color: var(--danger); }
.pwf { flex-direction: column; align-items: stretch; }
.pwf .btn { margin-top: 8px; }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav); border-top: 1px solid var(--line); z-index: 10; }
.nav-i { display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: var(--muted); }
.nav-i.on { color: var(--text); font-weight: 800; }

/* toast */
.toast { position: fixed; left: 20px; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom)); padding: 14px 16px;
  border-radius: 12px; background: var(--inv); color: var(--inv-t); font-weight: 700; text-align: center;
  opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--danger); color: #FFFFFF; }
.screen-add .toast, .screen-edit .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }

/* login */
.lg { padding: calc(48px + env(safe-area-inset-top)) 24px 24px; max-width: 420px; margin: 0 auto; }
.lg-title { font-size: 30px; font-weight: 800; margin: 0 0 20px; }
.lg-intro { color: var(--sub); }
.lg-err { background: var(--card); border: 1px solid var(--danger); color: var(--danger); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px; font-weight: 600; }
.lg-form { display: flex; flex-direction: column; gap: 14px; }
.lg-field span { display: block; font-size: 12px; color: var(--muted); letter-spacing: 1px; font-weight: 600; }
.lg-field input { width: 100%; height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); padding: 0 14px; margin-top: 6px; }
