/* ============================================================
   APP CELULAR — hoja de estilo unica
   Dark por defecto, negro puro para OLED.
   ============================================================ */

:root {
  --fondo:        #000000;
  --superficie:   #111113;
  --superficie-2: #1c1c1f;
  --borde:        #2a2a2e;
  --texto:        #f2f2f7;
  --texto-2:      #8e8e93;
  --acento:       #0a84ff;
  --gasto:        #ff453a;
  --ingreso:      #32d74b;
  --alto-barra:   52px;
  --alto-pestanas: 56px;
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --transicion: 170ms cubic-bezier(.32,.72,0,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100dvh;              /* nunca 100vh: Safari miente con la barra de URL */
  overflow: hidden;
  background: var(--fondo);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Barra superior ---------- */
#barra-superior {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--alto-barra) + var(--seguro-arriba));
  padding: var(--seguro-arriba) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: .5px solid var(--borde);
  z-index: 20;
}
#titulo-vista { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }

.chip-sync {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--superficie-2);
  color: var(--texto-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- Contenido ---------- */
#vista {
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--alto-barra) + var(--seguro-arriba) + 8px) 16px
           calc(var(--alto-pestanas) + var(--seguro-abajo) + 90px);
}

h2.seccion {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--texto-2);
  margin: 26px 0 10px;
}
h2.seccion:first-child { margin-top: 8px; }

.vacio {
  text-align: center;
  color: var(--texto-2);
  padding: 48px 24px;
  line-height: 1.5;
}
.vacio strong { display: block; color: var(--texto); margin-bottom: 6px; font-size: 17px; }

/* ---------- Tarjetas y filas ---------- */
.tarjeta {
  background: var(--superficie);
  border: .5px solid var(--borde);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--superficie);
  border-bottom: .5px solid var(--borde);
  min-height: 44px;
}
.lista { border-radius: 14px; overflow: hidden; border: .5px solid var(--borde); }
.lista .fila:last-child { border-bottom: 0; }

.fila-icono {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  background: var(--superficie-2);
  display: grid; place-items: center;
  font-size: 16px;
}
.fila-cuerpo { flex: 1; min-width: 0; }
.fila-titulo {
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fila-sub { font-size: 12.5px; color: var(--texto-2); margin-top: 2px; }
.fila-valor { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila-valor.gasto   { color: var(--gasto); }
.fila-valor.ingreso { color: var(--ingreso); }

/* Accion de borrar al deslizar */
.deslizable { position: relative; overflow: hidden; }
.deslizable .fila { position: relative; z-index: 2; transition: transform var(--transicion); }
.deslizable .borrar {
  position: absolute; inset: 0 0 0 auto;
  width: 84px;
  background: var(--gasto);
  color: #fff;
  font-size: 13px; font-weight: 600;
  display: grid; place-items: center;
  z-index: 1;
}

/* ---------- Resumen de finanzas ---------- */
.resumen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.resumen .tarjeta { margin: 0; padding: 14px; }
.resumen .rotulo { font-size: 12px; color: var(--texto-2); margin-bottom: 5px; }
.resumen .cifra { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.resumen .ancho { grid-column: 1 / -1; }

.barra-cat { margin-bottom: 14px; }
.barra-cat .cab { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.barra-cat .cab span:last-child { color: var(--texto-2); font-variant-numeric: tabular-nums; }
.barra-cat .riel { height: 7px; border-radius: 4px; background: var(--superficie-2); overflow: hidden; }
.barra-cat .relleno { height: 100%; border-radius: 4px; transition: width var(--transicion); }

/* ---------- Boton flotante ---------- */
#fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--alto-pestanas) + var(--seguro-abajo) + 16px);
  width: 60px; height: 60px;
  border-radius: 30px;
  background: var(--acento);
  color: #fff;
  font-size: 32px; font-weight: 300;
  line-height: 56px;
  box-shadow: 0 6px 20px rgba(10,132,255,.42);
  z-index: 30;
  transition: transform var(--transicion);
}
#fab:active { transform: scale(.9); }

/* ---------- Pestanas ---------- */
#pestanas {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--alto-pestanas) + var(--seguro-abajo));
  padding-bottom: var(--seguro-abajo);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(0,0,0,.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--borde);
  z-index: 25;
}
#pestanas button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--texto-2);
  min-height: 44px;
  transition: color var(--transicion);
}
#pestanas button.activa { color: var(--acento); }
#pestanas svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
#pestanas span { font-size: 10.5px; font-weight: 500; }

/* ---------- Hoja de captura ---------- */
#velo {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: aparecer var(--transicion);
}
@keyframes aparecer { from { opacity: 0 } to { opacity: 1 } }

