/* ================================================================
   Tokens — light theme only
   Palette: #EFECE3 beige · #8FABD4 light blue · #4A70A9 blue · #000000 black
   ================================================================ */
:root {
  --font: 'Google Sans', 'Google Sans Text', 'Product Sans', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --app-w: 480px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --bg: #efece3;
  --surface: #fbfaf7;
  --surface-2: #ebe7dc;
  --text: #111111;
  --text-2: #55524a;
  --text-3: #858176;
  --line: #e3dfd3;
  --line-strong: #d2ccbd;

  --accent: #4a70a9;
  --accent-ink: #ffffff;
  --accent-weak: #dde6f3;
  --accent-text: #3a5d92;
  --tone-acc: #3a5d92;
  --tone-acc-weak: #dde6f3;

  --pos: #1e7a3c;
  --pos-weak: #e2efe1;
  --neg: #b3261e;
  --neg-weak: #f6e1dc;
  --warn: #a35a00;
  --warn-weak: #f6ead2;
  --hi: #dfe7f3;

  --chart-in: #4a70a9;
  --chart-out: #8fabd4;
  --meter: #4a70a9;

  --hero-bg: #ffffff;
  --hero-border: #e3dfd3;
  --hero-text: #111111;
  --hero-text-2: #55524a;
  --hero-line: #e3dfd3;
  --hero-pos: #1e7a3c;
  --hero-neg: #b3261e;
  --hero-acc: #3a5d92;

  --fab-bg: #4a70a9;
  --fab-ink: #ffffff;
  --fab-shadow: 0 2px 6px rgba(74, 112, 169, .35);
  --nav-active: #3a5d92;
  --nav-pill: transparent;
  --toast-bg: #000000;
  --toast-text: #efece3;

  --shadow: 0 1px 2px rgba(0, 0, 0, .08);
  --overlay: rgba(0, 0, 0, .45);
  color-scheme: light;
}

/* ================================================================
   Base
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3 { margin: 0; font-weight: 500; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.acc { color: var(--tone-acc); }
.muted { color: var(--text-3); }
.num, .balance-value, .row-amt, .split-v, .tile-v, .totals-v, .detail-amt, .amount input { font-variant-numeric: tabular-nums; }

/* ================================================================
   App frame (mobile-first; centred column on larger screens)
   ================================================================ */
.app {
  max-width: var(--app-w);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
}
@media (min-width: 560px) {
  body { background: var(--surface-2); }
  .app { border-inline: 1px solid var(--line); }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .18)); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.account-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--accent-weak); color: var(--accent-text);
  font-size: 13.5px; font-weight: 500;
}
.account-btn:active { filter: brightness(.94); }
.brand h1 { font-size: 20px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .back { margin-left: -8px; color: var(--text); }

.period {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}
.period select {
  appearance: none;
  border: 0;
  background: transparent;
  height: 100%;
  padding: 0 34px 0 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  max-width: 180px;
}
.period select:focus-visible { outline: none; }
.period:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.period svg { position: absolute; right: 10px; width: 18px; height: 18px; pointer-events: none; color: var(--text-2); }

.view {
  padding: 4px 16px calc(var(--tab-h) + var(--safe-b) + 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ================================================================
   Bottom navigation
   ================================================================ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--app-w));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 100%;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
}
.tabbar button svg { width: 22px; height: 22px; padding: 3px 14px; box-sizing: content-box; border-radius: 99px; }
.tabbar button[aria-current="page"] { color: var(--nav-active); }
.tabbar button[aria-current="page"] svg { stroke-width: 2.2; background: var(--nav-pill); }
.tabbar .fab {
  justify-self: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--fab-bg);
  color: var(--fab-ink);
  box-shadow: var(--fab-shadow);
}
.tabbar .fab svg { width: 26px; height: 26px; stroke-width: 2.2; }

/* ================================================================
   Surfaces
   ================================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card-flush { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .section-head h2 { font-size: 16px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.link { color: var(--accent-text); font-weight: 500; font-size: 14px; padding: 6px 4px; }
.fine { margin: 2px 4px 0; font-size: 12.5px; color: var(--text-3); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.pos { background: var(--pos); }
.dot.neg { background: var(--neg); }

.badge {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
}
.badge.pos { background: var(--pos-weak); color: var(--pos); }
.badge.neg { background: var(--neg-weak); color: var(--neg); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.acc { background: var(--tone-acc-weak); color: var(--tone-acc); }
.count {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); color: var(--text-2);
}

/* ---------- balance (summary card at the top of a screen) ---------- */
.balance { padding: 20px 18px 16px; background: var(--hero-bg); border-color: var(--hero-border); color: var(--hero-text); }
.balance-label { font-size: 13px; color: var(--hero-text-2); }
.balance-value { font-size: 36px; font-weight: 500; letter-spacing: -.02em; margin: 4px 0 16px; line-height: 1.15; }
.balance .neg { color: var(--hero-neg); }
.balance .pos { color: var(--hero-pos); }
.balance .dot.pos { background: var(--hero-pos); }
.balance .dot.neg { background: var(--hero-neg); }
.split { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--hero-line); padding-top: 14px; }
.split-item { display: flex; flex-direction: column; gap: 2px; }
.split-item + .split-item { border-left: 1px solid var(--hero-line); padding-left: 16px; }
.split-k { font-size: 12.5px; color: var(--hero-text-2); }
.split-v { font-size: 16px; font-weight: 500; }
.balance-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--hero-line);
  color: var(--hero-text-2);
  font-size: 13px;
}
.balance-note svg { width: 18px; height: 18px; color: var(--hero-acc); margin-top: 1px; }
.balance-note strong { color: var(--hero-acc); font-weight: 500; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.tile-k { font-size: 13px; color: var(--text-2); }
.tile-v { font-size: 18px; font-weight: 500; margin-top: 2px; }
.tile-s { font-size: 12px; color: var(--text-3); }

/* ---------- notice ---------- */
.notice {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--pos-weak);
}
.notice-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--pos); color: var(--surface); flex: none; }
.notice-icon svg { stroke-width: 2.4; }
.notice-body { flex: 1; min-width: 0; }
.notice-title { font-weight: 500; }
.notice-text { font-size: 13px; color: var(--text-2); }

/* ---------- welcome / empty ---------- */
.welcome { text-align: center; padding: 32px 22px 22px; margin-top: 24px; }
.welcome-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-weak); color: var(--accent-text); margin-bottom: 14px; }
.welcome-mark svg { width: 28px; height: 28px; }
.welcome h2 { font-size: 22px; margin-bottom: 6px; }
.welcome p { color: var(--text-2); margin: 0 0 20px; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; padding: 32px 20px; color: var(--text-2); }
.empty-title { color: var(--text); font-weight: 500; font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0 0 14px; font-size: 14px; }

/* ================================================================
   Rows / lists
   ================================================================ */
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  min-height: 64px;
}
.list .row + .row { border-top: 1px solid var(--line); }
.row:active, .tile:active { background: var(--surface-2); }
.row-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  flex: none;
  background: var(--surface-2);
  color: var(--text-2);
}
.row-icon.pos { background: var(--pos-weak); color: var(--pos); }
.row-icon.neg { background: var(--neg-weak); color: var(--neg); }
.row-icon.neutral { background: var(--accent-weak); color: var(--accent-text); }
.row-icon.acc { background: var(--tone-acc-weak); color: var(--tone-acc); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.warn { color: var(--warn); }
.row-clip svg { width: 14px; height: 14px; color: var(--text-3); vertical-align: -2px; margin-left: 6px; }
.row-amt { font-weight: 500; white-space: nowrap; }
.row-chev { color: var(--text-3); }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.row-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.row-meta.pos { color: var(--pos); }
.row-meta.neg { color: var(--neg); }
.avatar {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  flex: none;
  font-size: 14px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
}
.avatar.pos { background: var(--pos-weak); color: var(--pos); }
.avatar.neg { background: var(--neg-weak); color: var(--neg); }
.avatar.acc { background: var(--tone-acc-weak); color: var(--tone-acc); }
.row-icon.num { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- ledger ---------- */
.totals {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.totals > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-width: 0; }
.totals > div:nth-child(2) { border-left: 1px solid var(--line); }
.totals-k { font-size: 12px; color: var(--text-2); }
.totals-v { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.totals .totals-bal { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; background: var(--hi); border-top: 1px solid var(--line); }
.totals-bal .totals-k { font-size: 13px; color: var(--text); font-weight: 500; }
.totals-bal .totals-v { font-size: 16px; font-weight: 700; }
.totals .totals-dep { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }

.toolbar { display: flex; flex-direction: column; gap: 10px; }
.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
}
.seg-btn {
  flex: 1;
  height: 34px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-btn[aria-pressed="true"] .count { background: var(--accent-weak); color: var(--accent-text); }
.seg-wide .seg-btn { height: 38px; }
.search {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; color: var(--text); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.group { display: flex; flex-direction: column; gap: 8px; }
.group + .group { margin-top: 14px; }
.group-head { display: flex; justify-content: space-between; padding: 0 4px; font-size: 13px; font-weight: 500; color: var(--text-2); }

/* ---------- chart ---------- */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis { fill: var(--text-3); font-size: 10.5px; stroke: none; font-family: var(--font); }
.chart .axis.active { fill: var(--text); font-weight: 700; }
.chart .bar-in { fill: var(--chart-in); stroke: none; }
.chart .bar-out { fill: var(--chart-out); stroke: none; }
.dot.in { background: var(--chart-in); }
.dot.out { background: var(--chart-out); }
.legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-2); }
.card-sub { font-size: 13px; color: var(--text-3); }
.meter-pct { font-size: 28px; font-weight: 500; letter-spacing: -.01em; line-height: 1.1; }
.meter-pct small { font-size: 14px; font-weight: 400; color: var(--text-2); margin-left: 4px; letter-spacing: 0; }
.meter { height: 8px; margin: 12px 0 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--meter); }
.meter.over span { background: var(--neg); }
.meter-legend { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text-2); }
.meter-legend strong { color: var(--text); font-weight: 500; }

