@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito+Sans:wght@400;600;700;800&display=swap');

:root {
  --verde: #246E52;
  --verde-suave: #DCEFE6;
  --verde-oscuro: #184A38;
  --rojo: #C0392B;
  --rojo-suave: #FBE4E1;
  --fondo: #F4F7F5;
  --tarjeta: #FFFFFF;
  --texto: #1F2A26;
  --texto-suave: #6B7C75;
  --borde: #E4ECE8;
  --sombra: 0 4px 16px rgba(31, 42, 38, 0.08);
  --radio: 18px;
  --radio-chico: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Nunito Sans', sans-serif;
  background: var(--fondo);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3, .titulo-app, .monto-grande {
  font-family: 'Baloo 2', sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px;
}

/* ---------- Encabezado ---------- */
.encabezado {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-oscuro) 100%);
  color: white;
  padding: 22px 20px 28px;
  border-radius: 0 0 28px 28px;
}
.encabezado .titulo-app {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}
.encabezado .subtitulo {
  font-size: 13px;
  opacity: 0.85;
}

.saldo-caja {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radio);
  padding: 16px 18px;
  margin-top: 16px;
}
.saldo-caja .etiqueta { font-size: 12px; opacity: 0.85; }
.saldo-caja .monto-grande { font-size: 30px; font-weight: 700; margin-top: 2px; }
.saldo-fila { display: flex; gap: 12px; margin-top: 12px; }
.saldo-item { flex: 1; background: rgba(255,255,255,0.10); border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.saldo-item b { display: block; font-size: 16px; }

/* ---------- Contenido ---------- */
.contenido { padding: 16px; flex: 1; }
.vista { display: none; }
.vista.activa { display: block; animation: aparecer .25s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.seccion-titulo {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tarjeta {
  background: var(--tarjeta);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 16px;
}

/* ---------- Chips de período ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  border: none; background: var(--tarjeta); color: var(--texto-suave);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  white-space: nowrap; box-shadow: var(--sombra); cursor: pointer;
}
.chip.activo { background: var(--verde); color: white; }

/* ---------- Listas de categoría / forma de pago con barra ---------- */
.fila-barra { margin-bottom: 14px; }
.grafico-torta-cont { position: relative; height: 220px; display: flex; align-items: center; justify-content: center; }
.fila-barra .top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.fila-barra .top .nombre { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.fila-barra .barra-fondo { height: 8px; background: var(--borde); border-radius: 6px; overflow: hidden; }
.fila-barra .barra-fondo .relleno { height: 100%; border-radius: 6px; }

/* ---------- Movimientos (lista) ---------- */
.mov-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--borde);
}
.mov-item:last-child { border-bottom: none; }
.mov-icono {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
}
.mov-info { flex: 1; min-width: 0; }
.mov-info .cat { font-weight: 700; font-size: 14.5px; }
.mov-info .meta { font-size: 12px; color: var(--texto-suave); }
.mov-monto { font-weight: 800; font-size: 15px; white-space: nowrap; }
.mov-monto.ingreso { color: var(--verde); }
.mov-monto.gasto { color: var(--rojo); }
.mov-item .foto-mini { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; margin-left: 4px; }

.vacio {
  text-align: center; padding: 30px 10px; color: var(--texto-suave); font-size: 14px;
}
.vacio .emoji { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- Navegación inferior ---------- */
.nav-inferior {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--tarjeta);
  border-top: 1px solid var(--borde);
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  background: none; border: none; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 10.5px; color: var(--texto-suave);
  font-weight: 700; padding: 4px 8px; cursor: pointer;
}
.nav-btn .icono { font-size: 21px; }
.nav-btn.activo { color: var(--verde); }
.nav-btn.fab {
  background: var(--verde); color: white; width: 54px; height: 54px;
  border-radius: 50%; font-size: 26px; margin-top: -26px;
  box-shadow: 0 6px 16px rgba(36,110,82,0.45); justify-content: center;
}
.nav-btn.fab .icono { font-size: 26px; }

/* ---------- Formulario "Agregar" (grande y simple) ---------- */
.toggle-tipo { display: flex; background: var(--borde); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.toggle-tipo button {
  flex: 1; border: none; background: none; padding: 12px 0; border-radius: 999px;
  font-weight: 800; font-size: 14.5px; color: var(--texto-suave); cursor: pointer;
}
.toggle-tipo button.activo.ingreso { background: var(--verde); color: white; }
.toggle-tipo button.activo.gasto { background: var(--rojo); color: white; }

.campo-monto {
  text-align: center; margin: 6px 0 22px;
}
.campo-monto input {
  width: 100%; border: none; background: none; text-align: center;
  font-family: 'Baloo 2', sans-serif; font-size: 46px; font-weight: 700; color: var(--texto);
  outline: none;
}
.campo-monto .simbolo { color: var(--texto-suave); font-size: 20px; }

label.etq { font-size: 12.5px; font-weight: 800; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .03em; margin: 14px 0 8px; display: block; }

.grid-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.opcion-icono {
  background: var(--fondo); border: 2px solid transparent; border-radius: var(--radio-chico);
  padding: 10px 4px; text-align: center; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--texto);
}
.opcion-icono .emoji { font-size: 22px; display: block; margin-bottom: 4px; }
.opcion-icono.sel { border-color: var(--verde); background: var(--verde-suave); }

textarea, input[type=text], input[type=date] {
  width: 100%; border: 1.5px solid var(--borde); border-radius: var(--radio-chico);
  padding: 12px 14px; font-size: 14.5px; font-family: inherit; color: var(--texto); background: var(--tarjeta);
}
textarea { resize: none; min-height: 54px; }

.zona-foto {
  border: 2px dashed var(--borde); border-radius: var(--radio); padding: 16px; text-align: center;
  color: var(--texto-suave); font-size: 13.5px; cursor: pointer; background: var(--fondo);
}
.zona-foto.tiene-foto { border-style: solid; border-color: var(--verde); }
.zona-foto img { max-width: 100%; max-height: 160px; border-radius: 12px; margin-top: 8px; }
.zona-foto .emoji { font-size: 26px; display: block; margin-bottom: 4px; }
.zona-foto .pdf-adjunto {
  background: var(--verde-suave); color: var(--verde-oscuro); font-weight: 700;
  border-radius: 12px; padding: 14px; font-size: 14px; word-break: break-all;
}
.ocr-estado { font-size: 12.5px; margin-top: 8px; color: var(--verde); font-weight: 700; }
.link-comprobante {
  font-size: 11px; font-weight: 800; color: var(--verde); background: var(--verde-suave);
  border-radius: 6px; padding: 2px 6px; text-decoration: none; margin-left: 4px;
}

.btn-grande {
  width: 100%; border: none; border-radius: 999px; padding: 16px; font-size: 16px;
  font-weight: 800; color: white; background: var(--verde); margin-top: 20px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(36,110,82,0.35);
}
.btn-grande.gasto { background: var(--rojo); box-shadow: 0 6px 16px rgba(192,57,43,0.35); }
.btn-secundario {
  width: 100%; border: 1.5px solid var(--borde); background: var(--tarjeta); border-radius: 999px;
  padding: 12px; font-weight: 700; color: var(--texto-suave); margin-top: 10px; cursor: pointer;
}

/* ---------- Gestión de categorías / formas de pago ---------- */
.lista-gestion .item-gestion {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--borde);
}
.lista-gestion .item-gestion:last-child { border-bottom: none; }
.item-gestion .emoji-chico { font-size: 19px; }
.item-gestion .nombre-item { flex: 1; font-weight: 700; font-size: 14px; }
.item-gestion button.borrar { border: none; background: var(--rojo-suave); color: var(--rojo); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; }

.form-nuevo { display: flex; gap: 8px; margin-top: 12px; }
.form-nuevo input { flex: 1; }
.form-nuevo button { border: none; background: var(--verde); color: white; border-radius: var(--radio-chico); padding: 0 16px; font-weight: 800; cursor: pointer; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--verde-oscuro); color: white; padding: 12px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; opacity: 0; transition: all .3s ease; z-index: 50; pointer-events: none;
  max-width: 90%; text-align: center;
}
.toast.mostrar { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Pantalla de login con Google ---------- */
#pantalla-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-oscuro) 100%);
  padding: 20px;
}
.login-caja {
  background: var(--tarjeta); border-radius: 24px; padding: 34px 26px;
  max-width: 340px; width: 100%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-emoji { font-size: 46px; margin-bottom: 6px; }
.login-caja h1 { font-family: 'Baloo 2', sans-serif; font-size: 22px; margin: 0 0 10px; color: var(--verde-oscuro); }
.login-caja p { font-size: 13.5px; color: var(--texto-suave); margin: 0 0 20px; }
#boton-google { display: flex; justify-content: center; }
.login-nota { color: var(--rojo); font-weight: 700; font-size: 12.5px; margin-top: 14px !important; }

/* ---------- Caja de cuenta en Ajustes ---------- */
.cuenta-caja { display: flex; align-items: center; gap: 12px; }
.cuenta-caja img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.cuenta-datos { flex: 1; min-width: 0; }
.cuenta-nombre { font-weight: 800; font-size: 14px; }
.cuenta-email { font-size: 12px; color: var(--texto-suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-instalar {
  display: none; align-items: center; gap: 10px; background: var(--verde-suave);
  border-radius: var(--radio-chico); padding: 12px; margin-bottom: 14px; font-size: 13px;
}
.banner-instalar.mostrar { display: flex; }
.banner-instalar button { border: none; background: var(--verde); color: white; border-radius: 8px; padding: 8px 12px; font-weight: 800; font-size: 12.5px; cursor: pointer; white-space: nowrap; }

/* ---------- Filtro por mes (Historial) ---------- */
.filtro-mes { display: flex; gap: 8px; margin-top: 10px; }
.filtro-mes input[type=month] { flex: 1; }

/* ---------- Movimientos clickeables ---------- */
.mov-item { cursor: pointer; }
.mov-item:active { background: var(--fondo); }

/* ---------- Modal de detalle ---------- */
.modal-fondo {
  display: none; position: fixed; inset: 0; background: rgba(24,74,56,0.55);
  z-index: 60; align-items: flex-end; justify-content: center;
}
.modal-fondo.mostrar { display: flex; animation: aparecerFondo .2s ease; }
@keyframes aparecerFondo { from { opacity: 0; } to { opacity: 1; } }
.modal-caja {
  background: var(--tarjeta); border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  max-width: 480px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative;
}
.modal-cerrar {
  position: absolute; top: 14px; right: 16px; border: none; background: var(--fondo);
  width: 32px; height: 32px; border-radius: 50%; font-size: 15px; color: var(--texto-suave); cursor: pointer;
}
.detalle-monto { text-align: center; font-family: 'Baloo 2', sans-serif; font-size: 32px; font-weight: 700; margin: 6px 0 4px; }
.detalle-monto.ingreso { color: var(--verde); }
.detalle-monto.gasto { color: var(--rojo); }
.detalle-cat { text-align: center; color: var(--texto-suave); font-size: 14px; margin-bottom: 18px; }
.detalle-fila { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--borde); font-size: 13.5px; }
.detalle-fila .lbl { color: var(--texto-suave); }
.detalle-fila .val { font-weight: 700; text-align: right; }
.detalle-comprobante { margin-top: 16px; }
.detalle-comprobante img { width: 100%; border-radius: var(--radio-chico); }
.detalle-comprobante a.pdf-link {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--verde-suave); color: var(--verde-oscuro); border-radius: var(--radio-chico);
  padding: 16px; font-weight: 800; text-decoration: none;
}
.detalle-ocr {
  margin-top: 12px; background: var(--fondo); border-radius: var(--radio-chico); padding: 12px;
  font-size: 12px; color: var(--texto-suave); white-space: pre-wrap; max-height: 120px; overflow-y: auto;
}
.detalle-ocr .titulo-ocr { font-weight: 800; color: var(--texto); display: block; margin-bottom: 6px; font-size: 12.5px; }
