/* ═══════════════════════════════════════════
   Fhipe — estilos. Tema carbón neutro + verde.
   Mobile-first, sin dependencias. Tipografía Rubik (local, offline).
   ═══════════════════════════════════════════ */
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 800; /* variable */
  font-display: swap;
  src: url('../fonts/rubik-latin.woff2') format('woff2');
}

:root {
  /* Paleta neutra: negro carbón, grises fríos. Sin tinte cálido. */
  --bg: #0E0F11;
  --bg-2: #141619;
  --surface: #16181C;
  --surface-2: #1E2126;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --green: #3DDC6B;
  --green-dim: #2fb457;
  --green-soft: rgba(61, 220, 107, 0.14);
  --text: #F2F4F6;
  --muted: #9AA1AC;
  --muted-2: #626873;
  --red: #FF6B6B;
  --amber: #FFC24B;
  --blue: #5B9DFF;
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }

/* ── Splash ── */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg);
  transition: opacity .35s ease;
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 24px; display: block;
  object-fit: cover;
  animation: pulse 1.4s ease-in-out infinite;
}
.splash-name { font-size: 1.6rem; font-weight: 800; letter-spacing: .5px; color: var(--green); }
@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.06);opacity:.8} }

/* ── Layout app ── */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(12px + var(--safe-t)) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(180deg, var(--bg) 68%, rgba(14,15,17,.7));
  backdrop-filter: blur(6px);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: block;
  object-fit: cover;
}
.brand-text { font-weight: 800; font-size: 1.2rem; letter-spacing: .3px; }
.topbar-sub { font-size: .72rem; color: var(--muted-2); text-align: right; max-width: 160px; }

.screen {
  flex: 1;
  padding: 8px 16px calc(var(--tabbar-h) + 90px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Secciones y cards ── */
.section { margin: 16px 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 12px;
}
.section-title { font-weight: 700; font-size: 1rem; }
.page-head { margin: 6px 0 14px; }
.page-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 2px; }
.muted { color: var(--muted); }
.muted.small, .small { font-size: .82rem; }
.center { text-align: center; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.link-btn {
  background: none; border: none; color: var(--green); font-weight: 600; font-size: .85rem; padding: 4px;
}

/* ── Tape 14 días ── */
.tape-total { font-size: .8rem; font-weight: 700; }
.tape-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.tape-track { display: flex; gap: 6px; min-width: min-content; }
.tape-cell {
  flex: 0 0 auto; width: 46px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tape-bar-wrap { height: 40px; display: flex; align-items: flex-end; }
.tape-bar { width: 22px; border-radius: 5px; background: var(--muted-2); min-height: 3px; }
.tape-bar.pos { background: var(--green); }
.tape-bar.neg { background: var(--red); }
.tape-bar.zero { background: rgba(255,255,255,.12); }
.tape-net { font-size: .58rem; font-weight: 700; white-space: nowrap; }
.tape-net.zero { color: var(--muted-2); }
.tape-day { font-size: .78rem; font-weight: 700; }
.tape-wd { font-size: .6rem; color: var(--muted-2); text-transform: capitalize; }

/* ── Stat cards swipeables ── */
.stat-scroll {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; padding-bottom: 2px;
  scrollbar-width: none;
}
.stat-scroll::-webkit-scrollbar { display: none; }
.stat-card {
  flex: 0 0 100%; scroll-snap-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; min-height: 104px;
}
.stat-card.danger { border-color: rgba(255,107,107,.45); background: linear-gradient(180deg, rgba(255,107,107,.08), var(--surface)); }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; }
.stat-foot { font-size: .72rem; color: var(--muted-2); }
.stat-card.danger .stat-foot { color: var(--red); font-weight: 600; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.2); transition: .2s; }
.dot.active { background: var(--green); width: 18px; border-radius: 3px; }

/* ── Donut ── */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut-chart { position: relative; width: 180px; height: 180px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-total { font-size: 1.3rem; font-weight: 800; }
.donut-sub { font-size: .68rem; color: var(--muted-2); }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 9px; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-label { flex: 1; color: var(--text); }
.legend-val { font-weight: 700; }

/* ── Progress bars ── */
.pbar { height: 9px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.pbar-fill.ok { background: var(--green); }
.pbar-fill.near { background: var(--amber); }
.pbar-fill.over { background: var(--red); }

/* ── Budget summary rows (home) ── */
.budget-row { margin-bottom: 14px; }
.budget-row:last-child { margin-bottom: 0; }
.budget-row-head { display: flex; justify-content: space-between; font-size: .86rem; margin-bottom: 6px; }
.budget-flag { display: inline-block; margin-top: 5px; font-size: .74rem; color: var(--red); font-weight: 600; }

/* ── Listas de transacciones ── */
.tx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tx-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--line); transition: opacity .18s, transform .18s;
}
.tx-row:last-child { border-bottom: none; }
.tx-row.removing { opacity: 0; transform: translateX(30px); }
.tx-icon {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.05rem;
}
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: .74rem; color: var(--muted-2); }
.tx-amt { font-weight: 800; white-space: nowrap; }
.tx-del {
  background: none; border: none; color: var(--muted-2); padding: 6px; margin-right: -6px;
  display: grid; place-items: center; border-radius: 8px;
}
.tx-del:active { background: rgba(255,107,107,.15); color: var(--red); }

