:root {
  --azul: #1F3B8C;
  --azul-oscuro: #172D6B;
  --lima: #D4E04A;
  --fondo: #F5F4F0;
  --blanco: #FFFFFF;
  --texto: #1A1F2E;
  --suave: #6B7080;
  --linea: #E6E4DE;
  --verde: #1E7B34;
  --verde-fondo: #E6F4EA;
  --rojo: #B3261E;
  --rojo-fondo: #FCE8E6;
  --azul-fondo: #E8EEF9;
  --amarillo-fondo: #FFF8D6;
  --radio: 16px;
  --barra-alto: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); }
body {
  color: var(--texto);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--barra-alto) + env(safe-area-inset-bottom) + 16px); }

/* Cabecera azul + hoja */
.cabecera {
  background: var(--azul);
  color: var(--blanco);
  padding: calc(20px + env(safe-area-inset-top)) 16px 52px;
}
.cabecera h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.cabecera p { margin: 6px 0 0; font-size: 14px; opacity: 0.8; }
.hoja {
  background: var(--fondo);
  border-radius: 24px 24px 0 0;
  margin-top: -32px;
  padding: 16px;
  min-height: 50vh;
}

/* Tarjetas */
.tarjeta {
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 16px;
  margin-bottom: 12px;
}
.tarjeta h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.etiqueta { font-size: 13px; color: var(--suave); font-weight: 500; }
.monto { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.monto small { font-size: 13px; font-weight: 500; color: var(--suave); margin-left: 2px; }
.principal { background: var(--azul); color: var(--blanco); border: none; }
.principal .etiqueta, .principal .detalle, .principal .monto small { color: rgba(255, 255, 255, 0.75); }
.principal .monto { font-size: 34px; }
.detalle { font-size: 13px; margin-top: 8px; color: var(--suave); }
.fila2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fila2 .tarjeta { margin-bottom: 12px; }
.negativo { color: var(--rojo); }
.a-favor { color: var(--verde); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--lima); color: var(--texto); border-radius: var(--radio);
  padding: 14px 16px; margin-bottom: 12px; font-weight: 600; text-decoration: none;
}

/* Botones */
.boton {
  display: block; width: 100%; border: none; border-radius: 14px;
  padding: 15px 16px; font-weight: 700; font-size: 16px; cursor: pointer; margin-top: 8px; text-align: center;
}
.boton-lima { background: var(--lima); color: var(--texto); }
.boton-azul { background: var(--azul); color: var(--blanco); }
.boton-gris { background: var(--blanco); color: var(--texto); border: 1px solid var(--linea); }
.boton-chico {
  border: none; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 14px;
  background: var(--azul); color: var(--blanco); cursor: pointer; white-space: nowrap;
}
.boton:disabled, .boton-chico:disabled { opacity: 0.5; cursor: default; }

/* Buscador y píldoras */
.buscador {
  width: 100%; border: 1px solid var(--linea); border-radius: 12px; background: var(--blanco);
  padding: 12px 14px; margin-bottom: 12px; outline: none;
}
.buscador:focus { border-color: var(--azul); }
.pildoras { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.pildoras::-webkit-scrollbar { display: none; }
.pildora {
  flex: none; border: 1px solid var(--linea); background: var(--blanco); border-radius: 999px;
  padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.pildora.activa { background: var(--azul); border-color: var(--azul); color: var(--blanco); }

/* Listas */
.seccion-titulo { font-size: 13px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: 0.04em; margin: 16px 4px 8px; }
.lista { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--linea); }
.item:first-child { border-top: none; }
.item-cuerpo { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 13px; color: var(--suave); margin-top: 2px; }
.item-monto { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.chip-hoy { background: var(--lima); color: var(--texto); }
.chip-atrasado { background: var(--amarillo-fondo); color: #7A5B00; }
.chip-roja { background: var(--rojo-fondo); color: var(--rojo); }
.chip-gris { background: var(--fondo); color: var(--suave); }

/* Extracto: no depender solo del color, cada tipo tiene ícono y texto */
.icono-mov {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.mov-ingreso .icono-mov { background: var(--verde-fondo); color: var(--verde); }
.mov-gasto .icono-mov { background: var(--rojo-fondo); color: var(--rojo); }
.mov-pago .icono-mov { background: var(--azul-fondo); color: var(--azul); }
.mov-ingreso .item-monto { color: var(--verde); }
.mov-gasto .item-monto { color: var(--rojo); }
.mov-pago .item-monto { color: var(--azul); }
.resumen-mes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.resumen-mes .monto { font-size: 18px; }

.aviso-caja {
  font-size: 13px; line-height: 1.45; padding: 12px; border-radius: 12px;
  background: var(--amarillo-fondo); border: 1px solid #EEE2A0; margin-bottom: 12px;
}
.vacio, .cargando { text-align: center; color: var(--suave); padding: 28px 8px; font-size: 14px; line-height: 1.5; }
.error { color: var(--rojo); }

/* Barra inferior */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--blanco); border-top: 1px solid var(--linea);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra-dentro { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--barra-alto); }
.barra a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--suave); text-decoration: none; font-size: 11px; font-weight: 600;
}
.barra a svg { width: 22px; height: 22px; }
.barra a.activa { color: var(--azul); }

/* Hoja de confirmación */
#capa .fondo-oscuro { position: fixed; inset: 0; background: rgba(10, 15, 30, 0.45); z-index: 20; }
#capa .hoja-dialogo {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 480px; margin: 0 auto;
  background: var(--blanco); border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}
.hoja-dialogo h2 { margin: 0 0 8px; font-size: 18px; }
.hoja-dialogo p { margin: 0 0 8px; line-height: 1.45; }

.aviso-flotante {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--barra-alto) + env(safe-area-inset-bottom) + 12px);
  max-width: 448px; margin: 0 auto; z-index: 30;
  background: var(--texto); color: var(--blanco); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; line-height: 1.4; opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.aviso-flotante.visible { opacity: 1; transform: none; }

/* Inicio de sesión */
.login { text-align: center; padding-top: 8px; }
.login p { color: var(--suave); line-height: 1.5; }
#botonGoogle { display: flex; justify-content: center; margin: 16px 0; min-height: 44px; }
