:root {
  --bg: #05060b;
  --bg-2: #0b1433;
  --card: rgba(255, 255, 255, .055);
  --card-2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .08);
  --text: #f4f5fb;
  --muted: #8d92ad;
  --accent: #5b8cff;
  --accent-2: #7c6cff;
  --good: #34d399;
  --bad: #ff6b81;
  --warn: #ffb547;
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(130% 55% at 50% -12%, #2146b8 0%, #0f1d4d 38%, var(--bg) 72%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
svg { display: block; }

#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; }
#view { padding: calc(var(--safe-t) + 8px) 16px calc(var(--safe-b) + 120px); }
body.onboarding #nav, body.onboarding #fab { display: none; }
body.detail-open #fab { display: none; }

/* ---------- barra superior ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .25; }
.icon-btn.sm { width: 30px; height: 30px; font-size: 18px; background: transparent; border-color: transparent; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 6px 0 10px; }
.period-nav { display: flex; align-items: center; justify-content: center; gap: 4px; }
.period-btn { color: var(--muted); font-size: 14px; padding: 4px 10px; border-radius: 99px; }
.period-btn .chev { font-size: 11px; margin-left: 2px; }
.big { font-size: 44px; font-weight: 750; letter-spacing: -1.5px; line-height: 1.1; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.big .cur { font-size: .5em; vertical-align: .5em; margin-right: 5px; letter-spacing: 0; }
.big .dec { font-size: .5em; color: var(--muted); letter-spacing: 0; }
.cmp { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 550; }
.cmp.good { color: var(--good); }
.cmp.bad { color: var(--bad); }
.cmp.muted { color: var(--muted); }
.cmp .dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; display: grid; place-items: center; font-size: 9px; }
.cmp .dot::after { content: attr(data-a); color: #05060b; font-weight: 800; }

/* ---------- gráficas ---------- */
.chart { margin: 4px -4px 8px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: #fff; }
.chart .bar.future { fill: rgba(255, 255, 255, .08); }
.chart .bar.stub { fill: rgba(255, 255, 255, .14); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .avg { stroke: rgba(255, 255, 255, .55); stroke-dasharray: 3 4; stroke-width: 1; }
.chart .avg-l { fill: #fff; font-size: 10px; font-weight: 600; }
.chart svg { animation: rise .45s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.donut-wrap { position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 6px auto 14px; }
.donut-wrap svg { width: 100%; height: 100%; animation: spinIn .6s cubic-bezier(.2, .8, .2, 1); }
.donut-wrap .seg { transition: opacity .2s, stroke-width .2s; cursor: pointer; }
@keyframes spinIn { from { opacity: 0; transform: rotate(-40deg) scale(.9); } to { opacity: 1; transform: none; } }
.donut-center { position: absolute; inset: 22%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-center .big { font-size: 36px; }
.donut-center .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 4px; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding: 0; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 99px; font-size: 13.5px; font-weight: 550;
  background: var(--card-2); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip.on { background: #fff; color: #0b0d18; }
.chip.icon { width: 34px; padding: 0; justify-content: center; }
.chip:active { transform: scale(.96); }
.gift-durations .chip { min-height: 44px; flex: 1; justify-content: center; }
.gift-durations .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.searchbar { margin: -4px 0 12px; }
.searchbar input, .field input, .field select {
  width: 100%; height: 46px; border-radius: 14px; padding: 0 14px; font-size: 16px;
  background: var(--card); border: 1px solid var(--line); outline: none;
}
.searchbar input:focus, .field input:focus, .field select:focus { border-color: var(--accent); }
.field select { color: var(--text); font-family: inherit; color-scheme: dark; }

/* ---------- listas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.group-h { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 16px 6px 6px; }
.tx, .rank, .row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; text-align: left;
}
.tx:active, .rank:active, .row:active { background: var(--card-2); }
.bubble {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px;
  background: color-mix(in srgb, var(--c, #888) 22%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, #888) 70%, transparent);
}
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-main b, .tx-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main b { font-weight: 600; }
.tx-main small { color: var(--muted); font-size: 12.5px; }
.amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.income { color: var(--good); }
.rank.sel { background: var(--card-2); }
.rk-name { flex: 1; min-width: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.count { font-style: normal; font-size: 11px; color: var(--muted); background: var(--card-2); border-radius: 99px; padding: 1px 7px; }
.rk-val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.rk-val small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty .e-ico { font-size: 38px; margin-bottom: 6px; }

/* ---------- presupuesto ---------- */
.budget-hero { display: flex; align-items: center; gap: 18px; padding: 16px; margin-bottom: 12px; }
.ring { width: 112px; height: 112px; flex: none; }
.ring .track { stroke: rgba(255, 255, 255, .1); }
.ring circle { fill: none; stroke-width: 11; transition: stroke-dashoffset .6s ease; }
.ring-wrap { position: relative; }
.ring-wrap .ring-l { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: 22px; }
.budget-hero .bh-t { color: var(--muted); font-size: 13px; }
.budget-hero .bh-v { font-size: 24px; font-weight: 750; margin: 2px 0; }
.budget-hero .bh-s { font-size: 13px; }
.b-row { padding: 12px 10px; border-radius: 16px; width: 100%; text-align: left; display: block; }
.b-row:active { background: var(--card-2); }
.b-top { display: flex; align-items: center; gap: 12px; }
.b-top .tx-main small b { color: var(--text); font-weight: 600; }
.bar-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); margin-top: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--c); transition: width .6s ease; }
.b-left { font-size: 12.5px; color: var(--muted); text-align: right; white-space: nowrap; }
.b-left.over { color: var(--bad); }
.b-left.warn { color: var(--warn); }
.mini-btn { font-size: 13px; font-weight: 600; color: var(--accent); padding: 6px 10px; border-radius: 99px; background: rgba(91, 140, 255, .12); }

/* ---------- análisis ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; min-width: 0; }
.stat .s-l { color: var(--muted); font-size: 12px; }
.stat .s-v { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .s-s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 16px; justify-content: center; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.section-t { font-size: 15px; font-weight: 650; margin: 18px 4px 8px; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--good); }

/* ---------- navegación ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 10px);
  width: min(calc(100% - 24px), 456px); height: 64px; border-radius: 26px; display: flex; padding: 6px; z-index: 20;
  background: rgba(22, 25, 40, .72); border: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); border-radius: 20px; }
.nav button.on { color: var(--text); background: rgba(255, 255, 255, .1); }
.fab {
  position: fixed; z-index: 21; right: max(16px, calc(50% - 224px)); bottom: calc(var(--safe-b) + 90px);
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #0b0d18;
  background: linear-gradient(135deg, #fff, #c9d6ff); box-shadow: 0 10px 30px rgba(91, 140, 255, .45);
}
.fab:active { transform: scale(.93); }

/* ---------- hojas (bottom sheets) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .25s; }
.sheet .panel {
  position: absolute; left: 50%; bottom: 0; width: min(100%, 480px); max-height: 92vh; overflow-y: auto;
  transform: translate(-50%, 100%); transition: transform .32s cubic-bezier(.2, .9, .25, 1);
  background: #12152a; border: 1px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(var(--safe-b) + 18px);
}
.sheet.open { pointer-events: auto; }
.sheet.open .backdrop { opacity: 1; }
.sheet.open .panel { transform: translate(-50%, 0); }
.grabber { width: 38px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .2); margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 14px; font-size: 18px; text-align: center; }
.sheet-sub { text-align: center; color: var(--muted); margin: -8px 0 14px; font-size: 13px; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; height: 36px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card-2); color: var(--text); }
.seg button.on.expense { color: var(--bad); }
.seg button.on.income { color: var(--good); }
.kp-display { text-align: center; font-size: 46px; font-weight: 750; letter-spacing: -1px; padding: 12px 0 16px; font-variant-numeric: tabular-nums; }
.kp-display.empty-v { color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.keypad button { height: 54px; border-radius: 16px; background: var(--card-2); font-size: 23px; font-weight: 550; }
.keypad button:active { background: rgba(255, 255, 255, .2); transform: scale(.97); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { height: 50px; border-radius: 16px; font-weight: 650; font-size: 16px; background: var(--card-2); }
.btn.primary { background: #3478f6; color: #fff; }
.btn.danger { background: rgba(255, 107, 129, .12); color: var(--bad); }
.btn.block { width: 100%; margin-top: 10px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; }
.cat-list { display: flex; flex-direction: column; gap: 2px; max-height: 56vh; overflow-y: auto; margin: 0 -6px 8px; }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; font-weight: 600; text-align: left; }
.cat-item:active, .cat-item.on { background: var(--card-2); }
.add-summary { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 14px; }
.sum-amt { font-size: 40px; font-weight: 750; letter-spacing: -1px; }
.sum-amt.income { color: var(--good); }
.field { display: block; margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 4px 6px; font-weight: 600; }
.password-field { position: relative; }
.password-field input { padding-right: 54px; }
.password-toggle { position: absolute; right: 2px; top: 1px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: transparent; color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 4px 6px; font-weight: 600; }
.sugs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sugs .chip { height: 28px; font-size: 12.5px; padding: 0 10px; }
.menu { display: flex; flex-direction: column; }
.menu .row { justify-content: space-between; padding: 14px 10px; font-weight: 550; }
.menu .row small { color: var(--muted); font-weight: 500; }
#business-panel-link[hidden] { display: none !important; }
#business-panel-link { text-decoration: none; color: inherit; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.menu .row.danger { color: var(--bad); }
.opt { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px; border-radius: 14px; font-weight: 600; width: 100%; }
.opt.on { background: var(--card-2); }
.opt .check { color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; background: var(--c); }
.swatch.on { box-shadow: 0 0 0 3px #12152a, 0 0 0 5px #fff; }
.emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emojis button { height: 38px; border-radius: 10px; font-size: 20px; }
.emojis button.on { background: var(--card-2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.install-steps { background: var(--card); border-radius: 16px; padding: 12px 14px; font-size: 13.5px; color: var(--muted); }
.install-steps b { color: var(--text); }

/* ---------- bienvenida ---------- */
.welcome { min-height: calc(100vh - 40px); display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 10px; padding: 20px 8px; }
.welcome .logo { width: 150px; margin: 0 auto 10px; animation: spinIn .8s cubic-bezier(.2, .8, .2, 1); }
.welcome h1 { font-size: 32px; letter-spacing: -.8px; margin: 0; }
.welcome p { color: var(--muted); margin: 0 0 18px; font-size: 16px; }
.welcome .features { text-align: left; display: grid; gap: 10px; margin: 0 0 22px; }
.welcome .features div { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translate(-50%, -140%); z-index: 60;
  background: rgba(30, 34, 55, .95); border: 1px solid var(--line); padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: 14px;
  transition: transform .3s cubic-bezier(.2, .9, .25, 1); white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- aviso de instalación ---------- */
.install-chip { height: 32px; padding: 0 12px; font-size: 13px; background: rgba(91, 140, 255, .18); border-color: rgba(91, 140, 255, .35); }
.link-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
svg.inl { display: inline-block; vertical-align: -3px; margin: 0 2px; }
.steps { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 14.5px; }
.steps li small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.step-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 750; font-size: 13px; }
.warn-box { background: rgba(255, 181, 71, .12); border: 1px solid rgba(255, 181, 71, .35); color: #ffd79a; border-radius: 14px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }
.ios-arrow { text-align: center; font-size: 30px; color: var(--accent); margin-top: 6px; animation: bounce 1.1s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }

/* ---------- cuenta y membresía ---------- */
.plan-chip { height: 32px; padding: 0 12px; font-size: 13px; background: rgba(255, 209, 102, .14); border-color: rgba(255, 209, 102, .35); color: #ffd98a; }
.plan-chip.over { background: rgba(255, 107, 129, .15); border-color: rgba(255, 107, 129, .4); color: var(--bad); }
.demo-bar { display: block; width: 100%; margin: 4px 0 2px; padding: 9px 12px; border-radius: 14px; font-size: 13px; text-align: center; background: rgba(91, 140, 255, .16); border: 1px solid rgba(91, 140, 255, .35); }
.account-card { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 4px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.benefits { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; font-size: 14.5px; }
.benefits li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.plan { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border-radius: 18px; text-align: left; background: var(--card); border: 1.5px solid var(--line); }
.plan.on { border-color: var(--accent); background: rgba(91, 140, 255, .12); }
.plan-name { font-weight: 650; font-size: 14px; }
.plan-name em { font-style: normal; font-size: 11px; font-weight: 700; color: #0b0d18; background: var(--good); border-radius: 99px; padding: 2px 7px; margin-left: 4px; }
.plan-price { font-size: 22px; font-weight: 750; }
.plan-price small { font-size: 12px; color: var(--muted); font-weight: 500; }
.ref-code { text-align: center; font-size: 34px; font-weight: 800; letter-spacing: 6px; padding: 10px 0 12px; color: #ffd98a; }

/* ---------- transferencias ---------- */
.amt.transfer { color: var(--muted); }
.seg button.on.transfer { color: var(--accent); }


/* Registro inteligente */
.smart-status { padding: 14px; border: 1px solid #57648a; border-radius: 14px; background: #142044; margin: 14px 0; }
.smart-status p, .smart-question { font-size: 14px; line-height: 1.5; }
.smart-toggle { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; line-height: 1.45; }
.smart-toggle input { width: 20px; height: 20px; flex-shrink: 0; accent-color: #7c6cff; }
.smart-candidate span { text-align: left; }
.smart-candidate small, .smart-audit small { display: block; margin: 5px 0; overflow-wrap: anywhere; }
.smart-audit { border-top: 1px solid #34405b; padding: 14px 0; }
.smart-question { padding: 10px; border-radius: 8px; background: #302947; }
.panel select { width: 100%; padding: 12px; background: #142044; color: #eef1ff; border: 1px solid #57648a; border-radius: 10px; font: inherit; }
