/* ==========================================================================
   MIS TERRENOS · la app del dueño
   Pensada para personas mayores: letra grande, mucho contraste, pocos
   botones y todo dicho con palabras. Nada se toca por accidente.
   ========================================================================== */
:root {
  --verde: #14532d;
  --verde-2: #166534;
  --verde-claro: #dcfce7;
  --oro: #b7791f;
  --fondo: #f4f1ea;
  --tarjeta: #ffffff;
  --texto: #1c1917;
  --suave: #57534e;
  --borde: #e7e2d8;
  --rojo: #b91c1c;
  --rojo-claro: #fee2e2;
  --azul: #1d4ed8;
  --naranja: #c2410c;
  --sombra: 0 2px 10px rgba(28, 25, 23, .08);
  --radio: 22px;
  --tab: 84px;
  font-size: 19px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Cabecera ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: linear-gradient(135deg, var(--verde) 0%, #1f6f3f 100%);
  color: #fff;
}
.cabecera-textos { flex: 1; min-width: 0; }
.saludo { font-size: 1.35rem; font-weight: 700; }
.empresa { font-size: .95rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cabecera-boton {
  width: 54px; height: 54px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.16); display: grid; place-items: center;
}
.cabecera-boton svg { width: 28px; height: 28px; fill: #fff; }
.cabecera-boton.girando svg { animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.frescura { text-align: center; font-size: .85rem; color: var(--suave); padding: 8px 16px 0; }
.frescura.vieja { color: var(--rojo); font-weight: 600; }

/* ---------- Vistas ---------- */
main { padding: 10px 16px calc(var(--tab) + 24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.vista { animation: aparecer .25s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.titulo-vista { font-size: 1.6rem; margin: 8px 4px 14px; }
.subtitulo { font-size: 1.2rem; margin: 22px 4px 10px; }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 20px 20px 18px; margin: 0 0 14px; border: 1px solid var(--borde); position: relative;
}
.tarjeta[data-ir] { cursor: pointer; }
.tarjeta[data-ir]:active { transform: scale(.99); }
.etiqueta { font-size: 1rem; color: var(--suave); font-weight: 600; }
/* Las cifras nunca se parten en dos líneas: se ajustan al ancho del teléfono. */
.cifra-gigante { font-size: clamp(1.75rem, 9vw, 2.4rem); font-weight: 800; letter-spacing: -.5px; color: var(--verde); margin: 4px 0 10px; white-space: nowrap; }
.cifra-grande { font-size: clamp(1.45rem, 7.2vw, 1.9rem); font-weight: 800; letter-spacing: -.3px; margin: 2px 0 4px; white-space: nowrap; }
.cifra-gigante small, .cifra-grande small { font-size: .55em; font-weight: 700; margin-right: 4px; opacity: .8; }
.nota { font-size: .98rem; color: var(--suave); }
.nota b { color: var(--texto); }
.tarjeta-heroe { background: linear-gradient(160deg, #ffffff 0%, #f0fdf4 100%); border-color: #bbf7d0; }
.tarjeta-aviso { border-color: #fed7aa; background: #fff7ed; }
.tarjeta-aviso .cifra-grande { color: var(--naranja); }
.tarjeta-mala { border-color: #fecaca; background: #fff5f5; }
.tarjeta-mala .cifra-grande { color: var(--rojo); }
.tarjeta-buena .cifra-grande { color: var(--verde-2); }
.barra { height: 16px; background: #e7e5e4; border-radius: 99px; overflow: hidden; }
.barra-relleno { height: 100%; width: 0; background: linear-gradient(90deg, var(--verde-2), #22c55e); border-radius: 99px; transition: width 1.2s ease-out; }
.nota.arriba { color: var(--verde-2); font-weight: 700; }
.nota.abajo { color: var(--rojo); font-weight: 700; }

/* Dona de solares */
.tarjeta-solares { display: flex; align-items: center; gap: 16px; }
.dona-caja { position: relative; width: 108px; height: 108px; flex: none; }
.dona { width: 100%; height: 100%; transform: rotate(-90deg); }
.dona-centro { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: var(--verde); }
.solares-textos { flex: 1; }
.flecha { font-size: 2.2rem; color: #a8a29e; }

/* Escuchar */
.escuchar {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--oro); color: #fff; border: 0; border-radius: 18px; padding: 18px;
  font-size: 1.15rem; font-weight: 700; margin: 6px 0 16px; box-shadow: var(--sombra);
}
.escuchar svg { width: 30px; height: 30px; fill: #fff; }
.escuchar.hablando { background: var(--verde-2); }

/* ---------- Solares ---------- */
.proyectos { display: flex; gap: 8px; overflow-x: auto; padding: 0 2px 10px; }
.proyectos button {
  flex: none; border: 2px solid var(--borde); background: #fff; border-radius: 99px; padding: 10px 18px; font-weight: 700;
}
.proyectos button.activo { border-color: var(--verde); background: var(--verde); color: #fff; }
.leyenda { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 14px; }
.leyenda div { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 10px 12px; border: 1px solid var(--borde); font-size: .95rem; }
.leyenda i { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.leyenda b { margin-left: auto; font-size: 1.1rem; }
.mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 7px; }
.solar {
  aspect-ratio: 1; border-radius: 12px; border: 0; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.e-DISPONIBLE { background: #e7e5e4; color: #57534e !important; box-shadow: inset 0 0 0 2px #d6d3d1; }
.e-VENDIDO { background: var(--azul); }
.e-SALDADO { background: var(--oro); }
.e-RESERVADO { background: var(--naranja); }
.e-NO_DISPONIBLE { background: #78716c; }
.e-ATRASADO { background: var(--rojo); }

/* ---------- Gráfico ---------- */
/* Los 12 meses SIEMPRE caben: sin cifras encima (no caben en un teléfono);
   el monto se ve tocando la barra, y el mejor mes va escrito debajo. */
.grafico { display: flex; align-items: flex-end; gap: 4px; height: 200px; margin-top: 16px; }
.columna { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; border: 0; background: none; padding: 0; }
.columna .palo { width: 100%; background: linear-gradient(180deg, #22c55e, var(--verde-2)); border-radius: 7px 7px 3px 3px; min-height: 3px; transition: height 1s ease-out; }
.columna .palo.cero { background: #e7e5e4; }
.columna.mejor .palo { background: linear-gradient(180deg, #facc15, var(--oro)); }
.columna .mes { font-size: .68rem; font-weight: 700; margin-top: 6px; color: var(--suave); }
.columna.actual .mes { color: var(--verde); }
.grafico-nota { margin-top: 12px; }

/* ---------- Listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li {
  background: #fff; border: 1px solid var(--borde); border-radius: 18px; padding: 14px 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.lista .l-texto { flex: 1; min-width: 0; }
.lista .l-nombre { font-weight: 700; font-size: 1.02rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.nota-lista { margin: -4px 4px 12px; }
.saldo { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--sombra); }
.saldo-cabeza { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.saldo-nombre { font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.saldo-monto { font-weight: 800; font-size: 1.15rem; color: var(--rojo); white-space: nowrap; }
.saldo .barra { height: 12px; margin: 10px 0 6px; }
.saldo .acciones { margin-top: 12px; }
.saldo .boton { padding: 11px; font-size: .95rem; }
.lista .l-detalle { font-size: .9rem; color: var(--suave); }
.lista .l-monto { font-weight: 800; font-size: 1.1rem; color: var(--verde); white-space: nowrap; }

.lista-deudores .deudor { background: #fff; border: 1px solid #fecaca; border-radius: var(--radio); padding: 18px; margin-bottom: 14px; box-shadow: var(--sombra); }
.deudor-nombre { font-size: 1.15rem; font-weight: 800; }
.deudor-detalle { color: var(--suave); font-size: .95rem; margin: 2px 0 8px; }
.deudor-debe { font-size: 1.5rem; font-weight: 800; color: var(--rojo); }
.deudor-dias { display: inline-block; background: var(--rojo-claro); color: var(--rojo); font-weight: 700; border-radius: 99px; padding: 3px 12px; font-size: .9rem; margin-top: 6px; }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.vacio { text-align: center; padding: 36px 18px; background: #fff; border-radius: var(--radio); border: 1px solid #bbf7d0; }
.vacio .grande-icono { font-size: 3.4rem; }
.vacio h3 { font-size: 1.35rem; margin: 10px 0 6px; color: var(--verde); }
.vacio p { color: var(--suave); margin: 0; }

/* ---------- Botones ---------- */
.boton { border: 0; border-radius: 16px; padding: 14px; font-weight: 800; background: var(--verde); color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.boton.grande { width: 100%; padding: 18px; font-size: 1.1rem; }
.boton.secundario { background: #e7e5e4; color: var(--texto); }
.boton.whatsapp { background: #16a34a; }
.boton.llamar { background: var(--azul); }
.boton svg { width: 22px; height: 22px; fill: #fff; }

/* ---------- Pestañas ---------- */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--borde);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.pestanas button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 16px; position: relative; color: #78716c; font-size: .86rem; font-weight: 700; }
.pestanas svg { width: 32px; height: 32px; fill: currentColor; }
.pestanas button.activa { color: var(--verde); background: var(--verde-claro); }
.insignia { position: absolute; top: 2px; right: calc(50% - 30px); background: var(--rojo); color: #fff; border-radius: 99px; font-size: .75rem; padding: 2px 7px; }

/* ---------- Hoja (ficha de un solar) ---------- */
.hoja { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.hoja-fondo { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: aparecer .2s; }
.hoja-caja {
  position: relative; width: 100%; max-width: 640px; margin: 0 auto; background: #fff;
  border-radius: 28px 28px 0 0; padding: 12px 22px calc(22px + env(safe-area-inset-bottom));
  animation: subir .25s ease-out; max-height: 88vh; overflow-y: auto;
}
@keyframes subir { from { transform: translateY(40%); } to { transform: none; } }
.hoja-asa { width: 54px; height: 6px; border-radius: 9px; background: #d6d3d1; margin: 0 auto 14px; }
.ficha-titulo { font-size: 1.6rem; font-weight: 800; margin: 0; }
.ficha-estado { display: inline-block; color: #fff; border-radius: 99px; padding: 4px 14px; font-weight: 700; margin: 8px 0 14px; }
.ficha-fila { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #f1efe9; font-size: 1.02rem; }
.ficha-fila span:first-child { color: var(--suave); }
.ficha-fila span:last-child { font-weight: 700; text-align: right; }
.ficha-cliente { font-size: 1.2rem; font-weight: 800; margin: 2px 0 12px; }
.ficha-barra { margin: 8px 0 4px; }
.hoja .boton.secundario { margin-top: 18px; }

/* ---------- Cargando (se ve antes de que arranque la app) ---------- */
.cargando { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px;
  background: linear-gradient(160deg, #14532d 0%, #0f3d22 100%); color: #fff; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.cargando img { border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.cargando h1 { font-size: 1.9rem; margin: 14px 0 6px; }
.cargando p { font-size: 1.1rem; margin: 4px 0; opacity: .95; }
.cargando-ayuda { max-width: 340px; margin-top: 22px !important; font-size: 1rem !important; opacity: .85 !important; line-height: 1.45; }

/* ---------- Entrada (PIN) ---------- */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--verde) 0%, #0f3d22 100%); color: #fff; }
.entrada-caja { width: 100%; max-width: 380px; text-align: center; }
.entrada-logo { width: 92px; height: 92px; border-radius: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.entrada h1 { font-size: 1.9rem; margin: 14px 0 4px; }
.entrada-texto { font-size: 1.15rem; opacity: .9; margin: 0 0 18px; }
.pin-puntos { display: flex; justify-content: center; gap: 18px; margin-bottom: 22px; }
.pin-puntos i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255,255,255,.75); }
.pin-puntos i.lleno { background: #fff; border-color: #fff; }
.pin-puntos.error { animation: temblar .4s; }
@keyframes temblar { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.teclado button { height: 72px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 1.9rem; font-weight: 600; width: 72px; justify-self: center; }
.teclado button:active { background: rgba(255,255,255,.32); }
.teclado .tecla-vacia { visibility: hidden; }
.entrada-codigo input { width: 100%; font-size: 1.6rem; text-align: center; letter-spacing: 6px; padding: 16px; border-radius: 16px; border: 0; margin-bottom: 14px; }
.entrada-codigo input::placeholder { letter-spacing: 0; font-size: 1.05rem; color: #78716c; }
/* Sobre el fondo verde, el botón va BLANCO: verde sobre verde no se distinguía. */
.entrada .boton { background: #fff; color: var(--verde); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.entrada-error { min-height: 1.5em; color: #fecaca; font-weight: 700; margin-top: 16px; }

@media (min-width: 560px) { :root { font-size: 20px; } .mapa { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); } }
