/* Tunda — mobile app styles.
   Follows the look people know from everyday money apps: a solid coloured
   app bar, flat white lists with thin dividers, red for money you will get,
   green for money received, a round "+" button, plain number keypad.
   System font only (nothing to download = fast on cheap phones). */

:root {
  --brand: #0B6B3A;
  --brand-dark: #08512C;
  --brand-tint: #E7F3EC;
  --accent: #F5B82E;

  --red: #D32F2F;        /* you will get / owed / loss */
  --red-tint: #FDECEC;
  --green: #1B873F;      /* received / profit */
  --green-tint: #E6F4EA;
  --amber: #A86B00;
  --amber-tint: #FFF4DB;

  --ink: #1C2421;
  --ink-2: #5E6A65;
  --ink-3: #8A9590;
  --line: #E3E8E5;
  --bg: #F1F4F2;
  --surface: #FFFFFF;

  --mtn: #E0A800;
  --airtel: #D32F2F;
  --credit: #5B4BB7;
  --cash: #0B6B3A;
  --whatsapp: #1DA851;

  --radius: 12px;
  --radius-sm: 8px;
  --tabbar-h: 62px;
  --appbar-h: 56px;
  --gutter: 16px;

  font-size: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
}
body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
body.sheet-open { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.2rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }

/* ---------- Screen ---------- */
.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--gutter) 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
  min-height: 100dvh;
}
body.has-tabbar .screen { min-height: auto; }

