/* Expense family app styles. Colours come from themes/<theme>.css (same variable names). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--app); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.big { width: 24px; height: 24px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

#app {
  max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 6px) 18px calc(env(safe-area-inset-bottom) + 110px);
}

/* ---------- top bar ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 48px; margin-bottom: 6px; }
.sync { font-size: 12.5px; line-height: 1.15; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; justify-self: start; min-height: 44px; max-width: 92px; text-align: left; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.sync.ok i { background: var(--ok); }
.sync.attn { color: var(--primary-ink); font-weight: 700; }
.sync.attn i { background: var(--primary-ink); }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav h1 { font-size: 17px; font-weight: 700; min-width: 96px; text-align: center; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; color: var(--ink-2); border-radius: 50%; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--card); display: grid; place-items: center; color: var(--primary-ink); box-shadow: var(--shadow); }
.round-btn.soft { background: var(--app); box-shadow: none; color: var(--ink-2); justify-self: start; }
.round-btn svg { width: 18px; height: 18px; }

/* ---------- home ---------- */
.hero { background: var(--primary); color: #fff; border-radius: 22px; padding: 16px 18px; margin: 4px 0 18px; box-shadow: var(--shadow-lift); }
.hero .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.hero .lbl { font-size: 13px; opacity: .8; }
.hero .val { font-size: 30px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.hero .left { text-align: right; }
.hero .left .val { font-size: 20px; color: var(--accent); }
.hero .track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.2); margin-top: 14px; overflow: hidden; }
.hero .track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.hero .track i.over { background: var(--over-soft); }
.hero small { display: block; margin-top: 7px; font-size: 12.5px; opacity: .85; }

.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 10px; }
.sec-head h2 { font-size: 16px; }
.sec-head span { font-size: 13px; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { border-radius: 16px; padding: 12px 8px 11px; text-align: center; transition: transform .12s ease; }
.tile:active { transform: scale(.96); }
.tile .n { font-size: 13px; font-weight: 500; display: block; }
.tile .ic { width: 40px; height: 40px; border-radius: 50%; margin: 8px auto 7px; display: grid; place-items: center; color: #fff; }
.tile .ic svg { width: 19px; height: 19px; }
.tile .a { font-weight: 700; font-size: 15px; display: block; }
.tile .b { display: block; height: 4px; border-radius: 99px; background: var(--track); margin: 7px 6px 0; overflow: hidden; }
.tile .b i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.tile .b i.over { background: var(--over); }
.tile .b.none { visibility: hidden; }
.tile.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0% { transform: scale(1); } 35% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* ---------- insights ---------- */
.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .card { margin-bottom: 10px; }
.gauge { position: relative; text-align: center; padding-bottom: 10px; }
.gauge svg { display: block; margin: 2px auto 0; }
.gauge .t { position: absolute; left: 0; right: 0; top: 58px; }
.gauge .t b { display: block; font-size: 15px; color: var(--primary-ink); }
.gauge .t b.over { color: var(--over); }
.gauge .t small { color: var(--ink-2); font-size: 12px; }
.spent small { color: var(--ink-2); font-size: 12px; }
.spent .k { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.spent .v { font-size: 25px; font-weight: 700; color: var(--primary-ink); }
.mini-ics { display: flex; gap: 6px; margin-top: 12px; }
.mini-ics span { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.mini-ics svg { width: 15px; height: 15px; }
.daily .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.daily .top small { color: var(--ink-2); font-size: 12.5px; display: block; }
.daily .top b { font-size: 15px; }
.pills { display: flex; gap: 6px; }
.pill2 { background: var(--app); border-radius: 10px; padding: 4px 9px; font-size: 11.5px; color: var(--ink-2); text-align: center; }
.pill2 b { display: block; color: var(--ink); font-size: 13px; }
.dbars { display: flex; gap: 2px; align-items: flex-end; height: 90px; }
.dbars i { flex: 1; border-radius: 3px; background: var(--chart); min-height: 3px; }
.dbars i.zero, .dbars i.future { background: var(--mist); }
.dbars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; }
.card-head span { font-size: 12.5px; color: var(--ink-2); }
.donut-row { display: flex; gap: 14px; align-items: center; }
.donut-row > svg { flex: none; transform: rotate(-90deg); }
.legend { flex: 1; display: grid; gap: 8px; font-size: 13px; min-width: 0; }
.legend div { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; }
.legend .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.legend .ic svg { width: 12px; height: 12px; }
.legend em { font-style: normal; color: var(--ink-2); }
.empty { text-align: center; color: var(--ink-2); padding: 36px 16px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- history ---------- */
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin: 16px 4px 6px; }
.day-head:first-child { margin-top: 4px; }
.day-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 2px 14px; }
.tx { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; width: 100%; text-align: left; }
.tx + .tx { border-top: 1px solid var(--hair); }
.tx .ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.tx .ic svg { width: 17px; height: 17px; }
.tx b { display: block; font-weight: 600; }
.tx small { color: var(--ink-2); font-size: 12.5px; }
.tx .amt { font-weight: 700; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 36px); max-width: 444px; height: 64px; z-index: 10;
  background: var(--bar-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 32px; box-shadow: var(--shadow-bar);
  display: flex; justify-content: space-around; align-items: center; padding: 0 6px;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--tab-off); padding: 7px 16px; border-radius: 22px; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--primary-ink); background: var(--accent-soft); }