/* ---------- person record ---------- */
.toolbar-row { flex-direction: row; align-items: center; }
.toolbar-row .search { flex: 1; min-width: 0; }
.toolbar-row .btn { flex: none; }
.section-count { font-size: 13px; color: var(--text-3); }
.bill-meta { font-size: 13px; color: var(--hero-text-2); margin-top: -10px; }
.move-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.move-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.move-text .row-sub { white-space: normal; }
.person-note { margin: 12px 0 0; font-size: 13px; color: var(--hero-text-2); white-space: pre-line; }
.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-gave { background: var(--neg-weak); color: var(--neg); }
.btn-took { background: var(--pos-weak); color: var(--pos); }
.person-actions { display: flex; justify-content: center; margin-top: -6px; }
.delete-record { align-self: flex-start; margin-left: -14px; }

/* ---------- statement sheet (reports) ---------- */
.statement .card-head h2 { font-size: 20px; }
.stmt { width: 100%; border-collapse: collapse; margin: 4px 0 16px; font-size: 14px; }
.stmt th { font-size: 12px; font-weight: 500; color: var(--text-2); text-align: left; padding: 8px 10px; background: var(--surface-2); }
.stmt th:first-child { border-radius: 8px 0 0 8px; }
.stmt th:last-child { border-radius: 0 8px 8px 0; }
.stmt td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stmt tbody tr { cursor: pointer; }
.stmt tbody tr:active { background: var(--surface-2); }
.stmt .num { text-align: right; white-space: nowrap; font-weight: 500; }
.stmt-p { display: block; font-weight: 500; }
.stmt-d { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.stmt tfoot td { border-bottom: 0; padding-top: 8px; padding-bottom: 4px; color: var(--text-2); }
.stmt tfoot tr:first-child td { padding-top: 14px; }
.stmt .stmt-bal td { background: var(--hi); color: var(--text); font-weight: 700; padding: 12px 10px; }
.stmt .stmt-bal td:first-child { border-radius: 8px 0 0 8px; }
.stmt .stmt-bal td:last-child { border-radius: 0 8px 8px 0; }

.install { display: flex; align-items: center; gap: 12px; }
.install .row-sub { white-space: normal; }

/* ================================================================
   Buttons
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14.5px;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-tonal { background: var(--accent-weak); color: var(--accent-text); }
.btn-text { color: var(--accent-text); padding: 0 14px; }
.btn-text.danger { color: var(--neg); }
.btn-danger { background: var(--neg); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { filter: brightness(.94); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text-2); flex: none; }
.icon-btn:active { background: var(--surface-2); }

/* ================================================================
   Sheets
   ================================================================ */
.overlay { position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
.sheet {
  position: fixed;
  z-index: 41;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--app-w));
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  animation: sheet-in .2s ease-out;
}
.sheet-full { top: 0; max-height: none; border-radius: 0; }
@media (min-width: 560px) {
  .sheet-full { top: 24px; bottom: 24px; border-radius: 20px; }
}
@keyframes sheet-in { from { transform: translate(-50%, 24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.grabber { width: 36px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 10px auto 0; flex: none; }
.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-t)) 8px 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet:not(.sheet-full) .sheet-head { padding-top: 8px; }
.sheet-head h2 { font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.sheet-foot .spacer { flex: 1; }
.form { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- kind picker ---------- */
.kinds { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.kinds legend { font-size: 13px; font-weight: 500; color: var(--text-2); padding: 0; margin-bottom: 8px; }
.kind-group-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.kind input { position: absolute; opacity: 0; pointer-events: none; }
.kind-icon {
  margin-bottom: 8px;
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px;
}
.kind-icon svg { width: 18px; height: 18px; }
.kind-icon.pos { background: var(--pos-weak); color: var(--pos); }
.kind-icon.neg { background: var(--neg-weak); color: var(--neg); }
.kind-icon.acc { background: var(--tone-acc-weak); color: var(--tone-acc); }
.kind:has(input:checked) .kind-icon.acc { background: var(--surface); }
.kind-wide { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.kind-wide .kind-icon { grid-row: span 2; margin: 0; }
.kind-t { font-weight: 500; font-size: 14px; line-height: 1.25; }
.kind-h { font-size: 11.5px; color: var(--text-3); line-height: 1.3; }
.kind:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); box-shadow: inset 0 0 0 1px var(--accent); }
.kind:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- fields ---------- */
.amount {
  display: flex; align-items: center; gap: 6px;
  border-bottom: 2px solid var(--line-strong);
  padding: 4px 2px 8px;
}
.amount:focus-within { border-color: var(--accent); }
.amount-cur { font-size: 28px; color: var(--text-2); }
.amount input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: none;
  font-size: 34px; font-weight: 500; letter-spacing: -.01em;
}
.amount input::placeholder { color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.opt { font-weight: 400; color: var(--text-3); }
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 0;
  font-size: 16px; /* prevents iOS zoom on focus */
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
input[type="date"].input { appearance: none; -webkit-appearance: none; }
.form-error { margin: 0; min-height: 1px; color: var(--neg); font-size: 13.5px; }
.form-error:empty { display: none; }


.attach-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 52px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--accent-text);
  font-weight: 500;
}
.attach-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}
.attach-item img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; }
.attach-file { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 8px; background: var(--neg-weak); color: var(--neg); flex: none; }
.attach-view { display: block; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.attach-view img { display: block; width: 100%; max-height: 280px; object-fit: cover; }

/* ---------- detail ---------- */
.detail { padding: 8px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.detail-top { display: flex; align-items: center; gap: 10px; }
.detail-top .icon-btn { margin-left: auto; margin-right: -8px; }
.detail-amt { font-size: 32px; font-weight: 500; letter-spacing: -.02em; }
.facts { margin: 0; border-top: 1px solid var(--line); }
.facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--text-2); font-size: 14px; flex: none; }
.facts dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.sub-head { font-size: 13px; font-weight: 500; color: var(--text-2); }

