@font-face { font-family: 'Manrope'; src: url('/fonts/manrope-var.ttf') format('truetype'); font-weight: 200 800; font-display: swap; }
:root {
  --bg: #0d3b30;          /* one hue, two tones: the page is the colour */
  --bg-2: #145244;
  --card: #ffffff;
  --ink: #0f1f1b;
  --muted: #62736e;
  --line: #e6ecea;
  --soft: #f3f6f5;
  --in: #0f8a4f;
  --in-soft: #e5f5ec;
  --out: #d23a3a;
  --out-soft: #fdecec;
  --primary: #0d3b30;
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
/* 16px minimum on every field, or iOS zooms the whole page on focus */
input { font: inherit; font-size: 16px; color: var(--ink); }

.boot { position: fixed; inset: 0; display: grid; place-items: center; color: #fff; font-size: 40px; opacity: .8; }

/* ─── cards / buttons ─── */
.card { background: var(--card); border-radius: var(--radius); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 18px; border-radius: 16px; font-weight: 700; font-size: 16px;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-in { background: var(--in); color: #fff; }
.btn-out { background: var(--out); color: #fff; }
.btn-light { background: var(--soft); color: var(--ink); }
.btn-danger { background: var(--out); color: #fff; }
.btn-ghost-danger { background: var(--out-soft); color: var(--out); }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; color: var(--muted); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--soft); padding: 4px; border-radius: 14px; }
.seg-btn { min-height: 44px; border-radius: 11px; font-weight: 700; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.kind .seg-btn.active[data-kind="in"] { background: var(--in); color: #fff; }
.kind .seg-btn.active[data-kind="out"] { background: var(--out); color: #fff; }

.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field small { font-weight: 500; }
.field input {
  width: 100%; min-height: 52px; padding: 0 14px; border: 1.5px solid var(--line);
  border-radius: 14px; background: #fff; outline: none;
}
.field input:focus { border-color: var(--primary); }
.pw { position: relative; }
.pw input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 2px 0; }
.error { font-size: 14px; color: var(--out); background: var(--out-soft); padding: 10px 12px; border-radius: 12px; margin: 14px 0 0; font-weight: 600; }

/* ─── auth ─── */
.auth { min-height: 100dvh; padding: calc(40px + var(--safe-t)) 16px calc(24px + var(--safe-b)); max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
.auth-brand { color: #fff; text-align: center; margin-bottom: 24px; }
.logo { width: 64px; height: 64px; border-radius: 20px; background: var(--bg-2); display: grid; place-items: center; font-size: 28px; margin: 0 auto 14px; }
.auth-brand h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.auth-brand p { margin: 6px 0 0; opacity: .75; }
.auth-card { padding: 18px; }
.auth-card form .btn { margin-top: 18px; }
.auth-foot { color: #fff; opacity: .7; text-align: center; font-size: 13px; margin-top: 18px; }

/* ─── app ─── */
.app { max-width: 560px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 16px calc(100px + var(--safe-b)); }
.top { display: flex; align-items: center; justify-content: space-between; color: #fff; min-height: 52px; }
.brand { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.user-chip { display: flex; align-items: center; gap: 8px; background: var(--bg-2); color: #fff; min-height: 44px; padding: 0 14px; border-radius: 999px; font-weight: 700; font-size: 14px; max-width: 55%; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.balance { padding: 20px; margin-top: 10px; }
.balance-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.balance-amt { font-size: clamp(34px, 11vw, 46px); font-weight: 800; letter-spacing: -.03em; margin: 4px 0 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.balance-amt.pos { color: var(--in); }
.balance-amt.neg { color: var(--out); }
.balance-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.balance-split > div { background: var(--soft); border-radius: 14px; padding: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.balance-split b { display: block; color: var(--ink); font-size: 17px; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.in { background: var(--in); } .dot.out { background: var(--out); }

.tools { margin-top: 16px; }
.pills { display: flex; gap: 8px; }
.pill { min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--bg-2); color: #d6e6e1; font-weight: 700; font-size: 14px; }
.pill.active { background: #fff; color: var(--ink); }
.search { display: flex; align-items: center; gap: 10px; margin-top: 10px; background: var(--bg-2); border-radius: 14px; padding: 0 14px; color: #a9c4bc; }
.search input { flex: 1; min-width: 0; min-height: 48px; border: 0; outline: 0; background: transparent; color: #fff; }
.search input::placeholder { color: #a9c4bc; }

.list { margin-top: 16px; }
.day { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; color: #d6e6e1; font-size: 13px; font-weight: 700; padding: 0 4px 8px; }
.day-head .net { font-variant-numeric: tabular-nums; }
.rows { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; min-height: 64px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row:active { background: var(--soft); }
.row-ico { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.row-ico.in { background: var(--in-soft); color: var(--in); }
.row-ico.out { background: var(--out-soft); color: var(--out); }
.row-main { flex: 1; min-width: 0; }
.row-note, .row-sub { display: block; }
.row-note { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-note.empty { color: var(--muted); font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.row-amt { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.row-amt.in { color: var(--in); } .row-amt.out { color: var(--out); }

.empty-state { background: var(--card); border-radius: var(--radius); padding: 32px 20px; text-align: center; color: var(--muted); }
.empty-state i { font-size: 32px; color: var(--primary); opacity: .6; }
.empty-state h3 { color: var(--ink); margin: 12px 0 4px; }
.empty-state p { margin: 0; }

.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, rgba(13,59,48,0));
  max-width: 560px; margin: 0 auto;
}
.actions .btn { min-height: 56px; font-size: 17px; }

/* ─── bottom sheet ─── */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(4, 20, 16, .55); animation: fade .18s ease; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: #fff; border-radius: 24px 24px 0 0; padding: 12px 18px calc(20px + var(--safe-b));
  animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.sheet > .btn-block { margin-top: 18px; }
.amount-wrap { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 14px; padding-left: 14px; }
.amount-wrap:focus-within { border-color: var(--primary); }
.amount-wrap em { font-style: normal; font-size: 28px; font-weight: 800; color: var(--muted); }
.amount-field .amount-wrap input { border: 0; font-size: 32px; font-weight: 800; min-height: 64px; padding-left: 8px; font-variant-numeric: tabular-nums; }
.del-area { margin-top: 12px; }
.del-confirm { background: var(--out-soft); border-radius: 16px; padding: 14px; margin-top: 12px; }
.del-confirm span { display: block; font-weight: 700; color: var(--out); margin-bottom: 10px; }
.del-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-who { font-size: 16px; margin: 4px 0 6px; display: flex; gap: 8px; align-items: center; }
.menu-note { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + var(--safe-t)); z-index: 80;
  background: #0f1f1b; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px); opacity: .6 } }
@media (prefers-reduced-motion: reduce) { .scrim, .sheet { animation: none; } }
.boot-off { text-align: center; font-size: 16px; padding: 24px; }
.boot-off i { font-size: 32px; }

.pills-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.share-btn { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.row-edit { flex: none; color: #b3c0bc; font-size: 13px; margin-left: -4px; }
.share-actions .btn { min-height: 52px; }
.offscreen { position: fixed; top: -1000px; left: 0; opacity: 0; }
.row-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.row-bal { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.share-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 0 6px; }
.sheet-head + .share-label { margin-top: 4px; }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-4 .seg-btn, .seg-3 .seg-btn { font-size: 14px; padding: 0 4px; }
.field select {
  width: 100%; min-height: 52px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: #fff; font: inherit; font-size: 16px; color: var(--ink); appearance: none; -webkit-appearance: none;
}
.field input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-row .field { min-width: 0; }
.share-sum { background: var(--soft); border-radius: 16px; padding: 14px; margin: 18px 0 16px; }
.ss-title { font-weight: 800; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ss-title span { font-weight: 600; color: var(--muted); font-size: 13px; }
.ss-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 12px; }
.ss-grid small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.ss-grid b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ss-grid b.in { color: var(--in); } .ss-grid b.out { color: var(--out); }
.share-empty { color: var(--muted); font-weight: 600; }
.share-actions { margin-top: 10px; }
