:root {
  --bg: #f4f2ff;
  --bg2: #ebe7ff;
  --card: #ffffff;
  --text: #1d1838;
  --muted: #6d6889;
  --line: #e6e2f5;
  --primary: #7c5cff;
  --primary2: #5b3df5;
  --green: #16b364;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 6px 24px rgba(60, 40, 160, .10);
  --radius: 20px;
  --nav-h: 74px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0c1f;
    --bg2: #17132c;
    --card: #1d1838;
    --text: #f2f0ff;
    --muted: #a29dc4;
    --line: #2c2650;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 100% -10%, rgba(124, 92, 255, .18), transparent 60%), radial-gradient(900px 400px at -20% 0%, rgba(34, 197, 94, .12), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 40px); }

/* ---------- Encabezado ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; }
.top h1 { font-size: 24px; font-weight: 900; }
.top .fecha { color: var(--muted); font-size: 13px; }
.top .fecha::first-letter { text-transform: uppercase; }
.logo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, var(--primary), #22c55e); box-shadow: var(--shadow); animation: flotar 4s ease-in-out infinite; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; border: 1px solid var(--line); }
.card h2 { font-size: 17px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card h2 small { font-weight: 600; color: var(--muted); font-size: 13px; }
.stagger > * { animation: entrar .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .12s; }
.stagger > *:nth-child(4) { animation-delay: .18s; }
.stagger > *:nth-child(5) { animation-delay: .24s; }
.stagger > *:nth-child(6) { animation-delay: .30s; }
.stagger > *:nth-child(n+7) { animation-delay: .36s; }

.hero { background: linear-gradient(135deg, #7c5cff 0%, #5b3df5 45%, #16b364 130%); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: '💰'; position: absolute; right: -10px; bottom: -24px; font-size: 120px; opacity: .15; transform: rotate(-15deg); animation: flotar 6s ease-in-out infinite; }
.hero .label { opacity: .85; font-size: 13px; font-weight: 700; }
.hero .big { font-size: 38px; font-weight: 900; letter-spacing: -1px; margin: 4px 0 14px; }
.hero .mini { display: flex; gap: 10px; }
.hero .mini div { flex: 1; background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(4px); }
.hero .mini b { display: block; font-size: 16px; }
.hero .mini span { font-size: 12px; opacity: .85; }

/* ---------- Salud financiera ---------- */
.salud { display: flex; gap: 16px; align-items: center; }
.gauge { position: relative; width: 120px; height: 120px; flex: none; }
.gauge svg { transform: rotate(-90deg); }
.gauge .fondo { stroke: var(--line); }
.gauge .valor { transition: stroke-dashoffset 1.4s cubic-bezier(.2, .9, .3, 1); }
.gauge .centro { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .cara { font-size: 34px; animation: rebote 2.4s ease-in-out infinite; display: block; }
.gauge .num { font-weight: 900; font-size: 15px; }
.salud .frase { font-weight: 800; font-size: 17px; margin-bottom: 8px; }
.factor { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 5px 0; }
.factor .barra { flex: 1; height: 7px; border-radius: 9px; background: var(--line); overflow: hidden; }
.factor .barra i { display: block; height: 100%; border-radius: 9px; width: 0; transition: width 1.2s cubic-bezier(.2, .9, .3, 1); }
.consejo { margin-top: 14px; background: var(--bg2); border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; min-height: 62px; }
.consejo .burbuja { animation: aparecer .4s ease both; }
.consejo button { margin-left: auto; color: var(--primary); font-weight: 800; flex: none; }

/* ---------- Sobres ---------- */
.sobres { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sobre { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; text-align: left; position: relative; overflow: hidden; transition: transform .15s; box-shadow: var(--shadow); }
.sobre:active { transform: scale(.96); }
.sobre::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--c); }
.sobre .emoji { font-size: 26px; }
.sobre .n { font-weight: 800; font-size: 13px; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sobre .s { font-weight: 900; font-size: 18px; }
.sobre .s.neg { color: var(--red); }
.sobre .p { height: 6px; background: var(--line); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.sobre .p i { display: block; height: 100%; background: var(--c); border-radius: 9px; transition: width 1s; }
.sobre .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.sobre.rojo { animation: temblar .5s ease 1; border-color: var(--red); }

/* ---------- Listas ---------- */
.fila { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fila:last-child { border-bottom: 0; }
.fila .ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; flex: none; background: var(--bg2); }
.fila .info { flex: 1; min-width: 0; }
.fila .info b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .info span { font-size: 12.5px; color: var(--muted); }
.fila .monto { font-weight: 900; text-align: right; white-space: nowrap; }
.fila .monto.mas { color: var(--green); }
.fila .monto.menos { color: var(--text); }
.dia-titulo { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 14px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; background: var(--bg2); color: var(--muted); }
.chip.hoy { background: #fee2e2; color: #b91c1c; animation: latido 1.2s ease-in-out infinite; }
.chip.pronto { background: #fef3c7; color: #92400e; }
.chip.ok { background: #dcfce7; color: #166534; }
.vacio { text-align: center; padding: 26px 10px; color: var(--muted); }
.vacio .e { font-size: 46px; display: block; margin-bottom: 8px; animation: flotar 3s ease-in-out infinite; }

/* ---------- Botones ---------- */
.btn { background: var(--primary); color: #fff; padding: 13px 18px; border-radius: 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s, filter .2s; box-shadow: 0 6px 16px rgba(124, 92, 255, .35); }
.btn:active { transform: scale(.96); }
.btn:disabled { filter: grayscale(1) opacity(.5); box-shadow: none; }
.btn.full { width: 100%; }
.btn.sec { background: var(--bg2); color: var(--text); box-shadow: none; }
.btn.verde { background: var(--green); box-shadow: 0 6px 16px rgba(22, 179, 100, .35); }
.btn.rojo { background: transparent; color: var(--red); box-shadow: none; }
.btn.chico { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.fila-btns { display: flex; gap: 10px; }
.fila-btns > * { flex: 1; }
.link { color: var(--primary); font-weight: 800; font-size: 13px; }

/* ---------- Navegación ---------- */
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h); background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
nav.bottom .wrap { max-width: 560px; width: 100%; display: flex; align-items: center; justify-content: space-around; position: relative; }
nav.bottom button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; color: var(--muted); width: 64px; padding: 6px 0; transition: color .2s; }
nav.bottom button .i { font-size: 22px; transition: transform .25s cubic-bezier(.2, .9, .3, 1.6); }
nav.bottom button.on { color: var(--primary); }
nav.bottom button.on .i { transform: translateY(-3px) scale(1.18); }
.fab { width: 62px !important; height: 62px; border-radius: 22px; background: linear-gradient(135deg, var(--primary), #22c55e) !important; color: #fff !important; font-size: 32px !important; transform: translateY(-20px); box-shadow: 0 10px 24px rgba(124, 92, 255, .5); display: grid !important; place-items: center; transition: transform .3s cubic-bezier(.2, .9, .3, 1.6) !important; }
.fab.abierto { transform: translateY(-20px) rotate(135deg); }
.fab-menu { position: fixed; bottom: calc(var(--nav-h) + 26px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 25; pointer-events: none; }
.fab-menu button { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 14px 20px; border-radius: 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; opacity: 0; transform: translateY(20px) scale(.9); transition: all .3s cubic-bezier(.2, .9, .3, 1.4); white-space: nowrap; }
.fab-menu.on { pointer-events: auto; }
.fab-menu.on button { opacity: 1; transform: none; }
.fab-menu.on button:nth-child(2) { transition-delay: .05s; }
.fab-menu.on button:nth-child(3) { transition-delay: .1s; }
.fab-menu button .i { font-size: 22px; }
.velo { position: fixed; inset: 0; background: rgba(15, 10, 40, .45); z-index: 22; opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(2px); }
.velo.on { opacity: 1; pointer-events: auto; }

/* ---------- Hojas (modales inferiores) ---------- */
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; transform: translateY(105%); transition: transform .38s cubic-bezier(.2, .9, .3, 1.05); }
.hoja.on { transform: none; }
.hoja .cont { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); }
.hoja .asa { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 14px; }
.hoja h3 { font-size: 20px; font-weight: 900; margin-bottom: 14px; }

label.campo { display: block; margin-bottom: 14px; }
label.campo > span { display: block; font-size: 12.5px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.inp { width: 100%; padding: 13px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); outline: none; transition: border-color .2s; }
.inp:focus { border-color: var(--primary); }
.monto-grande { font-size: 40px; font-weight: 900; text-align: center; border: 0; background: transparent; padding: 6px; letter-spacing: -1px; }
.monto-wrap { background: var(--bg2); border-radius: 18px; padding: 10px; margin-bottom: 14px; text-align: center; }
.monto-wrap small { color: var(--muted); font-weight: 700; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 9px 12px; border-radius: 13px; background: var(--bg2); font-weight: 700; font-size: 13px; border: 2px solid transparent; transition: all .15s; }
.chips button.on { border-color: var(--c, var(--primary)); background: color-mix(in srgb, var(--c, var(--primary)) 18%, var(--card)); transform: scale(1.04); }
.chips button small { display: block; font-size: 11px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Reparto de ingreso */
.reparto-fila { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.reparto-fila .e { font-size: 22px; width: 30px; text-align: center; }
.reparto-fila .n { flex: 1; min-width: 0; font-weight: 700; font-size: 13.5px; }
.reparto-fila .n small { display: block; color: var(--muted); font-weight: 600; font-size: 11.5px; }
.reparto-fila input { width: 104px; padding: 8px 10px; text-align: right; font-weight: 800; }
.sin-asignar { position: sticky; top: -10px; z-index: 2; margin: 0 -18px 12px; padding: 12px 18px; font-weight: 900; display: flex; justify-content: space-between; align-items: center; background: var(--card); border-bottom: 1px solid var(--line); transition: color .3s; }
.sin-asignar.cero { color: var(--green); }
.sin-asignar.neg { color: var(--red); }
.sin-asignar .barra { height: 8px; flex: 1; margin: 0 12px; border-radius: 9px; background: var(--line); overflow: hidden; }
.sin-asignar .barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); transition: width .4s; }
.aviso { border-radius: 14px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 12px; }
.aviso.bien { background: #dcfce7; color: #14532d; }
.aviso.mal { background: #fee2e2; color: #7f1d1d; }
.aviso.info { background: var(--bg2); color: var(--text); }

/* Dona */
.dona-wrap { display: flex; align-items: center; gap: 16px; }
.dona-wrap svg circle { transition: stroke-dasharray 1.2s cubic-bezier(.2, .9, .3, 1); }
.leyenda { flex: 1; font-size: 13px; }
.leyenda div { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.leyenda i { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.leyenda span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leyenda b { font-weight: 800; }

/* Metas */
.meta { display: flex; gap: 14px; align-items: center; }
.meta .anillo { position: relative; width: 74px; height: 74px; flex: none; }
.meta .anillo svg { transform: rotate(-90deg); }
.meta .anillo span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; }
.meta .anillo circle.v { transition: stroke-dashoffset 1.3s cubic-bezier(.2, .9, .3, 1); }

/* Ajustes */
.canal { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.canal .cab { display: flex; align-items: center; gap: 10px; }
.canal .cab .e { font-size: 24px; }
.canal .cab b { flex: 1; }
.canal .cuerpo { margin-top: 12px; display: none; }
.canal.on .cuerpo { display: block; }
.canal .estado { font-size: 12px; margin-top: 4px; color: var(--muted); }
.canal .ayuda { font-size: 12.5px; color: var(--muted); background: var(--bg2); padding: 10px 12px; border-radius: 12px; margin-bottom: 10px; line-height: 1.5; }
.canal .ayuda code { background: var(--card); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 30px; transition: .25s; }
.switch i::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s cubic-bezier(.2, .9, .3, 1.5); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::before { transform: translateX(20px); }
.opc { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.opc span small { display: block; color: var(--muted); font-size: 12px; }

/* Toast */
.toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -120px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 800; z-index: 50; transition: transform .4s cubic-bezier(.2, .9, .3, 1.4); max-width: 92vw; box-shadow: var(--shadow); }
.toast.on { transform: translate(-50%, 0); }

/* Onboarding */
.onb { position: fixed; inset: 0; z-index: 60; background: linear-gradient(160deg, #7c5cff, #3b1fd6 50%, #0f9d58); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 24px; text-align: center; }
.onb .grande { font-size: 96px; animation: rebote 2s ease-in-out infinite; }
.onb h2 { font-size: 28px; font-weight: 900; margin: 14px 0 10px; }
.onb p { font-size: 16px; opacity: .92; max-width: 380px; line-height: 1.5; }
.onb .puntos { display: flex; gap: 8px; margin: 22px 0; }
.onb .puntos i { width: 9px; height: 9px; border-radius: 9px; background: rgba(255, 255, 255, .4); transition: .3s; }
.onb .puntos i.on { width: 26px; background: #fff; }
.onb .btn { background: #fff; color: #3b1fd6; min-width: 220px; }
.onb .inp { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .3); color: #fff; text-align: center; max-width: 320px; margin-top: 14px; }
.onb .inp::placeholder { color: rgba(255, 255, 255, .7); }
.onb .slide { animation: aparecer .45s ease both; display: flex; flex-direction: column; align-items: center; }

canvas#confeti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- Animaciones ---------- */
@keyframes entrar { from { opacity: 0; transform: translateY(18px) scale(.98); } }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px); } }
@keyframes flotar { 50% { transform: translateY(-6px) rotate(-3deg); } }
@keyframes rebote { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-5px) scale(1.08); } 60% { transform: translateY(0) scale(.97); } }
@keyframes latido { 50% { transform: scale(1.08); } }
@keyframes temblar { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 380px) {
  .hero .big { font-size: 32px; }
  .gauge { width: 100px; height: 100px; }
}
