:root {
  --bg: #f4f6f4; --surface: #ffffff; --surface-2: #eef1ee; --surface-3: #e2e7e3; --line: #d7ddd8;
  --text: #15201a; --muted: #5e6c63; --accent: #2e8b47; --accent-deep: #1b5e20; --on-accent: #fff;
  --pos: #1f9d55; --neg: #d2453a; --amber: #b0700f;
  --radius: 22px; --shadow: 0 8px 30px rgba(0, 0, 0, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411; --surface: #18201b; --surface-2: #1f2822; --surface-3: #29342d; --line: #2f3a33;
    --text: #eef4ef; --muted: #9db0a4; --accent: #5cc77a; --accent-deep: #2e8b47; --on-accent: #fff;
    --pos: #4cd384; --neg: #ff7a6b; --amber: #e8a33a; --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
#app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 110px); }

/* Splash and sign-in */
.splash { min-height: 80dvh; display: grid; place-items: center; }
.logo-big { width: 84px; height: 84px; border-radius: 24px; background: var(--accent-deep) url(icon-512.png) center/cover; box-shadow: 0 12px 30px rgba(27, 94, 32, .35); }
.welcome { min-height: 86dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.welcome h1 { font-size: 36px; line-height: 1.1; margin: 10px 0 0; letter-spacing: -.5px; }
.welcome p { color: var(--muted); margin: 0 0 8px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; }
.top h1 { font-size: 26px; margin: 0; letter-spacing: -.3px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.hero { background: linear-gradient(135deg, var(--accent-deep), #1f7a6e); color: #fff; border-radius: 28px; padding: 22px; margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .08); right: -60px; top: -70px; }
.hero .label { opacity: .85; font-size: 14px; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin: 2px 0 4px; }
.hero .sub { opacity: .85; font-size: 13px; }
.section { font-size: 17px; font-weight: 700; margin: 22px 2px 10px; display: flex; align-items: center; justify-content: space-between; }

/* Rows */
.row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; }
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tap { cursor: pointer; border-radius: 14px; transition: transform .15s; }
.tap:active { transform: scale(.98); }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.amt { font-weight: 800; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); }
.chip-amt { font-weight: 800; font-size: 14px; padding: 4px 10px; border-radius: 999px; }
.chip-amt.pos { background: color-mix(in srgb, var(--pos) 16%, transparent); }
.chip-amt.neg { background: color-mix(in srgb, var(--neg) 16%, transparent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 16px; font-weight: 700; transition: transform .12s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent-deep); color: var(--on-accent); width: 100%; padding: 15px; }
.btn.soft { background: var(--surface-2); }
.btn.hero-pill { background: rgba(255, 255, 255, .18); color: #fff; padding: 9px 16px; border-radius: 999px; margin-top: 12px; }
.btn.google { background: var(--surface); color: var(--text); border: 1px solid var(--line); width: 100%; padding: 15px; }
.btn.small { padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.btn.danger { color: var(--neg); }
.btn[disabled] { opacity: .5; }
.fab { position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(env(safe-area-inset-bottom) + 86px); background: var(--accent-deep); color: #fff; border-radius: 20px; padding: 16px 20px; font-weight: 800; box-shadow: 0 10px 30px rgba(27, 94, 32, .4); z-index: 5; }

/* Tab bar */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 10px); width: min(528px, calc(100% - 28px)); display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 6px; box-shadow: var(--shadow); z-index: 6; }
.tabs button { flex: 1; padding: 8px 4px; border-radius: 18px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button.on { color: var(--text); }
.tabs button.on .ic { background: var(--accent-deep); color: #fff; }
.tabs .ic { width: 44px; height: 28px; border-radius: 14px; display: grid; place-items: center; font-size: 17px; transition: background .2s; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; animation: fade .2s; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%); max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px); z-index: 21; animation: up .32s cubic-bezier(.2, 0, 0, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.sheet .hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
@keyframes up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } }

/* Forms */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 2px 6px; }
input.in, select.in { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); outline: none; }
input.in:focus, select.in:focus { border-color: var(--accent); }
.big-amount { display: flex; justify-content: center; align-items: baseline; gap: 2px; margin: 6px 0; }
.big-amount span { font-size: 34px; color: var(--muted); font-weight: 700; }
.big-amount input { font-size: 44px; font-weight: 800; width: 7ch; border: 0; background: none; outline: none; text-align: left; padding: 0; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-2); border: 2px solid transparent; font-weight: 600; font-size: 14px; }
.pick .avatar { width: 30px; height: 30px; font-size: 12px; }
.pick.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent-deep); color: #fff; }
.split-preview { margin-top: 12px; font-size: 14px; color: var(--muted); text-align: center; }
.actions { display: flex; gap: 10px; margin-top: 18px; }

/* Banners and toast */
.banner { display: flex; gap: 12px; align-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-radius: 18px; padding: 14px; margin-bottom: 14px; font-size: 14px; }
.banner b { display: block; font-size: 15px; }
.banner .ic { font-size: 22px; }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 40; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; font-size: 14px; }
.link-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 14px; padding: 6px 6px 6px 14px; font-size: 13px; color: var(--muted); }
.link-box span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { border-radius: 18px; padding: 14px 10px; text-align: center; font-weight: 700; font-size: 14px; background: var(--surface-2); }
.tile .ic { font-size: 22px; display: block; margin-bottom: 6px; }

/* ---------------- Laptop and desktop ---------------- */
.side, .desk-only { display: none; }
.main { min-width: 0; }
@media (min-width: 900px) {
  #app { max-width: 1180px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding: 28px 32px 48px; }
  .tabs, .fab { display: none; }
  .side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 28px; height: calc(100dvh - 56px); background: var(--surface); border-radius: 26px; padding: 20px 16px; box-shadow: var(--shadow); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; padding: 2px 6px 8px; }
  .logo-sm { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-deep) url(icon-192.png) center/cover; }
  .side nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
  .side nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; font-weight: 600; color: var(--muted); text-align: left; transition: background .15s; }
  .side nav button:hover { background: var(--surface-2); }
  .side nav button.on { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--text); }
  .side nav .ic { display: grid; place-items: center; }
  .side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
  .side-foot .grow { min-width: 0; }
  .side-foot .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-foot .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top { margin-top: 6px; }
  .top h1 { font-size: 32px; }
  .hero { padding: 30px 32px; }
  .hero .big { font-size: 52px; }
  .desk-only { display: block; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .row.tap:hover { background: var(--surface-2); }
  .btn:hover { filter: brightness(1.06); }
  /* Sheets become centred dialogs. */
  .sheet { top: 50%; bottom: auto; transform: translate(-50%, -50%); width: 520px; max-height: 86dvh; border-radius: 28px; padding: 22px 26px 26px; animation: pop .22s cubic-bezier(.2, 0, 0, 1); }
  .sheet .grab { display: none; }
  .welcome { max-width: 520px; margin: 0 auto; }
  #app:has(.welcome) { display: block; }
  #toast { bottom: 32px; }
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }