/* Paleta con significado fijo: verde progreso, rojo déficit, amarillo precaución, azul información, gris neutral */
:root {
  --verde: #2E7D32; --verde-suave: #E5F4E4;
  --rojo: #C62828; --rojo-suave: #FBEBEB;
  --amarillo: #8A6100; --amarillo-suave: #FFF4D6;
  --azul: #1F5FA8; --azul-suave: #E7F1FB;
  --gris: #5F6368; --gris-suave: #EEF0F2;
  --tinta: #1C2430; --fondo: #F7F8FA; --tarjeta: #FFFFFF; --marino: #1F3A5F;
  --radio: 16px; --sombra: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--tinta);
  background: var(--fondo); line-height: 1.4; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; outline: none; }
h1 { font-size: 1.6rem; margin: .4em 0 .5em; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1.05rem; }
a { color: var(--azul); }
.cargando { text-align: center; color: var(--gris); margin-top: 30vh; }

/* Barra superior y navegación */
.barra-superior { display: flex; justify-content: space-between; align-items: center; background: var(--marino); color: #fff;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); font-weight: 600; }
.barra-superior .boton-texto { color: #fff; }
.navegacion { position: fixed; bottom: 0; left: 0; right: 0; display: grid; background: #fff; border-top: 1px solid #DDE1E6;
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.navegacion.n2 { grid-template-columns: 1fr 1fr; } .navegacion.n4 { grid-template-columns: repeat(4, 1fr); } .navegacion.n5 { grid-template-columns: repeat(5, 1fr); }
.navegacion.n5 a { font-size: .72rem; }
.navegacion a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 68px;
  text-decoration: none; color: var(--gris); font-size: .8rem; font-weight: 600; gap: 2px; }
.navegacion a span { font-size: 1.5rem; }
.navegacion a[aria-current] { color: var(--marino); background: var(--azul-suave); }

/* Tarjetas y cifras */
.tarjeta { display: block; background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 14px; }
.tarjeta.info { background: var(--azul-suave); }
.tarjeta.alerta { background: var(--rojo-suave); }
.tarjeta.enlace { text-decoration: none; color: inherit; font-weight: 600; }
.alerta-suave { background: var(--amarillo-suave); color: var(--amarillo); }
.cifra { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--gris-suave); gap: 12px; }
.cifra:last-of-type { border-bottom: 0; }
.cifra span { font-size: 1rem; } .cifra b { font-size: 1.35rem; white-space: nowrap; }
.cifra.fuerte { border-radius: 10px; padding: 12px; margin-top: 6px; }
.cifra.fuerte.rojo { background: var(--rojo-suave); } .cifra.fuerte.verde { background: var(--verde-suave); }
.cifra.total b { font-size: 1.5rem; }
.verde { color: var(--verde); } .rojo { color: var(--rojo); } .azul { color: var(--azul); }
.cifra.verde b, .cifra.rojo b { color: inherit; }
.nota { color: var(--gris); font-size: .9rem; margin: .4em 0; }
.frase { font-size: 1.05rem; background: var(--gris-suave); border-radius: 10px; padding: 12px; margin: 12px 0 0; }
.etiqueta-estado { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; vertical-align: middle; text-transform: uppercase; letter-spacing: .03em; }
.etiqueta-estado.gris { background: var(--gris-suave); color: var(--gris); }
.etiqueta-estado.amarillo { background: var(--amarillo-suave); color: var(--amarillo); }

/* Cuadritos: comparación entra vs sale */
.pregunta { font-size: 1.15rem; margin: 16px 0 8px; }
.pregunta span { font-size: 1.5rem; }
.comparacion > div { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.rotulo { width: 54px; font-weight: 700; font-size: .9rem; flex: none; }
.cuadritos { display: flex; flex-wrap: wrap; gap: 3px; }
.cuadritos i { width: 18px; height: 18px; border-radius: 3px; display: block; }
.cuadritos.verde i { background: var(--verde); } .cuadritos.rojo i { background: var(--rojo); }

/* Barras por categoría */
.barras { list-style: none; padding: 0; margin: 0; }
.barras li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 10px; }
.b-nombre { font-size: .95rem; } .barras b { grid-row: 1; grid-column: 2; }
.b-barra { grid-column: 1 / -1; height: 12px; background: var(--gris-suave); border-radius: 6px; overflow: hidden; }
.b-barra i { display: block; height: 100%; border-radius: 6px; }
.g-esencial { background: var(--azul); } .g-discrecional { background: #E08A00; } .g-intereses { background: var(--rojo); } .g-otros { background: var(--gris); }
.leyenda { font-size: .8rem; color: var(--gris); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.leyenda i.verde { background: var(--verde); } .leyenda i.rojo { background: var(--rojo); }

/* Histórico */
.historico { display: flex; gap: 8px; align-items: flex-end; justify-content: space-between; }
.h-mes { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .75rem; }
.h-barras { height: 110px; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.h-barras i { width: 40%; max-width: 18px; display: block; border-radius: 3px 3px 0 0; min-height: 2px; }
.h-barras i.verde { background: var(--verde); } .h-barras i.rojo { background: var(--rojo); }
.h-mes small { font-weight: 700; font-size: .68rem; }

/* Selector de mes */
.selector-mes { display: flex; align-items: center; justify-content: space-between; }
.selector-mes h1 { text-transform: capitalize; margin: .3em 0; font-size: 1.4rem; }

/* Botones */
.boton { display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 20px; border-radius: 14px;
  border: 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.boton.grande { width: 100%; font-size: 1.15rem; min-height: 64px; margin-top: 12px; }
.boton.primario { background: var(--marino); color: #fff; } .boton.secundario { background: var(--gris-suave); color: var(--tinta); }
.boton.peligro { background: var(--rojo); color: #fff; }
.boton:disabled { opacity: .6; }
.boton-texto { background: none; border: 0; font: inherit; font-weight: 600; color: var(--azul); cursor: pointer; min-height: 44px; padding: 0 8px; }
.boton-texto.peligro { color: var(--rojo); }
.boton-icono { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--gris-suave); font-size: 1.8rem; cursor: pointer; }
.boton-icono:disabled { opacity: .3; }
.flotante { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); box-shadow: 0 4px 14px rgba(31,58,95,.35); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }

/* Registro */
.menu-tipos { display: grid; gap: 12px; }
.opcion-grande { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; text-align: left; align-items: center;
  border: 0; border-radius: var(--radio); padding: 14px 16px; font: inherit; font-size: 1.2rem; font-weight: 700; cursor: pointer; min-height: 84px; }
.opcion-grande span { grid-row: 1 / 3; font-size: 2rem; }
.opcion-grande small { font-weight: 400; font-size: .85rem; color: var(--gris); }
.opcion-grande.rojo { background: var(--rojo-suave); color: var(--rojo); } .opcion-grande.verde { background: var(--verde-suave); color: var(--verde); }
.opcion-grande.azul { background: var(--azul-suave); color: var(--azul); } .opcion-grande.gris { background: var(--gris-suave); color: var(--tinta); }
.cabecera-paso { display: flex; justify-content: space-between; align-items: center; color: var(--gris); font-size: .85rem; }
.monto-grande { display: flex; align-items: center; background: #fff; border: 2px solid var(--marino); border-radius: var(--radio); padding: 4px 16px; }
.monto-grande span { font-size: 2.4rem; font-weight: 700; color: var(--gris); }
.monto-grande input { border: 0; outline: 0; font-size: 2.6rem; font-weight: 700; width: 100%; padding: 8px; background: transparent; }
.rejilla { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 520px) { .rejilla { grid-template-columns: repeat(3, 1fr); } }
.opcion { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; padding: 10px;
  border: 2px solid transparent; border-radius: var(--radio); background: #fff; box-shadow: var(--sombra); font: inherit; font-size: .95rem;
  font-weight: 600; cursor: pointer; text-align: center; color: var(--tinta); }
.opcion .icono { font-size: 2rem; }
.opcion.elegida { border-color: var(--marino); background: var(--azul-suave); }
.grupo { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); margin: 14px 0 8px; }
.resumen-registro { text-align: center; }
.r-monto { font-size: 2.2rem; font-weight: 800; }
.r-flujo { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; margin: 6px 0; }
.etiqueta { display: block; font-weight: 600; margin: 14px 0 6px; }
.campo { width: 100%; min-height: 52px; font: inherit; padding: 10px 12px; border: 1.5px solid #C5CBD3; border-radius: 12px; background: #fff; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 500; }
.check input, .opciones-linea input { width: 24px; height: 24px; }
.opciones-linea { border: 0; padding: 0; margin: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.opciones-linea legend { font-weight: 600; margin-bottom: 6px; }
.opciones-linea label { flex: 1; display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid #C5CBD3; border-radius: 12px; padding: 0 14px; min-height: 52px; }
details { margin-top: 12px; } summary { font-weight: 600; min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--azul); }
.error { color: var(--rojo); font-weight: 600; min-height: 1.2em; }
.listo { text-align: center; padding-top: 20px; }
.palomita { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; background: var(--verde-suave); color: var(--verde);
  font-size: 3.4rem; display: flex; align-items: center; justify-content: center; }

/* Movimientos */
.filtros { display: grid; gap: 8px; margin-bottom: 8px; }
.lista-mov { list-style: none; padding: 0; margin: 0; }
.mov { background: #fff; border-radius: 14px; box-shadow: var(--sombra); padding: 12px; margin-bottom: 10px; }
.mov.anulado { opacity: .55; } .mov.anulado .m-monto { text-decoration: line-through; }
.m-linea { display: flex; gap: 10px; align-items: flex-start; }
.m-icono { font-size: 1.6rem; } .m-texto { flex: 1; min-width: 0; } .m-texto small { display: block; color: var(--gris); font-size: .8rem; }
.m-monto { white-space: nowrap; font-size: 1.05rem; }
.m-acciones { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.vacio { text-align: center; color: var(--gris); padding: 24px; }

/* Deudas */
.d-cabecera { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.d-saldo b { font-size: 1.7rem; display: block; } .d-saldo span { color: var(--gris); font-size: .9rem; }
.progreso { height: 14px; background: var(--gris-suave); border-radius: 7px; overflow: hidden; margin-top: 10px; }
.progreso i { display: block; height: 100%; background: var(--verde); }
.progreso.malo i { background: repeating-linear-gradient(45deg, var(--rojo), var(--rojo) 6px, #E57373 6px, #E57373 12px); }
.d-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 0 0; font-size: .88rem; }
.d-datos dt { color: var(--gris); } .d-datos dd { margin: 0; font-weight: 600; }
.deuda.familiar { border-left: 6px solid var(--azul); }

/* Login, aviso, diálogo */
.login { text-align: center; padding-top: 6vh; } .login .tarjeta { text-align: left; }
.aviso { position: fixed; left: 50%; transform: translateX(-50%) translateY(150%); bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 12px; transition: transform .25s, opacity .25s; z-index: 20; max-width: 90vw;
  opacity: 0; pointer-events: none; }
.aviso.visible { transform: translateX(-50%) translateY(0); opacity: 1; } .aviso.error { background: var(--rojo); }
dialog { border: 0; border-radius: var(--radio); padding: 0; max-width: min(92vw, 460px); width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialogo { padding: 20px; } .fila-botones { display: flex; gap: 10px; margin-top: 16px; } .fila-botones .boton { flex: 1; }

/* Formularios de ajuste */
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acciones .boton { min-height: 48px; flex: 1 1 30%; font-size: .9rem; padding: 0 10px; }
.insignia { display: inline-block; background: var(--rojo); color: #fff; font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; margin-bottom: 6px; }
.vista-previa { background: var(--azul-suave); border-radius: 12px; padding: 12px; margin-top: 14px; font-weight: 600; }
.vista-previa.rojo { background: var(--rojo-suave); color: var(--rojo); } .vista-previa.verde { background: var(--verde-suave); color: var(--verde); }
.radio-tarjeta { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1.5px solid #C5CBD3; border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.radio-tarjeta input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.radio-tarjeta small { display: block; color: var(--gris); font-weight: 400; }
.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.liquidadas li { padding: 8px 0; border-bottom: 1px solid var(--gris-suave); display: flex; justify-content: space-between; }
.liquidadas { list-style: none; padding: 0; margin: 0; }