/* ---------- sheets ---------- */
.backdrop { position: fixed; inset: 0; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 20; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 480px; z-index: 30;
  background: var(--card); border-radius: 26px 26px 0 0; display: flex; flex-direction: column;
  transform: translate(-50%, 105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom); visibility: hidden;
}
.sheet.open { transform: translate(-50%, 0); visibility: visible; }
.sheet.small { max-height: calc(100% - env(safe-area-inset-top) - 24px); }
.sheet.small .sheet-body { overflow-y: auto; }
.sheet.entry { top: calc(env(safe-area-inset-top) + 44px); }
.grab { width: 38px; height: 5px; border-radius: 9px; background: var(--hair); margin: 8px auto 0; flex: none; }
.sheet-head { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; padding: 10px 18px 0; }
.sheet-head h2 { font-size: 17px; text-align: center; }
.entry-title { display: flex; justify-content: center; gap: 8px; align-items: center; }
.entry-title .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.entry-title .ic svg { width: 15px; height: 15px; }

.amount { text-align: center; margin: auto 0 14px; padding-top: 8px; font-size: 56px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.amount .cur { font-size: 30px; color: var(--ink-2); vertical-align: 18px; margin-right: 2px; font-weight: 500; }
.amount .dim { color: var(--dim); }
.amount .caret { display: inline-block; width: 2px; height: .8em; background: var(--primary); vertical-align: -.05em; margin-left: 3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.note-pill { display: block; margin: 0 auto 22px; max-width: calc(100% - 36px); background: var(--app); border-radius: 999px; padding: 8px 16px; font-size: 14.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-pill b { color: var(--primary-ink); font-weight: 600; }
.note-input { display: block; margin: 0 auto 22px; width: calc(100% - 36px); border: 1.5px solid var(--primary-ink); background: var(--card); border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 16px; color: var(--ink); text-align: center; }
.split { display: flex; margin: 0 18px auto; white-space: nowrap; border-radius: 12px; overflow: hidden; min-height: 46px; font-size: 12.5px; }
.split div { padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; }
.split .s { background: var(--primary-2); color: #fff; }
.split .s.over { background: var(--over); }
.split .l { background: var(--ok-soft); color: var(--ink); flex: 1; text-align: right; }
.split b { font-size: 14px; }
.split.none { visibility: hidden; }

.keypad { background: var(--app); margin-top: 18px; padding: 10px 12px 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button { height: 54px; border-radius: 13px; background: var(--card); display: grid; place-items: center; font-size: 22px; font-weight: 500; box-shadow: 0 1px 1px rgba(38,51,47,.06); position: relative; }
.keypad button:active { background: var(--mist); }
.keypad .fn { font-size: 12.5px; font-weight: 600; color: var(--primary-ink); background: var(--accent-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.keypad .fn svg { width: 18px; height: 18px; }
.keypad .save { background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; }
.keypad .save:disabled { opacity: .45; cursor: default; }
.date-key input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; }

.sheet.small .sheet-body { padding: 14px 20px 22px; }
.sheet-body h2 { font-size: 18px; margin-bottom: 6px; }
.sheet-body h3 { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 16px 0 8px; }
.sheet-body h3:first-child { margin-top: 4px; }
.sheet-body p { margin: 0 0 8px; line-height: 1.45; }
.themes { display: flex; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 8px; padding: 9px 14px 9px 9px; border-radius: 999px; background: var(--app); font-weight: 600; }
.theme-opt i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(128, 128, 128, .45); }
.theme-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--primary-ink); }
.row-btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 14px; background: var(--app); font-weight: 600; color: var(--primary-ink); margin-top: 8px; }
.primary-btn { display: block; width: 100%; text-align: center; padding: 14px; min-height: 48px; border-radius: 14px; background: var(--primary); color: #fff; font-weight: 700; margin-top: 12px; }
.primary-btn:disabled, .row-btn:disabled { opacity: .55; cursor: default; }
.sheet-link { color: var(--primary-ink); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.gs-status { font-size: 13.5px; }
.trust { list-style: none; padding: 0; margin: 8px 0 10px; }
.trust li { display: flex; gap: 12px; padding: 10px 0; line-height: 1.45; border-top: 1px solid var(--hair); }
.trust li:first-child { border-top: 0; }
.trust .ic { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--ok-soft); color: var(--primary-ink); display: grid; place-items: center; }
.trust .ic svg { width: 17px; height: 17px; }
.danger-btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 14px; background: var(--over); color: #fff; font-weight: 700; margin-top: 14px; }

.blocked { position: fixed; inset: 0; z-index: 60; background: var(--app); display: grid; place-content: center; text-align: center; padding: 24px; color: var(--ink-2); line-height: 1.5; }
.blocked b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.blocked .primary-btn, .blocked .row-btn { max-width: 320px; margin-left: auto; margin-right: auto; }
.blocked small { display: block; max-width: 320px; margin: 14px auto 0; font-size: 12.5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--toast-bg); color: var(--toast-ink); border-radius: 14px; padding: 11px 12px 11px 16px; display: flex; gap: 14px; align-items: center;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 55; max-width: calc(100% - 36px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.top { bottom: auto; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -20px); }
.toast.top.show { transform: translate(-50%, 0); }
.toast button { color: var(--toast-action); font-weight: 700; padding: 4px 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- top bar actions, banners, sheet card ---------- */
.top-actions { display: flex; gap: 8px; justify-self: end; }
.round-btn { width: 40px; height: 40px; }
.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--accent-soft); border-radius: 14px; padding: 8px 8px 8px 14px; margin: 2px 0 12px; font-size: 13.5px; }
.demo-banner button { background: var(--primary); color: #fff; font-weight: 700; border-radius: 10px; padding: 9px 12px; min-height: 40px; white-space: nowrap; }
.hero { cursor: pointer; }
.hero .set-budget { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.sheet-card { display: grid; grid-template-columns: 44px 1fr 22px; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.sheet-card .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--ok-soft); color: var(--primary-ink); display: grid; place-items: center; }
.sheet-card b { display: block; font-size: 15px; }
.sheet-card small { color: var(--ink-2); font-size: 12.5px; }
.sheet-card > svg { color: var(--ink-2); }

/* ---------- settings rows ---------- */
.set-row { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 14px; background: var(--app); margin-top: 8px; text-align: left; font-weight: 600; }
.set-row span { flex: 1; }
.set-row em { font-style: normal; font-weight: 500; color: var(--ink-2); font-size: 14px; }
.set-row > svg { color: var(--ink-2); width: 18px; height: 18px; }
.set-row select, select.big { font: inherit; font-weight: 500; color: var(--ink); background: var(--card); border: 1px solid var(--hair); border-radius: 10px; padding: 8px 10px; max-width: 60%; }
select.big { width: 100%; max-width: none; padding: 14px; font-size: 17px; margin: 8px 0; }
.gs-status { font-size: 14px; margin: 2px 0 4px; }
.gs-status b { color: var(--ink); }
.foot { margin-top: 18px; display: grid; gap: 6px; }
.link-btn { color: var(--primary-ink); font-weight: 600; text-align: left; padding: 6px 0; min-height: 36px; }

/* ---------- budgets ---------- */
.bud-row { display: grid; grid-template-columns: 32px 1fr 128px; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid var(--hair); }
.bud-row:first-of-type { border-top: 0; }
.bud-row .ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.bud-row .ic svg { width: 16px; height: 16px; }
.money-in { display: flex; align-items: center; gap: 4px; background: var(--app); border-radius: 10px; padding: 0 10px; border: 1px solid transparent; }
.money-in:focus-within { border-color: var(--primary-ink); }
.money-in i { font-style: normal; color: var(--ink-2); }
.money-in input { width: 100%; border: 0; background: none; font: inherit; font-size: 17px; color: var(--ink); padding: 11px 0; text-align: right; outline: none; }
.money-in input::placeholder { color: var(--ink-2); font-size: 14px; }
.bud-total { display: flex; justify-content: space-between; margin-top: 10px; font-weight: 700; }

/* ---------- first-run setup ---------- */
.onboard { position: fixed; inset: 0; z-index: 50; background: var(--app); overflow-y: auto; }
.ob { max-width: 480px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 28px) 24px calc(env(safe-area-inset-bottom) + 24px); }
.ob-dots { display: flex; gap: 6px; margin-bottom: 22px; }
.ob-dots i { width: 22px; height: 5px; border-radius: 9px; background: var(--hair); }
.ob-dots i.on { background: var(--primary-ink); }
.ob-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow-lift); margin: 8vh auto 22px; display: block; }
.ob h1 { font-size: 27px; line-height: 1.2; margin-bottom: 10px; }
.ob .center { text-align: center; }
.ob p { color: var(--ink-2); line-height: 1.5; margin: 0 0 12px; font-size: 16px; }
.ob-actions { margin-top: auto; padding-top: 20px; }
.ob-steps { list-style: none; padding: 0; margin: 10px 0 14px; counter-reset: s; }
.ob-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--hair); font-size: 16px; line-height: 1.4; }
.ob-steps li:first-child { border-top: 0; }
.ob-steps li::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--primary-ink); font-weight: 700; display: grid; place-items: center; }
.ob-steps svg { width: 19px; height: 19px; vertical-align: -4px; color: var(--primary-ink); }
.ob-note { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--ink-2); box-shadow: var(--shadow); }
.ob-error { background: var(--card); border-left: 4px solid var(--over); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14.5px; line-height: 1.45; }
.ob .primary-btn[aria-busy="true"]::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: 10px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