/* ── Cards genéricas (budgets/goals) ── */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-title { font-weight: 700; }
.card-sub { font-size: .78rem; color: var(--muted); }
.card-del { background: none; border: none; color: var(--muted-2); font-size: 1rem; padding: 4px 6px; border-radius: 8px; }
.card-del:active { color: var(--red); background: rgba(255,107,107,.12); }
.card-foot { margin-top: 9px; font-size: .8rem; }
.flag { font-weight: 700; font-size: .78rem; }
.flag.neg { color: var(--red); }
.flag.pos { color: var(--green); }

/* Goal-específico */
.goal-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.goal-pct { font-weight: 800; font-size: .95rem; }
.goal-eta { display: block; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.btn-soft, .goal-add {
  margin-top: 12px; width: 100%; padding: 10px; border-radius: var(--radius-sm);
  background: rgba(53,210,74,.12); border: 1px solid rgba(53,210,74,.3); color: var(--green);
  font-weight: 700; font-size: .88rem;
}
.btn-soft:active { background: rgba(53,210,74,.22); }

/* ── Botones nuevos / primarios / peligro ── */
.btn-new {
  width: 100%; margin-bottom: 14px; padding: 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px dashed rgba(53,210,74,.4); color: var(--green);
  font-weight: 700; font-size: .92rem;
}
.btn-new:active { background: var(--surface-2); }
.btn-primary {
  width: 100%; padding: 15px; border: none; border-radius: var(--radius-sm);
  background: var(--green); color: #06210a; font-weight: 800; font-size: 1rem; margin-top: 4px;
}
.btn-primary:active { background: var(--green-dim); }
.btn-danger {
  width: 100%; margin-top: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.35); color: var(--red); font-weight: 700;
}
.btn-danger:active { background: rgba(255,107,107,.2); }

/* ── Insights ── */
.insight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.insight {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px;
  border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--muted-2);
}
.insight.warn { border-left-color: var(--amber); }
.insight.good { border-left-color: var(--green); }
.insight.info { border-left-color: var(--blue); }
.insight-icon { font-size: 1.1rem; line-height: 1.2; flex: 0 0 auto; }
.insight-text { font-size: .86rem; line-height: 1.45; }
.disclaimer { margin: 14px 0 0; font-size: .72rem; color: var(--muted-2); line-height: 1.5; }

/* ── Bills ── */
.bill-list { display: flex; flex-direction: column; }
.bill-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.bill-row:last-child { border-bottom: none; }
.bill-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bill-name { font-weight: 600; }
.bill-status { font-size: .74rem; color: var(--muted-2); }
.bill-status.soon { color: var(--amber); font-weight: 600; }
.bill-status.overdue { color: var(--red); font-weight: 700; }
.bill-status.paid { color: var(--green); font-weight: 600; }
.bill-row.paid .bill-name { color: var(--muted); text-decoration: line-through; }
.bill-amt { font-weight: 800; white-space: nowrap; }
.bill-actions { display: flex; gap: 4px; }
.bill-pay, .bill-del {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-size: .85rem; display: grid; place-items: center;
}
.bill-pay { color: var(--green); border-color: rgba(53,210,74,.3); }
.bill-pay:active { background: rgba(53,210,74,.2); }
.bill-del:active { color: var(--red); }

/* ── Segmented (idioma / tipo) ── */
.seg, .type-toggle { display: flex; gap: 6px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.seg-btn, .tt-btn {
  flex: 1; padding: 10px; border: none; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: .9rem; transition: .2s;
}
.seg-btn.active, .tt-btn.active { background: var(--green); color: #06210a; }
.type-toggle { margin-bottom: 16px; }

.privacy { font-size: .8rem; color: var(--muted); background: rgba(53,210,74,.07); border: 1px solid rgba(53,210,74,.18);
  padding: 11px 13px; border-radius: var(--radius-sm); margin: 0 0 14px; line-height: 1.5; }
.about { text-align: center; font-size: .72rem; color: var(--muted-2); margin: 24px 0 8px; }

/* ── Empty states ── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-emoji { font-size: 2.6rem; display: block; margin-bottom: 12px; }

/* ── FAB ── */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 20px; border: none; z-index: 30;
  background: var(--green); color: #06210a;
  display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(53,210,74,.4);
  transition: transform .12s;
}
.fab:active { transform: scale(.92); }

/* ── Tabbar ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: rgba(14,15,17,.92); backdrop-filter: blur(16px) saturate(1.2);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: none; color: var(--muted-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .62rem; font-weight: 600; transition: color .18s;
}
.tab.active { color: var(--green); }
.tab svg { opacity: .9; }

/* ── Bottom sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55);
  opacity: 0; transition: opacity .25s;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg-2); border-top-left-radius: 24px; border-top-right-radius: 24px;
  padding: 8px 20px calc(24px + var(--safe-b));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto; border: 1px solid var(--line); border-bottom: none;
}
.sheet.show { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.18); margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.sheet-close { background: none; border: none; color: var(--muted); font-size: 1.1rem; padding: 6px; }

/* ── Forms ── */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  font-size: 1rem; font-family: inherit; appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--green); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b79a94' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 90px + var(--safe-b));
  transform: translate(-50%, 20px); z-index: 60;
  background: #111; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
  border: 1px solid var(--line);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Onboarding (primer arranque) ── */
.onb-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .28s;
  padding: 16px;
}
.onb-overlay.show { opacity: 1; }
.onb-card {
  width: 100%; max-width: 440px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 26px; padding: 30px 24px calc(24px + var(--safe-b));
  text-align: center;
  transform: translateY(30px); transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.onb-overlay.show .onb-card { transform: translateY(0); }
.onb-step-badge {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--green);
  background: rgba(53,210,74,.12); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px;
}
.onb-icon {
  width: 78px; height: 78px; margin: 0 auto 18px; border-radius: 22px;
  display: grid; place-items: center; font-size: 2.4rem;
  background: var(--surface); border: 1px solid var(--line);
}
.onb-title { font-size: 1.4rem; font-weight: 800; margin: 0 0 10px; }
.onb-text { font-size: .95rem; color: var(--muted); line-height: 1.6; margin: 0 auto 22px; max-width: 340px; }
.onb-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 22px; }
.onb-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); transition: .25s; }
.onb-dot.active { background: var(--green); width: 22px; border-radius: 4px; }
.onb-skip { display: block; margin: 14px auto 0; background: none; border: none; color: var(--muted-2); font-size: .85rem; font-weight: 600; }
.onb-final-actions { display: flex; flex-direction: column; gap: 10px; }
.onb-final-actions .btn-danger { margin-top: 0; }

