:root {
  --bg: #0f1220;
  --bg-elev: #191d31;
  --bg-card: #1e2338;
  --line: #2a3050;
  --text: #eef1fb;
  --muted: #9aa3c7;
  --accent: #6c8ef5;
  --green: #20c997;
  --red: #ff6b6b;
  --amber: #f5a623;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100%; }

/* ---- generic ---- */
.screen { padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bot)); }
.h1 { font-size: 26px; font-weight: 800; margin: 4px 0 2px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill.pending { background: rgba(245,166,35,.15); color: var(--amber); }
.pill.approved { background: rgba(32,201,151,.15); color: var(--green); }
.pill.denied { background: rgba(255,107,107,.15); color: var(--red); }

button { font-family: inherit; cursor: pointer; border: none; }
.btn { width: 100%; padding: 15px; border-radius: 14px; font-size: 16px; font-weight: 700; background: var(--accent); color: #fff; }
.btn:active { transform: scale(.99); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.sm { width: auto; padding: 10px 16px; font-size: 14px; }
.btn:disabled { opacity: .5; }

input, textarea, select {
  width: 100%; padding: 14px; border-radius: 12px; font-size: 16px;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }

/* ---- avatars ---- */
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }

/* ---- login ---- */
.login-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo { font-size: 44px; }
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 12px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.who.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108,142,245,.35); }
.who .role { font-size: 12px; color: var(--muted); }

.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 22px 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); }
.pin-dot.on { background: var(--accent); border-color: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.key { padding: 18px; border-radius: 16px; background: var(--bg-card); border: 1px solid var(--line); color: var(--text); font-size: 24px; font-weight: 700; }
.key.blank { background: transparent; border: none; }

/* ---- balance hero ---- */
.hero { border-radius: 22px; padding: 22px; color: #fff; margin-bottom: 18px; position: relative; overflow: hidden; }
.hero .label { opacity: .85; font-size: 14px; }
.hero .amount { font-size: 44px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -1px; }

/* ---- list items ---- */
.txn { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.txn:last-child { border-bottom: none; }
.txn .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--bg-elev); flex: none; }
.txn .amt { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.amt.pos { color: var(--green); }
.amt.neg { color: var(--text); }

/* ---- tabs ---- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(15,18,32,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-bot); }
.tabbar-inner { max-width: 520px; margin: 0 auto; width: 100%; display: flex; }
.tab { flex: 1; background: none; color: var(--muted); padding: 10px 4px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tab .ti { font-size: 20px; }
.tab.active { color: var(--accent); }
.badge { position: absolute; top: 4px; right: 24%; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; }
.tab { position: relative; }

/* ---- misc ---- */
.bars { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bar-row .bar-track { height: 10px; background: var(--bg-elev); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar-row .bar-fill { height: 100%; border-radius: 999px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--bg-elev); border: 1px solid var(--line); padding: 12px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* sheet / modal */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet { background: var(--bg-elev); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-bot)); animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%);} to { transform: none; } }
.sheet h3 { margin: 4px 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; background: var(--bg-card); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); }

/* ---- v2: household, accounts, fx, transfers, chat ---- */
.fxbar { display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; }
.fxbar .rate { font-weight: 800; font-variant-numeric: tabular-nums; }
.fxbar .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.tag.live { background: rgba(32,201,151,.15); color: var(--green); }
.tag.manual { background: rgba(245,166,35,.15); color: var(--amber); }

.totals { display: flex; gap: 10px; margin-bottom: 16px; }
.tcard { flex: 1; background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.tcard .k { font-size: 12px; color: var(--muted); }
.tcard .v { font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }

.member { margin-bottom: 14px; }
.member .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.acct { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--bg-elev); margin-top: 8px; border: 1px solid transparent; }
.acct:active { border-color: var(--accent); }
.acct .ai { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; background: var(--bg-card); flex: none; }
.acct .bal { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.ccy { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--bg-card); color: var(--muted); }
.neg-amt { color: var(--red); }

.fab { position: fixed; right: max(16px, calc(50% - 260px + 16px)); bottom: calc(78px + var(--safe-bot)); width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; box-shadow: 0 8px 24px rgba(76,110,245,.5); z-index: 30; display: grid; place-items: center; }

.seg { display: flex; background: var(--bg-elev); border-radius: 12px; padding: 4px; gap: 4px; margin: 10px 0; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }

.conv-note { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0; }
.conv-note b { color: var(--text); }

/* chat thread */
.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; max-height: 38vh; overflow-y: auto; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.35; }
.bubble .who { font-size: 11px; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.bubble.theirs { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.chatbar { display: flex; gap: 8px; margin-top: 8px; }
.chatbar input { flex: 1; }
.chatbar button { width: auto; padding: 0 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }

.req-head { display: flex; align-items: center; gap: 10px; }
.req-amt { font-size: 20px; font-weight: 800; }
select { appearance: none; -webkit-appearance: none; background-image: none; }

/* raised +/- quick-action buttons in the bottom bar */
.tab.act { color: var(--text); font-weight: 600; }
.tab.act .ti { width: 42px; height: 42px; margin-top: -16px; margin-bottom: 1px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 26px; line-height: 1; box-shadow: 0 5px 16px rgba(0,0,0,.4); }
.tab.plus .ti { background: var(--green); }
.tab.minus .ti { background: var(--red); }
/* expense happens most often — make it the biggest, most reachable button */
.tab.minus .ti { width: 58px; height: 58px; margin-top: -24px; font-size: 34px; box-shadow: 0 6px 20px rgba(255,107,107,.45); }
.tab.minus { font-weight: 700; }
.tab.act:active .ti { transform: scale(.92); }

/* ---- MDI icons (inline SVG) ---- */
.mdi { fill: currentColor; display: block; flex: none; }
.mdi.lead { display: inline-block; vertical-align: -0.18em; margin-right: 6px; }
/* bottom-bar icons */
.tab .ti { display: grid; place-items: center; }
.tab .ti .mdi { width: 24px; height: 24px; }
.tab.act .ti .mdi { width: 26px; height: 26px; }
.tab.minus .ti .mdi { width: 32px; height: 32px; }
/* accent-tinted icon chips */
.acct .ai { color: var(--accent); }
.txn .ico { color: var(--accent); }
.brand .logo { display: grid; place-items: center; }
.brand .logo .mdi { width: 40px; height: 40px; color: var(--accent); }
h3 .mdi.lead { color: var(--accent); }
.catlbl { display: inline-flex; align-items: center; gap: 8px; }
.catlbl .mdi { color: var(--accent); }
.chip { display: inline-flex; align-items: center; }
.chip .mdi.lead { margin-right: 5px; }
.fxccy { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.chatbar button { display: grid; place-items: center; }
.chatbar button .mdi { color: #fff; }

/* ---- launch splash (shown until app.js first render) ---- */
.boot { min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 16px; }
.boot-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: bootspin .8s linear infinite; }
.boot-name { color: var(--muted); font-weight: 700; letter-spacing: .5px; font-size: 15px; }
@keyframes bootspin { to { transform: rotate(360deg); } }
