/* Mis finanzas · modelo 4: blanco y azul medio. Móvil primero (iPhone), letra del sistema. */

:root {
  color-scheme: light;
  --bg: #F4F6FA;
  --sup: #FFFFFF;
  --sup2: #EEF1F7;
  --linea: #E6EAF1;
  --txt: #0F172A;
  --txt2: #475569;
  --txt3: #64748B;
  --azul: #2F5FD0;
  --azul-osc: #2550B5;
  --azul-suave: #E6EDFB;
  --verde: #1E7B3A;
  --rojo: #C2362F;
  --foco: #2F5FD0;
  --sombra: 0 1px 2px rgba(15, 23, 42, .05);
  --sombra-alta: 0 18px 40px -12px rgba(15, 23, 42, .28);
  --radio: 22px;
  --sans: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  /* curva tipo hoja de iOS: arranca rápido y frena suave, sin rebote */
  --ios: cubic-bezier(.32, .72, 0, 1);
  --salida: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--txt);
  font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  caret-color: var(--azul);
}
::selection { background: color-mix(in srgb, var(--azul) 22%, transparent); }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.t-num, .m { font-variant-numeric: tabular-nums; }

/* Foco visible, hacia afuera, para que no quede tapado */
:focus-visible { outline: 3px solid var(--foco); outline-offset: 3px; border-radius: 12px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 16px; font-weight: 600; font-size: 17px;
  transition: transform .12s ease-out, background-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn-azul { background: var(--azul); color: #fff; }
.btn-azul:active { background: var(--azul-osc); }
.btn-borde { background: var(--sup); border: 1.5px solid var(--linea); }
.btn-rojo { background: var(--rojo); color: #fff; }
.peligro { color: var(--rojo); }
.btn[disabled] { opacity: .5; }
.icono-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--txt2); transition: background-color .15s, transform .12s ease-out; }
.icono-btn:active { transform: scale(.92); background: var(--sup2); }
.mini { min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--azul-suave); color: var(--azul); font-weight: 600; font-size: 15px; white-space: nowrap; }
.mini:active { transform: scale(.96); }
.enlace { display: block; margin: 28px auto 0; min-height: 44px; padding: 0 12px; color: var(--txt3); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Entrar ---------- */
.entrar {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); text-align: center;
}
.entrar-logo { border-radius: 20px; margin-bottom: 18px; box-shadow: var(--sombra-alta); }
.entrar h1 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.entrar p { color: var(--txt2); margin: 0 0 26px; max-width: 30ch; }
.entrar-form { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.entrar-form input { height: 56px; border-radius: 16px; border: 1.5px solid var(--linea); background: var(--sup); padding: 0 18px; font-size: 18px; text-align: center; }
.error { color: var(--rojo); min-height: 1.4em; margin: 2px 0 0; font-size: 15px; }

/* ---------- App ---------- */
.app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10px) 16px calc(178px + env(safe-area-inset-bottom)); }
.cabeza { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 14px; min-height: 64px; }
.cabeza h1 { font-size: 30px; font-weight: 700; letter-spacing: -.025em; margin: 0; }
.mesnav { display: flex; align-items: center; }
.mes-anio { min-height: 44px; padding: 0 4px; color: var(--txt3); font-weight: 500; font-variant-numeric: tabular-nums; }
.mesnav .icono-btn { width: 38px; color: var(--txt3); }

.vista { animation: aparecer .22s var(--salida) both; }

/* Tarjeta azul (saldo del mes y patrimonio) */
.tarjeta-azul { background: var(--azul); color: #fff; border-radius: 26px; padding: 18px 18px 14px; box-shadow: 0 16px 32px -18px rgba(47, 95, 208, .7); }
.t-eti { margin: 0; font-size: 15px; font-weight: 500; color: #DCE6FB; }
.t-num { margin: 2px 0 0; font-size: clamp(36px, 11vw, 46px); font-weight: 700; letter-spacing: -.035em; line-height: 1.08; overflow-wrap: anywhere; }
.t-delta { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: #DCE6FB; min-height: 1.2em; }
.curva { display: block; width: 100%; height: 64px; margin: 8px 0 10px; overflow: visible; }
.curva path { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .95; }
.curva circle { fill: #fff; }
.t-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.t-dos > * { background: rgba(255, 255, 255, .15); border-radius: 16px; padding: 9px 12px; text-align: left; display: grid; gap: 1px; min-width: 0; transition: background-color .15s, transform .12s ease-out; }
.t-dos button:active { transform: scale(.97); background: rgba(255, 255, 255, .24); }
.t-dos span { font-size: 13px; font-weight: 600; color: #DCE6FB; }
.t-dos b { font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.t-dos button:focus-visible { outline-color: #fff; }

/* Consejos */
.consejo { margin-top: 12px; background: var(--sup); border-radius: 20px; padding: 13px 14px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--sombra); }
.ic-suave { width: 38px; height: 38px; border-radius: 12px; background: var(--azul-suave); color: var(--azul); display: grid; place-items: center; flex: none; }
.ic-suave svg { width: 20px; height: 20px; }
#consejo-txt { display: grid; gap: 8px; font-size: 15px; line-height: 1.38; color: var(--txt2); padding-top: 1px; }
#consejo-txt p { margin: 0; }
#consejo-txt b { color: var(--txt); font-weight: 650; }

/* Secciones y listas */
.secc { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 26px 4px 0; min-height: 36px; }
.secc h2 { font-size: 21px; letter-spacing: -.015em; margin: 0; }
.secc > span { color: var(--txt3); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.secc-ayuda { margin: 0 4px 10px; color: var(--txt3); font-size: 14px; }
.secc + .lista { margin-top: 8px; }
.grupo { margin-top: 14px; }
.grupo:first-child { margin-top: 0; }
.grupo-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 6px 6px; font-size: 15px; min-height: 32px; }
.grupo-cab b { color: var(--txt2); font-weight: 650; }
.grupo-cab .dch { display: flex; align-items: center; gap: 8px; color: var(--txt3); font-variant-numeric: tabular-nums; }
.grupo-cab .mini { min-height: 34px; font-size: 14px; }
.lista { background: var(--sup); border-radius: var(--radio); padding: 0 14px; box-shadow: var(--sombra); }
.fila { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 0; text-align: left; min-height: 62px; transition: opacity .15s; border-radius: 0; }
.fila + .fila { border-top: 1px solid var(--linea); }
.fila:active { opacity: .6; }
.fila:focus-visible { outline-offset: -2px; border-radius: 12px; }
.ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.ico svg { width: 20px; height: 20px; }
.fila .t { flex: 1; min-width: 0; }
.fila .t b { display: block; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .t span { display: block; font-size: 13.5px; color: var(--txt3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .der { text-align: right; flex: none; }
.fila .t .total, .fila .t .total span { white-space: normal; }
.fila .t .total + .total { color: var(--txt2); }
.fila .t .total b { display: inline; font-size: inherit; font-weight: 650; }
.fila .m { font-weight: 650; font-size: 16px; white-space: nowrap; }
.fila .der small { display: block; color: var(--txt3); font-size: 12.5px; font-weight: 500; margin-top: 2px; white-space: nowrap; }
.pos { color: var(--verde) !important; }
.neg { color: var(--rojo) !important; }
.barrita { height: 4px; border-radius: 4px; background: var(--sup2); margin-top: 7px; overflow: hidden; }
.barrita i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--c); transition: width .6s var(--salida); }
.vacio { margin: 0; padding: 18px 14px; color: var(--txt3); text-align: center; font-size: 15px; }
.pulso { animation: pulso 1.2s var(--salida); }
.entra { animation: entra .34s var(--ios) both; }
.ayuda { color: var(--txt3); font-size: 14px; margin: 14px 6px 0; }

/* Movimientos */
.filtros { display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin: -4px -4px 8px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtros button { flex: none; min-height: 40px; padding: 0 13px; border-radius: 999px; background: var(--sup); color: var(--txt2); font-weight: 600; font-size: 15px; box-shadow: var(--sombra); transition: background-color .15s, color .15s; }
.filtros button[aria-pressed="true"] { background: var(--azul); color: #fff; }
.filtro-activo { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--azul-suave); color: var(--azul); border-radius: 16px; padding: 8px 8px 8px 14px; margin-bottom: 12px; font-weight: 650; font-size: 15px; }
.filtro-activo .acc { display: flex; gap: 6px; flex-wrap: wrap; }
.filtro-activo button { min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--sup); font-weight: 600; font-size: 14px; color: var(--azul); }
.filtro-activo button.peligro { color: var(--rojo); }
.dia { margin-bottom: 14px; }
.dia-cab { display: flex; justify-content: space-between; color: var(--txt3); font-size: 14px; padding: 0 8px 6px; }
.dia-cab span:last-child { font-variant-numeric: tabular-nums; }
.pend::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #E0A400; margin-left: 6px; vertical-align: middle; }

/* ---------- Botón flotante y pestañas ---------- */
.fab {
  position: fixed; z-index: 6; bottom: calc(92px + env(safe-area-inset-bottom)); right: max(18px, calc(50vw - 262px));
  width: 62px; height: 62px; border-radius: 21px; background: var(--azul); color: #fff; display: grid; place-items: center;
  box-shadow: 0 14px 28px -10px rgba(47, 95, 208, .75); transition: transform .12s ease-out, background-color .15s;
}
.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: scale(.92); background: var(--azul-osc); }
.fab:focus-visible { outline-offset: 4px; border-radius: 22px; }
.tabs {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(20px) saturate(170%); -webkit-backdrop-filter: blur(20px) saturate(170%); border-top: 1px solid var(--linea);
}
.tabs button { flex: 1; max-width: 180px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: #7B8597; border-radius: 14px; transition: color .15s; }
.tabs button[aria-current="page"] { color: var(--azul); }
.tabs svg { width: 24px; height: 24px; }
@media (prefers-reduced-transparency: reduce) { .tabs { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; } }

/* ---------- Hojas (bottom sheet con <dialog>) ---------- */
dialog { color: var(--txt); padding: 0; border: 0; }
dialog::backdrop { background: rgba(15, 23, 42, .38); opacity: 0; transition: opacity .3s; }
dialog.abierto::backdrop { opacity: 1; }
.hoja {
  width: 100%; max-width: 560px; max-height: calc(100dvh - env(safe-area-inset-top) - 20px);
  margin: auto auto 0; border-radius: 28px 28px 0 0; background: var(--sup); box-shadow: var(--sombra-alta);
  transform: translateY(100%); transition: transform .42s var(--ios); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
}
.hoja.abierto { transform: translateY(var(--arrastre, 0px)); }
.hoja.arrastrando { transition: none; }
@media (min-width: 700px) {
  .hoja { margin: auto; border-radius: 28px; transform: translateY(24px) scale(.98); opacity: 0; transition: transform .3s var(--ios), opacity .22s; }
  .hoja.abierto { opacity: 1; transform: none; }
}
.hoja-cuerpo { padding: 0 18px calc(18px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.tope { position: sticky; top: 0; z-index: 2; background: var(--sup); padding-top: 8px; touch-action: none; cursor: grab; }
.agarre { width: 40px; height: 5px; border-radius: 5px; background: #D5DBE5; margin: 0 auto 4px; }
.hoja-cabeza { display: flex; justify-content: space-between; align-items: center; }
.hoja-cabeza h2 { font-size: 22px; letter-spacing: -.015em; margin: 0; }

.segmento { display: flex; background: var(--sup2); border-radius: 14px; padding: 4px; gap: 2px; }
.segmento button { flex: 1; min-height: 42px; border-radius: 11px; color: var(--txt2); font-weight: 600; font-size: 16px; transition: background-color .2s var(--salida), color .2s, box-shadow .2s; }
.segmento button[aria-checked="true"] { background: var(--sup); color: var(--txt); box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
.segmento.suave { margin-top: -6px; }
.segmento.suave button[aria-checked="true"] { color: var(--azul); }

.campo-monto { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1.5px solid var(--linea); border-radius: 18px; padding: 0 18px; transition: border-color .15s; }
.campo-monto:focus-within { border-color: var(--azul); }
.campo-monto:has(input:focus-visible) { outline: 3px solid var(--foco); outline-offset: 2px; }
.campo-monto .signo { font-size: 28px; font-weight: 600; color: var(--txt3); }
.campo-monto input { flex: 1; min-width: 0; height: 70px; border: 0; background: none; outline: none; font-size: 36px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rapidos { display: flex; gap: 8px; overflow-x: auto; margin: -14px -8px -8px; padding: 8px; scrollbar-width: none; }
.rapidos::-webkit-scrollbar { display: none; }
.rapidos button, .sugerencias button { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; background: var(--sup2); font-size: 15px; font-weight: 600; color: var(--txt2); }
.rapidos button:active, .sugerencias button:active { transform: scale(.95); }

.cats { display: grid; gap: 14px; }
.cats h3 { margin: 0 0 8px 2px; font-size: 14px; font-weight: 650; color: var(--txt3); }
.cats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cat-op {
  min-height: 80px; border-radius: 16px; border: 1.5px solid var(--linea); background: var(--sup);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px;
  font-size: 13.5px; font-weight: 600; line-height: 1.15; text-align: center; color: var(--txt2);
  transition: border-color .15s, background-color .15s, transform .12s ease-out;
}
.cat-op .ico { width: 34px; height: 34px; border-radius: 11px; }
.cat-op .ico svg { width: 18px; height: 18px; }
.cat-op[aria-checked="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); color: var(--txt); }
.cat-op:active { transform: scale(.96); }
.cat-op.nueva { border-style: dashed; color: var(--azul); --c: var(--azul); }
.sugerencias { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: -4px; }
.sugerencias span { font-size: 14px; color: var(--txt3); width: 100%; }

.campo { display: grid; }
.campo > span, .grupo-campo legend { color: var(--txt3); font-size: 15px; margin-bottom: 8px; padding: 0; }
.campo > span em { font-style: normal; opacity: .85; }
.campo input { height: 54px; border-radius: 16px; border: 1.5px solid var(--linea); background: var(--bg); padding: 0 16px; font-size: 17px; width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; transition: border-color .15s; }
.campo input:focus { border-color: var(--azul); outline: none; }
.campo input:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
.campo input[type="date"] { display: flex; align-items: center; }
.grupo-campo { border: 0; margin: 0; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--linea); background: var(--sup); font-weight: 600; font-size: 15px; color: var(--txt2); }
.chips button[aria-checked="true"] { border-color: var(--azul); background: var(--azul-suave); color: var(--azul); }
.acciones { display: flex; gap: 10px; }
.acciones .btn { flex: 1; }
.acciones .peligro { flex: 0 0 auto; }

/* ---------- Confirmación: ventana centrada aparte ---------- */
.confirmar { width: min(92vw, 380px); margin: auto; border-radius: 24px; background: var(--sup); box-shadow: var(--sombra-alta); opacity: 0; transform: scale(.95); transition: opacity .2s, transform .28s var(--ios); }
.confirmar.abierto { opacity: 1; transform: none; }
.confirmar-cuerpo { padding: 24px 20px 20px; display: grid; gap: 10px; text-align: center; }
.confirmar h2 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.confirmar p { color: var(--txt2); margin: 0 0 10px; }

/* ---------- Aviso flotante (arriba: no tapa el botón + ni las pestañas) ---------- */
.aviso {
  position: fixed; z-index: 50; left: 50%; top: calc(env(safe-area-inset-top) + 10px); width: min(calc(100vw - 32px), 440px);
  transform: translate(-50%, -16px); opacity: 0; transition: opacity .2s, transform .35s var(--ios);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--txt); color: #fff; padding: 12px 16px; border-radius: 16px; box-shadow: var(--sombra-alta); font-weight: 600; font-size: 15px;
}
.aviso.ver { opacity: 1; transform: translate(-50%, 0); }
.aviso button { color: #9DB8F5; font-weight: 700; min-height: 36px; padding: 0 4px; }
.aviso button:focus-visible { outline-color: #fff; }

/* ---------- Movimiento ---------- */
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes entra { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pulso { 0% { background: color-mix(in srgb, var(--c, var(--azul)) 14%, transparent); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