/* ================================================================
   Dialog & toast
   ================================================================ */
.dialog-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: var(--overlay); }
.dialog { width: min(100%, 340px); background: var(--surface); border-radius: 24px; padding: 22px 22px 14px; }
.dialog h3 { font-size: 19px; margin-bottom: 8px; }
.dialog p { margin: 0 0 18px; color: var(--text-2); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(calc(100% - 32px), 420px);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s, visibility .15s;
}
.toast.show { opacity: 1; visibility: visible; }

/* ================================================================
   Sign in / create account
   ================================================================ */
/* Twemoji flags (CC-BY 4.0) so country flags also show on Windows. */
@font-face {
  font-family: 'Twemoji Country Flags';
  src: url('vendor/fonts/TwemojiCountryFlags.woff2') format('woff2');
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  font-display: swap;
}
body.signed-out { background: var(--bg); }
#auth-root { min-height: 100dvh; }
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center; gap: 20px;
  padding: calc(32px + var(--safe-t)) 16px calc(24px + var(--safe-b));
}
.auth-brand { text-align: center; }
.auth-mark { display: inline-block; width: 80px; height: 80px; margin-bottom: 8px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .16)); }
.auth-brand h1 { font-size: 26px; font-weight: 500; letter-spacing: -.01em; }
.auth-brand p { margin: 4px 0 0; color: var(--text-2); }
.auth-card { padding: 20px 18px; }
.auth-tabs { margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-head { margin-bottom: 16px; }
.auth-head h2, .auth-state h2 { font-size: 20px; margin-bottom: 6px; }
.auth-head p, .auth-state p { margin: 0; color: var(--text-2); font-size: 14px; }
.auth-head code { font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.auth-link { align-self: flex-end; margin-top: -6px; }
.auth-link.center { align-self: center; margin-top: 4px; }
.auth-small { margin: 0; font-size: 12.5px; color: var(--text-3); text-align: center; }
.auth-msg { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--pos-weak); color: var(--pos); font-size: 13.5px; }
.auth-foot { margin: 0; text-align: center; font-size: 12.5px; color: var(--text-3); }
.auth-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.auth-state .btn { margin-top: 6px; }
.auth-state-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-weak); color: var(--accent-text);
}
.auth-state-icon svg { width: 26px; height: 26px; }
.field-hint { font-size: 12.5px; color: var(--text-3); }
.pw { position: relative; }
.pw .input { padding-right: 68px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 36px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--accent-text);
}
.phone { display: flex; align-items: stretch; gap: 8px; }
.phone .input { flex: 1; min-width: 0; }
.phone-country {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-weight: 500; white-space: nowrap; cursor: pointer;
}
.phone-country:focus-within { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.phone-country svg { width: 16px; height: 16px; color: var(--text-2); }
.phone-flag { font-family: 'Twemoji Country Flags', var(--font); font-size: 20px; line-height: 1; }
.phone-country select {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  font-family: 'Twemoji Country Flags', var(--font); font-size: 16px;
}

/* ================================================================
   Account card (Reports)
   ================================================================ */
.account { display: flex; flex-direction: column; gap: 14px; }
.account-sheet { padding: 8px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.account-sheet .account-top { padding: 6px 0 4px; }
.account-sheet .avatar { width: 48px; height: 48px; font-size: 16px; }
.account-sheet .row-title { font-size: 17px; }
.btn-danger-soft { background: var(--neg-weak); color: var(--neg); }

/* Find a registered user (new person record) */
.find-row { display: flex; gap: 8px; }
.find-row .input { flex: 1; min-width: 0; }
.find-row .btn { flex: none; height: auto; min-height: 48px; border-radius: var(--radius-sm); }
.find-status { margin: 2px 2px 0; font-size: 13px; color: var(--text-2); }
.find-status.error { color: var(--neg); }
.found {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent-weak);
}
.found .row-sub { white-space: normal; }
.ledger-badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px; border-radius: 999px;
  background: var(--accent-weak); color: var(--accent-text);
  font-size: 11.5px; font-weight: 500; vertical-align: 1px;
}
.balance .ledger-badge { margin-top: 10px; }
.account-top { display: flex; align-items: center; gap: 12px; }
.account-top .row-sub { white-space: normal; overflow-wrap: anywhere; }
.sync-line {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px; color: var(--text-2);
}
.sync-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; flex: none; background: var(--text-3); }
.sync-dot.ok { background: var(--pos); }
.sync-dot.busy { background: var(--accent); }
.sync-dot.warn { background: var(--warn); }
.sync-dot.error { background: var(--neg); }
.account-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.account-actions .btn-text { padding: 0 8px; }

