[hidden] { display: none !important; }

/* Estilo iOS: fondo gris agrupado, tarjetas blancas, separadores finos, un solo color de acento */
:root {
  --bg: #F2F2F7;
  --sheet-bg: #FFFFFF;
  --text: #1C1C1E;
  --text-secondary: #6C6C70;
  --text-terciario: #AEAEB2;
  --chip-bg: #EFEFF4;
  --chip-bg-selected: rgba(255, 107, 74, 0.10);
  --accent: #FF6B4A;
  --border: rgba(60, 60, 67, 0.16);
  --handle: #C7C7CC;
  --rojo: #FF3B30;
  --verde: #34C759;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  position: fixed;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
}

.pantalla {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  padding-bottom: calc(110px + var(--safe-bottom));
}

/* En la Mac la app se queda del ancho de un teléfono, centrada */
.pantalla > * { max-width: 560px; margin-left: auto; margin-right: auto; }

/* ---------- Encabezados con título grande ---------- */

/* Como en iOS: botones arriba a la derecha y el título grande debajo */
.header-lista {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 6px;
  padding: calc(var(--safe-top) + 12px) 16px 8px 16px;
}

.header-lista > .btn-fab, .header-lista > .header-acciones { align-self: flex-end; }

.header-lista h1 {
  font-size: 34px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.header-acciones {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-fab {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icono-secundario {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: var(--sheet-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icono-secundario svg { width: 20px; height: 20px; }

.btn-dictar { background: var(--chip-bg-selected); color: var(--accent); }
.btn-dictar svg { width: 22px; height: 22px; }

/* Flechas de día / mes, agrupadas junto al título */
.header-dia-nav, .header-resumen {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px 16px 16px;
}

.header-resumen { padding-top: calc(var(--safe-top) + 24px); }

.header-dia-nav h2, .header-resumen h2 {
  margin: 0;
  min-width: 150px;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
}

.btn-icono {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.btn-icono svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icono:disabled { color: var(--text-terciario); }

/* ---------- Tarjetas y filas (listas agrupadas) ---------- */

.lista-gastos { padding: 0 16px; }

.tarjeta, .grupo-dia-card {
  background: var(--sheet-bg);
  border-radius: 14px;
  overflow: hidden;
}

.fila-transaccion, .fila-fijo-modal {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 16px;
  cursor: pointer;
}

/* Separador iOS: empieza después del ícono */
.fila-transaccion + .fila-transaccion::before,
.fila-fijo-modal + .fila-fijo-modal::before,
.fila-categoria + .fila-categoria::before,
.tarjeta .subtotal-row::before,
.grupo-dia-card .subtotal-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 70px;
  border-top: 0.5px solid var(--border);
}

.tarjeta .subtotal-row::before, .grupo-dia-card .subtotal-row::before { left: 16px; }

.fila-transaccion:active, .fila-fijo-modal:active { background: #E5E5EA; }

.fila-transaccion-icono {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--chip-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fila-transaccion-icono svg { width: 22px; height: 22px; }

.fila-transaccion-textos, .fila-fijo-modal-textos {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fila-fijo-modal-textos > span:first-child {
  font-size: 18px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fila-transaccion-textos .categoria {
  font-size: 18px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fila-transaccion-textos .nota, .fila-fijo-modal-tipo {
  font-size: 15px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fila-transaccion-monto, .fila-fijo-monto {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.subtotal-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-size: 17px;
  color: var(--text-secondary);
}

.subtotal-row strong { color: var(--text); font-size: 18px; font-weight: 700; }

.estado-vacio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 22vh;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 40px;
}

.estado-vacio p { font-size: 21px; font-weight: 600; color: var(--text); margin: 0; }
.estado-vacio span { font-size: 17px; }

/* ---------- Totales grandes ---------- */

.total-mes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 16px 22px 16px;
}

.total-mes span { font-size: 16px; color: var(--text-secondary); }
.total-mes strong { font-size: 42px; font-weight: 700; letter-spacing: -0.5px; }

/* ---------- Resumen ---------- */

.seccion { padding: 0 16px 24px 16px; }

/* Encabezado de sección estilo iOS, sobre la tarjeta */
.seccion h3 {
  font-size: 15px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin: 0 0 8px 16px;
}

.fila-vacia {
  font-size: 17px;
  color: var(--text-secondary);
  padding: 18px 16px;
  text-align: center;
}

.grafico-dona {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  margin: 22px auto 18px auto;
  position: relative;
}

.grafico-dona::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: var(--sheet-bg);
}

.fila-categoria {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 8px 16px;
}

.fila-categoria + .fila-categoria::before { left: 50px; }

.dot-categoria {
  width: 10px;
  height: 10px;
  border-radius: 5px;
  flex-shrink: 0;
}

.fila-categoria-icono {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.fila-categoria-icono svg { width: 20px; height: 20px; }

.fila-categoria-nombre { flex: 1; font-size: 18px; }
.fila-categoria-monto { font-size: 18px; font-weight: 600; }

/* ---------- Barra de pestañas ---------- */

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  background: rgba(249, 249, 249, 0.94);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  padding: 8px 0 calc(6px + var(--safe-bottom)) 0;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.tab-btn {
  flex: 1;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  color: #8E8E93;
  padding: 2px 0;
}

.tab-icono {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-btn.activo { color: var(--accent); }
.tab-btn.activo .tab-icono { stroke-width: 2.1; }

/* ---------- Hojas (modales) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.modal-alta { max-height: 80vh; }
.modal-corta { max-height: 75vh; }

.grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--handle);
  margin: 6px auto 0 auto;
}

.modal-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 4px 16px;
  font-size: 18px;
  font-weight: 600;
}

.modal-nav > span { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-texto { font-size: 18px; color: var(--accent); text-align: left; padding: 6px 0; }
.btn-guardar { font-weight: 600; text-align: right; justify-self: end; }
.btn-guardar:disabled { color: var(--text-terciario); }

.monto-container {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  padding-top: 18px;
}

.signo-peso { font-size: 34px; font-weight: 600; color: var(--text-secondary); }

#input-monto {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -1px;
  width: 240px;
  text-align: center;
}

.etiqueta-mxn {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-secondary);
  padding-bottom: 18px;
}

.seccion-categoria {
  margin: 0 16px;
  padding: 14px 12px 12px 12px;
  background: var(--sheet-bg);
  border-radius: 14px;
}

.label-seccion {
  font-size: 15px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  display: block;
  margin: 0 0 12px 4px;
}

.grid-categorias {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  row-gap: 14px;
  column-gap: 6px;
}

.chip-categoria {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.chip-categoria-circulo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border: 2px solid transparent;
}

.chip-categoria-circulo svg { width: 24px; height: 24px; color: var(--text); }

/* La categoría elegida se marca solo con el acento, sin colores por categoría */
.chip-categoria.seleccionada .chip-categoria-circulo {
  background: var(--chip-bg-selected) !important;
  border-color: var(--accent) !important;
}

.chip-categoria.seleccionada .chip-categoria-circulo svg { color: var(--accent); }

.chip-categoria-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.chip-categoria.seleccionada .chip-categoria-label {
  color: var(--text);
  font-weight: 600;
}

.fila-detalle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 16px 0 16px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--sheet-bg);
  cursor: pointer;
}

.fila-detalle-info { display: flex; align-items: center; gap: 14px; }
.fila-icono { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.fila-icono svg { width: 20px; height: 20px; }
.fila-textos { display: flex; flex-direction: column; gap: 1px; }
.fila-titulo { font-size: 15px; color: var(--text-secondary); }
.fila-valor { font-size: 18px; font-weight: 500; }
.chevron { color: var(--text-terciario); font-size: 22px; }

.opciones-inline {
  display: flex;
  flex-direction: column;
  margin: 6px 16px 0 16px;
  background: var(--sheet-bg);
  border-radius: 14px;
  overflow: hidden;
}

.opciones-inline button {
  padding: 14px 16px;
  text-align: left;
  font-size: 18px;
  border-bottom: 0.5px solid var(--border);
}

.opciones-inline button:last-child { border-bottom: none; }

.input-fecha {
  display: block;
  margin: 6px 16px 0 16px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--sheet-bg);
  font-size: 18px;
  width: calc(100% - 32px);
}

.btn-eliminar {
  display: block;
  width: calc(100% - 32px);
  margin: 24px 16px 0 16px;
  padding: 15px;
  text-align: center;
  color: var(--rojo);
  font-size: 18px;
  font-weight: 500;
  background: var(--sheet-bg);
  border-radius: 14px;
}

/* ---------- Interruptor iOS ---------- */

.switch {
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: #E9E9EA;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch.activo { background: var(--verde); }

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

.switch.activo .switch-knob { transform: translateX(20px); }

/* ---------- Formularios ---------- */

.campo-form { padding: 16px 16px 0 16px; }
.campo-form label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 6px 4px;
}
.campo-form input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--sheet-bg);
  font-size: 18px;
}

.campo-monto-fijo {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--sheet-bg);
}

.campo-monto-fijo span { color: var(--text-secondary); font-size: 18px; }
.campo-form .campo-monto-fijo input { flex: 1; font-size: 18px; padding: 0; min-width: 0; border-radius: 0; }

.segmented {
  display: flex;
  background: #E3E3E8;
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.segmented-btn {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.segmented-btn.activo {
  background: #fff;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.04);
}

/* ---------- Entrada con contraseña ---------- */

.pantalla-login {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-caja {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-caja h1 { margin: 0; font-size: 32px; font-weight: 700; }
.login-caja p { margin: 0 0 8px; color: var(--text-secondary); }
.login-caja input[type="password"] {
  font-size: 17px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--sheet-bg);
  outline: none;
}
.login-caja input[type="password"]:focus { border-color: var(--accent); }
.error-login { color: #FF3B30; font-size: 14px; }
.btn-entrar {
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
}
.btn-entrar:disabled { opacity: 0.5; }

/* ---------- Aviso de gastos sin subir ---------- */

.aviso-sync {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: #1C1C1E;
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Dictar gasto ---------- */

/* La hoja de dictar sale desde arriba: el teclado del iPhone cubre la parte de abajo */
.modal-arriba { align-items: flex-start; }
.modal-arriba .modal-sheet {
  border-radius: 0 0 14px 14px;
  padding-top: var(--safe-top);
  padding-bottom: 16px;
}
.modal-arriba .grabber { display: none; }

.dictar-cuerpo { padding: 16px 16px 8px 16px; }

#input-dictar {
  width: 100%;
  padding: 18px 16px;
  border-radius: 14px;
  background: var(--sheet-bg);
  font-size: 22px;
  font-weight: 600;
}

.dictar-ayuda {
  margin: 14px 4px 10px 4px;
  font-size: 16px;
  color: var(--text-secondary);
}

.dictar-ayuda svg { width: 18px; height: 18px; color: var(--accent); vertical-align: -3px; }

.dictar-ejemplos { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.dictar-ejemplos span {
  font-size: 15px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--sheet-bg);
  color: var(--text-secondary);
}

.error-dictar { margin: 14px 4px 0 4px; font-size: 16px; color: var(--rojo); }

/* Micrófono de un toque (cuando el navegador permite reconocimiento de voz) */
.btn-escuchar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 22px auto 4px auto;
  border-radius: 36px;
  background: var(--accent);
  color: #fff;
}

.btn-escuchar svg { width: 32px; height: 32px; }

.btn-escuchar.activo { animation: pulso 1.3s ease-out infinite; }

@keyframes pulso {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 74, 0.45); }
  100% { box-shadow: 0 0 0 22px rgba(255, 107, 74, 0); }
}

.dictar-estado { text-align: center; font-weight: 500; }