.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.bad { color: var(--red); }
.good { color: var(--green); }
.big { font-size: 1.5rem; font-weight: 800; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.icon { display: inline-flex; flex: none; }
.label, h3.label { font-weight: 600; font-size: .95rem; color: var(--ink-2); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- App bar (top) ---------- */
.topbar, .home-head {
  position: sticky; top: 0; z-index: 12;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  min-height: calc(var(--appbar-h) + env(safe-area-inset-top));
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; gap: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.topbar h1 { font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.home-head { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
.home-head .muted { color: rgba(255, 255, 255, .8); font-size: .85rem; }
.home-head h1 { font-size: 1.2rem; }
.topbar .icon-btn, .home-head .icon-btn { color: #fff; }
.topbar .icon-btn:active { background: rgba(255, 255, 255, .15); }
.topbar .link-btn { color: #fff; }
.topbar .sub { display: block; font-size: .8rem; font-weight: 400; opacity: .85; }
.topbar .avatar { width: 36px; height: 36px; background: rgba(255, 255, 255, .2); color: #fff; margin-left: 2px; }
.step-label { color: var(--brand); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

/* "+ Add" in the app bar becomes a round floating button (like most apps) */
.topbar .btn-sm.btn-primary {
  position: fixed; z-index: 11;
  right: max(var(--gutter), calc(50% - 280px + var(--gutter)));
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  min-height: 52px; padding: 0 20px 0 16px; border-radius: 26px;
  background: var(--brand); color: #fff; font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 10px 18px;
  border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-size: 1rem; font-weight: 700; letter-spacing: .01em;
  cursor: pointer; text-decoration: none;
  transition: background-color .12s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-ghost { background: transparent; color: var(--brand); min-height: 44px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-outline { background: var(--surface); color: var(--red); border-color: #F1B9B9; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-sm { width: auto; min-height: 40px; padding: 6px 14px; font-size: .92rem; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--brand-tint); }
.icon-btn.small { width: 34px; height: 34px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
  border: 0; background: none; color: var(--brand); font-weight: 700; cursor: pointer; min-height: 44px; padding: 0 8px;
}
.center-link { margin: 4px auto 0; }

.chip {
  min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: .92rem; cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-switch { display: flex; gap: 8px; justify-content: flex-end; }
.lang-switch.left { justify-content: flex-start; }

/* Choice buttons (payment method, unit, yes/no) */
.choices { display: flex; gap: 8px; }
.choices.wrap { flex-wrap: wrap; }
.choice {
  flex: 1 1 0; min-width: 0; min-height: 46px; padding: 8px 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.choices.wrap .choice { flex: 0 0 auto; padding: 8px 16px; }
.choice.active { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-dark); }
.choices.methods { display: grid; grid-template-columns: 1fr 1fr; }
.choices.methods .choice { min-height: 54px; justify-content: flex-start; padding-left: 12px; }

/* Tabs: underline style */
.choices.tabs {
  gap: 0; margin: 0 calc(-1 * var(--gutter));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.choices.tabs .choice {
  border: 0; border-radius: 0; border-bottom: 3px solid transparent;
  background: transparent; color: var(--ink-2); min-height: 46px; font-weight: 700;
}
.choices.tabs .choice.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.topbar + .choices.tabs, .home-head + .choices.tabs { margin-top: -12px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.input-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1.5px solid #CDD5D1; border-radius: var(--radius-sm);
  padding: 0 12px; color: var(--ink-2);
}
.input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.input {
  flex: 1; min-width: 0; min-height: 50px;
  border: 0; outline: 0; background: transparent;
  font-size: 1.05rem; color: var(--ink);
}
.input::placeholder { color: var(--ink-3); }
select.input { appearance: none; cursor: pointer; }
.input-wrap .prefix, .input-wrap .suffix { font-weight: 600; color: var(--ink-2); font-size: .95rem; }
.input-wrap.invalid, .input-wrap:has(.invalid) { border-color: var(--red); background: var(--red-tint); }
.input-wrap.search { border-color: var(--line); border-radius: 999px; }
.field-error { color: var(--red); font-weight: 600; font-size: .88rem; }
.field-error:empty { display: none; }
.calc-note { font-weight: 600; color: var(--brand-dark); background: var(--brand-tint); padding: 10px 12px; border-radius: var(--radius-sm); font-size: .92rem; }
.calc-note:empty { display: none; }
.calc-note.bad { color: var(--red); background: var(--red-tint); }
.code-input { letter-spacing: .5em; font-size: 1.5rem; font-weight: 700; text-align: center; }

/* ---------- Cards & lists ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.card-plain { background: var(--bg); border: 0; }
.card-accent { background: var(--brand-tint); border-color: #CFE7D9; }
.card-accent .icon { color: var(--brand); }
.card-warn { background: var(--amber-tint); border-color: #F2DDA9; }
.card-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.card-row { display: flex; justify-content: space-between; align-items: center; }
.card.empty { align-items: center; text-align: center; padding: 32px 16px; }
.big-number { font-size: 1.8rem; font-weight: 800; display: flex; flex-direction: column; line-height: 1.15; }
.big-number.warn { color: var(--amber); }

.list-item {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 60px; text-align: left;
  background: var(--surface); border: 0; border-bottom: 1px solid var(--line);
  font: inherit; color: inherit;
}
button.list-item { cursor: pointer; }
button.list-item:active { background: #F5F8F6; }
.list-item:last-child { border-bottom: 0; }
/* a run of list items is one white list with dividers */
.stack-sm:has(> .list-item) {
  gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.card .list-item { padding: 10px 0; min-height: 54px; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; overflow-wrap: anywhere; }
.li-sub { font-size: .83rem; color: var(--ink-2); white-space: pre-line; }
.li-right { text-align: right; flex: none; max-width: 52%; }
.li-amount { font-weight: 700; }
.tone-bad .li-amount, .tone-bad .li-amount .money { color: var(--red); }
.tone-warn .li-amount { color: var(--amber); }
.tone-good .li-amount, .tone-good .li-amount .money { color: var(--green); }
.tone-void { opacity: .5; }
.tone-void .li-amount { text-decoration: line-through; }
.rank, .avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; background: var(--brand-tint); color: var(--brand-dark);
}
.day-head { display: flex; justify-content: space-between; padding: 14px 2px 6px; font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.stack-sm:has(> .day-head) { background: transparent; border: 0; border-radius: 0; overflow: visible; }
.stack-sm:has(> .day-head) > .list-item { border: 1px solid var(--line); border-top: 0; }
.stack-sm:has(> .day-head) > .day-head + .list-item { border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.money small { font-size: .78em; font-weight: 600; color: inherit; opacity: .75; }
.money.neg { color: var(--red); }
.empty-state { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; padding: 36px 8px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .78rem; background: var(--brand-tint); color: var(--brand-dark); }
.pill.warn { background: var(--amber-tint); color: var(--amber); }
.pill.bad { background: var(--red-tint); color: var(--red); }
.pill.good { background: var(--green-tint); color: var(--green); }
.badge { align-self: flex-start; background: var(--amber-tint); color: var(--amber); font-weight: 700; font-size: .85rem; padding: 4px 10px; border-radius: 999px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.kv:last-of-type { border-bottom: 0; }
.kv span:last-child { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-grid .btn { min-height: 52px; font-size: .95rem; }
.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--brand-tint); border-radius: var(--radius); padding: 14px; color: var(--brand-dark); }
.notice p { color: var(--ink); margin-top: 4px; }

/* ---------- Welcome ---------- */
.welcome { padding: 0; gap: 0; background: var(--brand); min-height: 100svh; justify-content: space-between; }
.welcome .lang-switch { padding: calc(12px + env(safe-area-inset-top)) var(--gutter) 0; gap: 6px; align-items: flex-start; justify-content: space-between; }
.welcome .lang-switch > * { flex: none; }
.welcome .lang-switch .chip { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); white-space: nowrap; padding: 6px 12px; }
.welcome .lang-switch .chip.active { background: #fff; color: var(--brand); border-color: #fff; }
.welcome-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px var(--gutter); color: #fff; text-align: center; }
.logo-mark { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 8px 22px rgba(0, 0, 0, .22); margin-bottom: 8px; }
.brand { font-size: 2.3rem; font-weight: 800; letter-spacing: -.01em; }
.tagline { font-size: 1.1rem; font-weight: 600; }
.welcome-hero .muted { color: rgba(255, 255, 255, .85); }
.welcome > .stack { background: var(--surface); border-radius: 20px 20px 0 0; padding: 22px var(--gutter) calc(18px + env(safe-area-inset-bottom)); gap: 10px; }
.welcome > .stack .small { margin: 2px 0; }

/* sign-in screens */
.auth .stack { gap: 14px; }

/* ---------- PIN pad (plain keypad) ---------- */
.pin-pad { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 8px; }
.pin-pad.busy { opacity: .55; pointer-events: none; }
.pin-title { text-align: center; font-size: 1.15rem; }
.pin-dots { display: flex; gap: 18px; padding: 6px 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dot.filled { background: var(--brand); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pin-message { color: var(--red); font-weight: 600; text-align: center; min-height: 1.4em; font-size: .92rem; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 24px; width: 100%; max-width: 300px; }
.pin-key {
  height: clamp(52px, 8.6svh, 64px); border-radius: 50%; aspect-ratio: 1; justify-self: center;
  border: 0; background: transparent;
  font-size: 1.75rem; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pin-key:active { background: #E3E8E5; }
.pin-del { color: var(--ink-2); }

/* ---------- Home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats-2 { grid-template-columns: 1fr 1fr; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); min-width: 0; }
.stat-label { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.stat-value { font-size: .75rem; color: var(--ink-2); overflow-wrap: anywhere; }
.stat-value strong, .stat strong { font-size: 1.2rem; color: var(--ink); }
.stat-hint { font-size: .72rem; color: var(--ink-3); }
.stat.neg strong { color: var(--red); }
.stat.pos strong { color: var(--green); }
.split { display: flex; flex-direction: column; gap: 10px; }
.split-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface); }
.seg { display: block; min-width: 4px; }
.seg-cash { background: var(--cash); }
.seg-mtn { background: var(--mtn); }
.seg-airtel { background: var(--airtel); }
.seg-credit { background: var(--credit); }
.split-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .85rem; min-width: 0; }
.legend-item strong { margin-left: auto; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mc-row:last-of-type { border-bottom: 0; }
.mc-label { display: flex; flex-direction: column; min-width: 0; }
.mc-value { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.mc-value.neg { color: var(--red); }
.tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.tip:last-child { border-bottom: 0; }
.tip .icon { color: var(--brand); margin-top: 1px; }
.tip-below_cost .icon, .tip-restock_best .icon, .tip-expenses_high .icon, .tip-week_down .icon { color: var(--amber); }
.todo { border-left: 4px solid var(--accent); }
.todo-item { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: 0; }
.todo-item > .icon { color: var(--amber); margin-top: 2px; }
.todo-text p:first-child { font-weight: 500; }
.todo-item > .btn { grid-column: 2; justify-self: start; }

/* Chart */
.chart { display: flex; flex-direction: column; gap: 6px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-bar { fill: #4CA373; }
.chart-bar.on { fill: var(--brand-dark); }
.chart-base { stroke: var(--line); stroke-width: 1; }
.chart-label { font-size: 10px; fill: var(--ink-2); }
.chart-hit { cursor: pointer; }
.chart-tip { min-height: 1.4em; font-weight: 600; font-size: .88rem; }

/* ---------- Sell ---------- */
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 420px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.product-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 12px; min-height: 96px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: inherit;
}
.product-tile:active { border-color: var(--brand); background: var(--brand-tint); }
.product-tile.out { opacity: .55; }
.tile-name { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.tile-price { font-weight: 700; color: var(--brand); font-size: .95rem; }
.tile-price small { font-weight: 500; color: var(--ink-2); }
.tile-stock { font-size: .78rem; color: var(--ink-3); margin-top: auto; }
.tile-stock.low { color: var(--amber); font-weight: 600; }
.tile-badge { position: absolute; top: -7px; right: -5px; background: var(--brand); color: #fff; font-weight: 700; border-radius: 999px; padding: 1px 8px; font-size: .8rem; }
.with-basket { padding-bottom: 90px; }
.basket-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 8px var(--gutter); z-index: 9; max-width: 560px; margin: 0 auto; }
.basket-bar[hidden] { display: none; }
.basket-btn { justify-content: space-between; box-shadow: 0 4px 14px rgba(0, 0, 0, .22); }
.basket-total { display: inline-flex; align-items: center; gap: 4px; }
.line-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 1.1rem; padding: 8px 0; border-top: 1px dashed var(--line); }
.line-total.big { font-size: 1.3rem; }
.warn-box { background: var(--red-tint); color: var(--red); border-radius: var(--radius-sm); padding: 10px 12px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.warn-box[hidden] { display: none; }
.warn-box p { display: flex; gap: 8px; align-items: flex-start; }

/* Receipt */
.receipt-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.receipt-total { display: flex; justify-content: space-between; font-size: 1.25rem; font-weight: 800; padding: 6px 0; }
.receipt.is-void { opacity: .75; }
.void-stamp { background: var(--red-tint); color: var(--red); font-weight: 700; padding: 8px 12px; border-radius: var(--radius-sm); }

/* ---------- Debts (ledger) ---------- */
.balance-card { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.balance-card .amount { font-size: 1.5rem; font-weight: 800; color: var(--red); white-space: nowrap; }
.balance-card.settled .amount { color: var(--green); }
.balance-card .label { font-size: .85rem; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 4px; }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border: 0; background: none; color: var(--ink); font-size: .78rem; font-weight: 600; cursor: pointer; text-decoration: none; border-radius: var(--radius-sm); }
.quick-action .icon { width: 40px; height: 40px; border-radius: 50%; align-items: center; justify-content: center; background: var(--brand-tint); color: var(--brand); }
.quick-action.wa .icon { background: #E3F6EA; color: var(--whatsapp); }
.quick-action.danger .icon { background: var(--red-tint); color: var(--red); }
.quick-action:active { background: var(--bg); }
.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ledger-head, .ledger-row { display: grid; grid-template-columns: 1fr 92px 92px; align-items: stretch; }
.ledger-head { background: var(--bg); font-size: .72rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; }
.ledger-head span:not(:first-child) { text-align: right; }
.ledger-row { padding: 0 0 0 12px; border-top: 1px solid var(--line); font-size: .92rem; min-height: 56px; }
button.ledger-row { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.ledger-row .what { min-width: 0; padding: 8px 0; display: flex; flex-direction: column; justify-content: center; }
.ledger-row .what small { display: block; color: var(--ink-3); font-size: .78rem; }
.ledger-row .amt { font-weight: 700; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px 0 6px; }
.ledger-row .gave { color: var(--red); background: rgba(211, 47, 47, .05); }
.ledger-row .got { color: var(--green); background: rgba(27, 135, 63, .05); }
.ledger-bar {
  position: fixed; z-index: 9; left: 0; right: 0; max-width: 560px; margin: 0 auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px var(--gutter); background: var(--surface); border-top: 1px solid var(--line);
}
.ledger-bar .btn { min-height: 48px; }
.with-ledger-bar { padding-bottom: 90px; }

/* Menu */
.menu { padding: 0; gap: 0; overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); font: inherit; font-weight: 500; text-align: left; cursor: pointer; color: var(--ink); }
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: #F5F8F6; }
.menu-item span:not(.icon):not(.pill) { flex: 1; }
.menu-item .icon:first-child { color: var(--brand); }
.menu-item .icon:last-child { color: var(--ink-3); }
.reset-code { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; background: var(--amber-tint); border-radius: var(--radius-sm); text-align: center; }
.reset-code strong { font-size: 2rem; letter-spacing: .12em; }

/* ---------- Bottom navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: .72rem; font-weight: 500; min-width: 0;
}
.tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tab.active { color: var(--brand); font-weight: 700; }
.tab.active .icon { background: var(--brand-tint); border-radius: 999px; padding: 2px 14px; }

/* ---------- Banner, toast, sheet ---------- */
.banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px var(--gutter); padding-top: calc(8px + env(safe-area-inset-top));
  font-weight: 600; font-size: .85rem; text-align: center;
  background: #4A4F4D; color: #fff;
}
.banner[hidden] { display: none; }
.banner.bad { background: var(--red); cursor: pointer; }

.toast {
  position: fixed; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; z-index: 40;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: #323836; color: #fff; font-weight: 500; font-size: .95rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #B3261E; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.sheet-backdrop.show { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 0 var(--gutter) calc(18px + env(safe-area-inset-bottom));
  transform: translateY(30px); transition: transform .18s;
}
.sheet-backdrop.show .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; align-items: center; justify-content: space-between; padding: 18px 0 8px; }
.sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #D3DAD6; }
.sheet-head h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; }
.sheet .list-item { padding: 10px 0; }

/* ---------- Install prompt ---------- */
.install-holder:empty, .install-compact:empty { display: none; }
.install-card { background: var(--brand-tint); border-color: #CFE7D9; }
.install-card .row { align-items: flex-start; }
.install-card h2 { font-size: 1rem; }
.install-icon { border-radius: 12px; flex: none; }
.install-steps { font-weight: 600; background: var(--surface); padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink); }
.install-compact { flex: none; margin-right: auto; display: flex; flex-direction: column; gap: 6px; }
.install-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.install-compact .install-steps { position: absolute; left: var(--gutter); right: var(--gutter); top: 60px; z-index: 5; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }

/* ---------- Small / short phones ---------- */
@media (max-height: 700px) {
  .logo-mark { width: 64px; height: 64px; border-radius: 16px; }
  .brand { font-size: 1.9rem; }
  .welcome-hero { gap: 4px; }
  .btn { min-height: 48px; }
}
@media (max-width: 345px) {
  .welcome .lang-switch .chip { padding: 5px 9px; font-size: .85rem; }
  .welcome .lang-switch { gap: 4px; }
  .ledger-head, .ledger-row { grid-template-columns: 1fr 80px 80px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