/* Selector de idioma con banderas (más visible) */
.seg-flag { margin-right: 6px; }

/* ═══════════════════════════════════════════
   ANIMACIONES SOFISTICADAS
   ═══════════════════════════════════════════ */

/* Entrada escalonada de las secciones al renderizar una vista */
.screen > .section {
  animation: sectionIn .5s var(--ease-out) both;
}
.screen > .section:nth-child(1) { animation-delay: .02s; }
.screen > .section:nth-child(2) { animation-delay: .07s; }
.screen > .section:nth-child(3) { animation-delay: .12s; }
.screen > .section:nth-child(4) { animation-delay: .17s; }
.screen > .section:nth-child(5) { animation-delay: .22s; }
.screen > .section:nth-child(6) { animation-delay: .27s; }
.screen > .section:nth-child(7) { animation-delay: .32s; }
@keyframes sectionIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Filas de transacciones / listas: cascada sutil */
.tx-list .tx-row, .bill-list .bill-row, .insight-list .insight, .cards > .card {
  animation: rowIn .45s var(--ease-out) both;
}
.tx-list .tx-row:nth-child(1),.bill-list .bill-row:nth-child(1),.insight-list .insight:nth-child(1),.cards>.card:nth-child(1){animation-delay:.04s}
.tx-list .tx-row:nth-child(2),.bill-list .bill-row:nth-child(2),.insight-list .insight:nth-child(2),.cards>.card:nth-child(2){animation-delay:.09s}
.tx-list .tx-row:nth-child(3),.bill-list .bill-row:nth-child(3),.insight-list .insight:nth-child(3),.cards>.card:nth-child(3){animation-delay:.14s}
.tx-list .tx-row:nth-child(4),.bill-list .bill-row:nth-child(4),.insight-list .insight:nth-child(4),.cards>.card:nth-child(4){animation-delay:.19s}
.tx-list .tx-row:nth-child(5),.bill-list .bill-row:nth-child(5),.insight-list .insight:nth-child(5),.cards>.card:nth-child(5){animation-delay:.24s}
.tx-list .tx-row:nth-child(6),.bill-list .bill-row:nth-child(6),.insight-list .insight:nth-child(6),.cards>.card:nth-child(6){animation-delay:.29s}
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Donut: dibujo del anillo girando al aparecer */
.donut { animation: donutSpin .9s var(--ease-out) both; transform-origin: center; }
@keyframes donutSpin {
  from { opacity: 0; transform: rotate(-90deg) scale(.9); }
  to   { opacity: 1; transform: rotate(0) scale(1); }
}
.donut-center { animation: fadeScale .6s .35s var(--ease-spring) both; }
@keyframes fadeScale {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: scale(1); }
}

/* Barras de progreso: crecen desde 0 */
.pbar-fill { animation: barGrow .8s var(--ease-out) both; }
@keyframes barGrow { from { width: 0 !important; } }

/* Tape: barras crecen desde abajo, escalonadas */
.tape-bar { transform-origin: bottom; animation: tapeGrow .55s var(--ease-spring) both; }
.tape-cell:nth-child(1) .tape-bar{animation-delay:.02s}
.tape-cell:nth-child(2) .tape-bar{animation-delay:.05s}
.tape-cell:nth-child(3) .tape-bar{animation-delay:.08s}
.tape-cell:nth-child(4) .tape-bar{animation-delay:.11s}
.tape-cell:nth-child(5) .tape-bar{animation-delay:.14s}
.tape-cell:nth-child(6) .tape-bar{animation-delay:.17s}
.tape-cell:nth-child(7) .tape-bar{animation-delay:.20s}
.tape-cell:nth-child(n+8) .tape-bar{animation-delay:.23s}
@keyframes tapeGrow { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }

/* Stat value: conteo visual con leve subida */
.stat-value { animation: valueIn .6s var(--ease-spring) both; }
@keyframes valueIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Micro-interacciones: press con resorte */
.card, .tx-row, .stat-card, .bill-row, .seg-btn, .tab {
  transition: transform .18s var(--ease-spring), background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.btn-primary, .btn-new, .btn-soft, .btn-danger, .link-btn {
  transition: transform .16s var(--ease-spring), background .2s, box-shadow .2s, filter .2s;
}
.btn-primary:active, .btn-new:active, .btn-soft:active, .goal-add:active { transform: scale(.96); }
.card-del:active, .tx-del:active, .bill-pay:active, .bill-del:active { transform: scale(.85); }

/* FAB: entra rebotando + glow pulsante sutil */
.fab { animation: fabIn .55s .3s var(--ease-spring) both; }
@keyframes fabIn { from { opacity: 0; transform: scale(0) rotate(-45deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.fab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 24px;
  border: 2px solid var(--green); opacity: 0; animation: fabRing 2.6s ease-out infinite;
}
@keyframes fabRing {
  0% { opacity: .5; transform: scale(1); }
  60%, 100% { opacity: 0; transform: scale(1.35); }
}
.fab:active { transform: scale(.9); }

/* Tab activo: el icono da un saltito */
.tab.active svg { animation: tabPop .4s var(--ease-spring); }
@keyframes tabPop { 0%{transform:scale(1)} 40%{transform:scale(1.28) translateY(-2px)} 100%{transform:scale(1)} }

/* Topbar entra deslizando */
.topbar { animation: slideDown .5s var(--ease-out) both; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* Toast: rebote de resorte */
.toast { transition: opacity .25s, transform .35s var(--ease-spring); }

/* Onboarding: icono flota, badge entra */
.onb-icon { animation: floatY 3s ease-in-out infinite; }
@keyframes floatY { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.onb-step-badge { animation: fadeScale .4s var(--ease-spring) both; }
.onb-title { animation: rowIn .45s .05s var(--ease-out) both; }
.onb-text { animation: rowIn .45s .12s var(--ease-out) both; }

/* Sheet backdrop: los inputs del form entran escalonados */
.sheet.show .field, .sheet.show .btn-primary, .sheet.show .type-toggle {
  animation: rowIn .4s var(--ease-out) both;
}
.sheet.show .type-toggle { animation-delay: .03s; }
.sheet.show .field:nth-child(1) { animation-delay: .06s; }
.sheet.show .field:nth-child(2) { animation-delay: .1s; }
.sheet.show .field:nth-child(3) { animation-delay: .14s; }
.sheet.show .field:nth-child(4) { animation-delay: .18s; }
.sheet.show .btn-primary { animation-delay: .22s; }

/* Splash: el logo pulsa con glow */
.splash-logo {
  box-shadow: 0 0 0 0 rgba(61,220,107,.4);
  animation: pulse 1.4s ease-in-out infinite, glowPulse 2s ease-in-out infinite;
}
@keyframes glowPulse {
  0%,100% { box-shadow: 0 12px 40px rgba(61,220,107,.15); }
  50% { box-shadow: 0 12px 55px rgba(61,220,107,.35); }
}

/* Respeta usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Ancho máximo en pantallas grandes (se ve como app centrada) */
@media (min-width: 620px) {
  .app, .sheet, .toast { max-width: 480px; margin-left: auto; margin-right: auto; }
  .sheet { left: 50%; transform: translate(-50%, 100%); }
  .sheet.show { transform: translate(-50%, 0); }
  .fab { right: calc(50% - 240px + 18px); }
  .tabbar { max-width: 480px; left: 50%; transform: translateX(-50%); }
  body { background: #060708; }
  .app { background: var(--bg); min-height: 100vh; }
}
