:root {
  --ink: #172c37; --muted: #71808a; --bg: #f6f5f1; --card: #ffffff;
  --line: #e6e9e8; --teal: #147c73; --teal-light: #e7f4f0;
  --gold: #e8b861; --red: #b64644; --radius: 21px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #64b9a2; outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.app-shell { margin: 0 auto; max-width: 750px; min-height: 100svh; padding: 0 22px 110px; }
.app-header { padding: max(22px, env(safe-area-inset-top)) 0 22px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-symbol { display: grid; place-items: center; width: 42px; height: 42px; background: #183543; color: #e9bf6d; border-radius: 14px; font-size: 26px; }
.brand-name { font-size: 17px; letter-spacing: -.45px; font-weight: 800; }
.brand-subtitle { color: var(--muted); font-size: 11px; margin-top: 3px; }
.connection-badge { font-size: 11px; border: 1px solid #cce5df; background: #edf7f3; color: #227c6b; border-radius: 100px; padding: 8px 10px; white-space: nowrap; }
.connection-badge.offline { background: #fff7e9; border-color: #f1dfc5; color: #946b25; }
.page-content { display: grid; gap: 22px; }
.hero { position: relative; overflow: hidden; border-radius: 26px; background: linear-gradient(122deg, #112c39, #1d4c4c); padding: 26px 25px; color: white; box-shadow: 0 12px 32px rgba(18,53,57,.13); }
.hero::before { content: ""; position: absolute; right: -50px; top: -100px; width: 240px; height: 240px; border: 1px solid rgba(247,207,137,.17); border-radius: 50%; box-shadow: 0 0 0 22px rgba(255,255,255,.015), 0 0 0 49px rgba(255,255,255,.025); }
.hero::after { content: "✦"; position: absolute; right: 35px; top: 34px; color: rgba(245,201,126,.7); font-size: 34px; }
.eyebrow { font-size: 10px; font-weight: 800; letter-spacing: 1.8px; margin: 0 0 10px; }
.hero .eyebrow { color: #add3cc; }
.hero-number { font-size: clamp(30px, 7vw, 45px); font-weight: 800; letter-spacing: -1.6px; line-height: 1.13; font-variant-numeric: tabular-nums; margin: 5px 0 21px; }
.hero-number span { font-size: 17px; color: #c7d6d1; letter-spacing: 0; font-weight: 500; }
.hero-bottom { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid #ffffff2c; padding-top: 20px; }
.hero-stat { position: relative; z-index: 1; }
.hero-label { color: #bfd0cc; font-size: 11px; margin-bottom: 7px; }
.hero-stat strong { font-size: 17px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hero-dots { color: #f2be6b; font-size: 13px; letter-spacing: 1px; }
.metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.metric-card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-card { padding: 18px; }
.metric-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 11px; }
.metric-value { font-size: clamp(17px, 3vw, 22px); font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: 11px; margin-top: 9px; color: var(--muted); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.65px; margin-bottom: 6px; }
h2 { font-size: 18px; letter-spacing: -.4px; margin-bottom: 0; }
h3 { font-size: 15px; margin-bottom: 8px; }
.section-sub { margin: 0; color: var(--muted); font-size: 13px; }
.section-title { font-size: 17px; letter-spacing: -.3px; font-weight: 800; margin: 0; }
.panel { padding: 20px; }
.progress-track { height: 10px; background: #edf0ed; border-radius: 20px; overflow: hidden; margin: 16px 0 7px; }
.progress-fill { background: linear-gradient(90deg, #32a88b, #147c73); height: 100%; border-radius: inherit; max-width: 100%; }
.progress-copy { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.btn { border: 0; border-radius: 14px; padding: 14px 17px; font-weight: 750; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { color: white; background: #147c73; }
.btn-primary:hover { background: #10695f; }
.btn-secondary { color: #153e46; background: #e6efec; }
.btn-ghost { background: #f4f5f1; color: #506570; }
.btn-danger { background: #fbeeee; color: var(--red); }
.btn-block { width: 100%; }
.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; }
.text-button { background: transparent; padding: 6px 0; border: none; color: var(--teal); font-weight: 750; font-size: 12px; }
.small-button { background: #edf4f1; color: #1e736a; border: 0; border-radius: 10px; padding: 9px 11px; font-size: 12px; font-weight: 750; }
.txn-list { display: grid; gap: 0; }
.transaction { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #eef1ef; }
.transaction:last-child { border-bottom: none; padding-bottom: 0; }
.transaction:first-child { padding-top: 0; }
.category-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 14px; background: #eff5f2; font-size: 19px; }
.txn-main { min-width: 0; flex: 1; }
.txn-title { font-size: 13px; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.txn-sub { color: var(--muted); font-size: 11px; margin-top: 5px; }
.txn-value { text-align: right; font-weight: 800; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.txn-secondary { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 5px; }
.empty { text-align: center; padding: 32px 15px; }
.empty-symbol { display: block; font-size: 35px; margin-bottom: 10px; }
.empty h3 { margin-bottom: 5px; }
.empty p { font-size: 13px; color: var(--muted); line-height: 1.55; margin-bottom: 17px; }
.category-row { margin-bottom: 18px; }
.category-row:last-child { margin-bottom: 0; }
.category-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.category-meta strong { font-variant-numeric: tabular-nums; }
.category-row .progress-track { margin: 9px 0 0; height: 7px; }
.notice { border: 1px solid #f1dfbe; color: #856328; background: #fff8e9; padding: 14px 15px; border-radius: 15px; font-size: 12px; line-height: 1.5; }
.notice strong { display: block; margin-bottom: 4px; color: #634b21; }
.notice.cool { color: #39665e; background: #edf6f2; border-color: #dcece5; }
.notice.cool strong { color: #205c52; }
.page-intro { padding-top: 4px; }
.page-intro p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
.expense-item { display: flex; gap: 10px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.expense-item:last-child { border-bottom: 0; }
.item-actions { display: flex; gap: 5px; margin-left: 4px; }
.action-mini { border: 0; background: #f2f5f3; color: #42675f; border-radius: 8px; padding: 7px 9px; font-size: 11px; }
.action-mini.delete { color: #ac5150; background: #fff2f1; }
.person-row { display: grid; grid-template-columns: 42px 1fr; gap: 13px; align-items: start; }
.avatar { display: grid; place-items: center; width: 42px; height: 42px; color: #197b72; background: #e8f2ed; border-radius: 15px; font-weight: 800; }
.person-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.person-head h3 { margin: 0; }
.person-head small { font-size: 11px; color: var(--muted); }
.person-form { margin-top: 15px; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 8px; align-items: end; }
.person-form label { font-size: 10px; margin-bottom: 6px; }
.person-form input { min-width: 0; width: 100%; padding: 11px 8px; border-radius: 10px; font-size: 12px; }
.person-form .btn { padding: 12px; }
.settlement { display: grid; gap: 11px; }
.settlement-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.settlement-line strong { font-variant-numeric: tabular-nums; }
.settlement-line.positive strong { color: #147c73; }
.settlement-line.negative strong { color: #b6544b; }
.helper { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 12px 0 0; }
label { display: block; font-size: 12px; font-weight: 700; margin: 0 0 7px; }
input, select, textarea { display: block; border: 1px solid #dce4df; background: white; border-radius: 12px; padding: 13px 12px; width: 100%; color: var(--ink); font-size: 14px; }
textarea { resize: vertical; }
input::placeholder,textarea::placeholder { color: #9ba8ab; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.rate-field { border: 1px solid #e8efec; padding: 13px; border-radius: 12px; background: #fafcf9; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 9px; line-height: 1.4; }
.optional { color: var(--muted); font-weight: 400; }
.settings-form { display: flex; gap: 10px; align-items: end; }
.settings-form > div { flex: 1; }
.settings-form .btn { flex: 0 0 auto; }
.backup-card { display: flex; gap: 12px; align-items: start; }
.backup-icon { padding: 12px; background: #eff6f0; border-radius: 14px; font-size: 23px; }
.backup-info { flex: 1; }
.backup-info p { color: var(--muted); font-size: 12px; line-height: 1.5; margin-bottom: 13px; }
.backup-card .btn { padding: 11px 13px; }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%,750px); display: grid; grid-template-columns: repeat(5,1fr); background: rgba(255,255,255,.98); border-top: 1px solid var(--line); padding: 9px 12px max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 30px rgba(23,46,55,.05); }
.nav-item { border: 0; background: none; color: #8a9699; font-size: 10px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 7px 4px; border-radius: 13px; }
.nav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: #147c73; background: #eef6f1; }
.floating-add { display: none; position: fixed; z-index: 18; bottom: calc(85px + env(safe-area-inset-bottom)); right: max(22px, calc((100vw - 710px)/2)); width: 55px; height: 55px; background: #147c73; color: white; font-size: 30px; font-weight: 300; line-height: 1; border: 4px solid white; box-shadow: 0 4px 18px rgba(17,83,74,.3); border-radius: 18px; }
.floating-add.visible { display: block; }
.expense-dialog { width: min(100% - 24px, 500px); max-height: min(92dvh, 800px); overflow-y: auto; border: 1px solid #e3e8e5; box-shadow: 0 25px 85px #0004; border-radius: 24px; padding: 0; background: white; color: var(--ink); }
.expense-dialog::backdrop { background: #102d37a8; backdrop-filter: blur(3px); }
.expense-form { display: grid; gap: 15px; padding: 25px; }
.expense-form .eyebrow { color: var(--teal); margin-bottom: 4px; }
.dialog-top { display: flex; justify-content: space-between; align-items: start; }
.dialog-top h2 { font-size: 23px; }
.icon-button { background: #f0f3f1; border: none; border-radius: 50%; width: 33px; height: 33px; font-size: 23px; line-height: 1; color: #6e7b7f; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.dialog-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(97px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(90%,440px); background: #173743; color: white; border-radius: 15px; padding: 13px 17px; text-align: center; font-size: 12px; box-shadow: 0 10px 30px #0003; opacity: 0; visibility: hidden; transition: opacity .2s ease, transform .2s ease, visibility .2s ease; z-index: 40; }
.toast.show { opacity: 1; transform: translate(-50%,0); visibility: visible; }
@media (min-width: 700px) { .app-shell { padding: 0 28px 115px; } .hero { padding: 32px; } }
@media (max-width: 390px) { .app-shell { padding-left: 14px; padding-right: 14px; } .brand-name { font-size: 15px; } .brand-subtitle { font-size: 10px; } .connection-badge { font-size: 10px; padding: 7px; } .metric-card { padding: 14px; } .hero { padding: 23px 20px; } .hero-stat strong { font-size: 15px; } .person-form { grid-template-columns: 1fr 1fr; } .person-form .btn { grid-column: 1/-1; } .expense-form { padding: 20px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }

.wallet-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.wallet-cell {background:#f5f9f7;border:1px solid #e5efea;border-radius:14px;padding:13px 9px;min-width:0;}
.wallet-cell span {display:block;color:var(--muted);font-size:11px;margin-bottom:8px;}
.wallet-cell strong {display:block;font-size:clamp(12px,2.5vw,15px);font-variant-numeric:tabular-nums;overflow-wrap:anywhere;}
.wallet-cell small {display:block;color:var(--muted);font-size:10px;margin-top:6px;}
.backup-buttons{display:flex;gap:8px;flex-wrap:wrap;}
.backup-buttons .btn{flex:1;}
.expense-item .item-actions {display:flex;flex-direction:column;align-items:flex-end;flex-shrink:0;}
@media (max-width:390px){.wallet-grid{grid-template-columns:1fr 1fr;}.wallet-cell:last-child{grid-column:1/-1;}.nav-item{font-size:9px;}}

/* v1.3: explanation of the cash wallet / exchange reconciliation. */
.omr-reconciliation{margin-top:14px;padding:13px 14px;border-radius:12px;background:#edf5f2;display:grid;gap:6px;color:#153e3b;font-size:.82rem;line-height:1.55}
.omr-reconciliation strong{font-size:.85rem}
.omr-reconciliation span{overflow-wrap:anywhere}

/* v1.4 — separate bank / physical-cash balances and contribution source. */
.wallet-grid-four{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.wallet-primary{background:#e9f5ef;border-color:#c7e5d8}
.wallet-grid-four .wallet-cell{padding:15px 12px}
.wallet-grid-four .wallet-cell strong{font-size:clamp(14px,3.8vw,20px)}
.wallet-grid-four .wallet-cell span{font-size:11px;line-height:1.3}
.wallet-grid-four .wallet-cell small{line-height:1.45}
.person-form{grid-template-columns:repeat(2,minmax(0,1fr))}
.person-form select{font-size:12px;padding:11px 8px}
.person-form button[type=submit]{grid-column:1/-1}
@media (max-width:390px){.wallet-grid-four .wallet-cell:last-child{grid-column:auto}.wallet-grid-four .wallet-cell{padding:12px 9px}}

.person-form > div:nth-of-type(3){grid-column:1/-1}