#hoja {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--superficie);
  border-radius: 20px 20px 0 0;
  border-top: .5px solid var(--borde);
  padding: 8px 16px calc(16px + var(--seguro-abajo));
  animation: subir var(--transicion);
  max-height: 94dvh;
  overflow-y: auto;
}
@keyframes subir { from { transform: translateY(100%) } to { transform: translateY(0) } }

.hoja-agarre {
  width: 36px; height: 5px; border-radius: 3px;
  background: var(--borde);
  margin: 0 auto 12px;
}

.hoja-tipo {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--superficie-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 14px;
}
.hoja-tipo button {
  padding: 9px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  color: var(--texto-2);
  min-height: 40px;
  transition: background var(--transicion), color var(--transicion);
}
.hoja-tipo button.activa { background: var(--superficie); color: var(--texto); }

#monto {
  display: block;
  text-align: center;
  font-size: 46px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  padding: 4px 0 0;
}
#monto-ayuda {
  text-align: center;
  font-size: 12.5px;
  color: var(--texto-2);
  margin: 4px 0 14px;
}

#teclado {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
#teclado button {
  height: 52px;
  border-radius: 12px;
  background: var(--superficie-2);
  font-size: 22px;
  font-weight: 500;
  transition: background var(--transicion);
}
#teclado button:active { background: var(--borde); }

#categorias { display: flex; flex-wrap: wrap; gap: 8px; }
#categorias button {
  padding: 11px 15px;
  min-height: 44px;
  border-radius: 12px;
  background: var(--superficie-2);
  border: .5px solid var(--borde);
  font-size: 14.5px;
  font-weight: 500;
  display: flex; align-items: center; gap: 7px;
  transition: transform var(--transicion), background var(--transicion);
}
#categorias button:active { transform: scale(.94); background: var(--acento); }

.hoja-pie { display: flex; gap: 10px; margin-top: 16px; }
.secundario {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  background: var(--superficie-2);
  color: var(--texto-2);
  font-size: 14.5px;
  font-weight: 500;
}

/* ---------- Ajustes ---------- */
.ajuste-boton {
  width: 100%;
  text-align: left;
  padding: 15px 14px;
  background: var(--superficie);
  border-bottom: .5px solid var(--borde);
  font-size: 15px;
  min-height: 48px;
}
.ajuste-boton:last-child { border-bottom: 0; }
.ajuste-boton.peligro { color: var(--gasto); }
.ajuste-boton small { display: block; color: var(--texto-2); font-size: 12.5px; margin-top: 3px; }

/* ---------- Aviso flotante ---------- */
#aviso {
  position: fixed;
  left: 50%;
  bottom: calc(var(--alto-pestanas) + var(--seguro-abajo) + 88px);
  transform: translateX(-50%);
  background: var(--superficie-2);
  border: .5px solid var(--borde);
  color: var(--texto);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  z-index: 60;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: aparecer var(--transicion);
}

/* El usuario pidio dark siempre; en claro solo suavizamos el negro puro */
@media (prefers-color-scheme: light) {
  :root { --fondo: #0b0b0c; }
}

/* ---------- Hoja de edición ---------- */
.editor-velo {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  z-index: 70;
  animation: aparecer var(--transicion);
}
.editor-hoja {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  background: var(--superficie);
  border-radius: 20px 20px 0 0;
  border-top: .5px solid var(--borde);
  padding: 8px 16px 0;
  animation: subir var(--transicion);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}
.editor-titulo {
  font-size: 17px; font-weight: 700;
  text-align: center;
  padding: 4px 0 6px;
}
.editor-cuerpo {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.editor-cuerpo > div:first-child { margin-top: 4px; }
/* El pie queda fijo abajo: guardar no debería exigir scroll. */
.editor-pie {
  display: flex;
  gap: 10px;
  padding: 12px 0 calc(12px + var(--seguro-abajo));
  border-top: .5px solid var(--borde);
  background: var(--superficie);
}