/* Account panel: name and email rows */
.account-list .row { min-height: 62px; }
.account-list .row-main .row-sub:first-child { font-size: 12px; color: var(--text-3); }
.account-list .row-sub.warn { white-space: normal; }
.lead-text { margin: 0; font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; }
.lead-text strong { color: var(--text); font-weight: 500; }

/* Password confirmation dialog */
.dialog .field { margin-bottom: 12px; }
.dialog p.form-error { margin: -4px 0 12px; color: var(--neg); }

/* Backup / restore progress */
.progress-dialog { text-align: center; padding: 24px 22px 18px; }
.progress-dialog .pd-icon {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; border-radius: 50%;
  margin-bottom: 12px;
  background: var(--accent-weak); color: var(--accent-text);
}
.progress-dialog .pd-icon svg { width: 28px; height: 28px; }
.progress-dialog .pd-icon.ok { background: var(--pos-weak); color: var(--pos); }
.progress-dialog .pd-icon.error { background: var(--neg-weak); color: var(--neg); }
.progress-dialog h3 { margin-bottom: 6px; }
.pd-pct { font-size: 34px; font-weight: 500; letter-spacing: -.01em; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.pd-meter { margin: 10px 0 12px; }
.pd-meter span { transition: width .2s ease-out; }
.pd-meter.busy span { width: 35%; animation: pd-busy 1.2s ease-in-out infinite; }
@keyframes pd-busy { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .pd-meter.busy span { animation: none; width: 100%; opacity: .4; } }
.progress-dialog .pd-status { margin: 0; min-height: 2.6em; font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.progress-dialog .dialog-actions { justify-content: center; margin-top: 16px; }
.progress-dialog .dialog-actions .btn { min-width: 120px; }

.auth-foot a, .fine a { color: var(--accent-text); }
