/* ============================================================
   TerremotoVzla — Diseño mobile-first, profesional e intuitivo
   ============================================================ */
:root {
  --azul-900: #0a2e52;
  --azul-700: #0d3b66;
  --azul-500: #1769aa;
  --azul-300: #4a90d9;
  --amarillo: #ffce3a;
  --rojo: #e03131;
  --rojo-bg: #fff0f0;
  --verde: #2f9e6f;
  --verde-bg: #e9f7f0;
  --naranja: #c77700;
  --naranja-bg: #fff5e0;
  --gris-900: #1b2733;
  --gris-600: #5a6b7b;
  --gris-400: #93a1ae;
  --linea: #e8edf2;
  --bg: #eef2f6;
  --card: #ffffff;
  --sombra-sm: 0 1px 3px rgba(13, 59, 102, .08);
  --sombra-md: 0 4px 16px rgba(13, 59, 102, .10);
  --sombra-lg: 0 12px 32px rgba(13, 59, 102, .16);
  --radio: 16px;
  --radio-sm: 12px;
  --max: 880px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* El atributo [hidden] siempre debe ocultar, aunque la regla del elemento use display:flex.
   Sin este !important, .modal{display:flex} dejaba el modal encima bloqueando la pantalla. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--gris-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Cabecera ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--azul-900), var(--azul-500));
  color: #fff;
  box-shadow: var(--sombra-md);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand strong { font-size: 17px; letter-spacing: .2px; display: block; }
.brand small { display: block; opacity: .82; font-size: 12px; font-weight: 400; }
.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .15);
  border-radius: 12px;
  font-size: 22px;
  flex: none;
}
.back {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  font-size: 22px; line-height: 1;
  background: rgba(255, 255, 255, .15);
  border-radius: 12px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s ease, box-shadow .2s, background .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn-report { background: var(--amarillo); color: #5a4500; box-shadow: 0 4px 12px rgba(255, 206, 58, .4); }
.btn-primary { background: var(--azul-700); color: #fff; box-shadow: var(--sombra-md); }
.btn-primary:hover { background: var(--azul-500); }
.btn-ghost { background: #eef3f8; color: var(--azul-700); border: 1px solid var(--linea); }
.btn-block { width: 100%; padding: 16px; font-size: 16px; border-radius: 14px; }

/* ---------- Layout ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 18px 16px 110px; }

/* ---------- Hero + búsqueda ---------- */
.hero {
  background: linear-gradient(160deg, #ffffff, #f4f9ff);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 22px 20px;
  box-shadow: var(--sombra-sm);
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(21px, 5.5vw, 27px);
  line-height: 1.2;
  letter-spacing: -.4px;
  margin-bottom: 8px;
}
.hero h1 .acento { color: var(--azul-500); }
.hero > p { color: var(--gris-600); font-size: 15px; margin-bottom: 18px; max-width: 52ch; }

.searchbox { position: relative; }
.searchbox .search-field { position: relative; }
.searchbox .search-field::before {
  content: "🔍";
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  opacity: .55;
  pointer-events: none;
}
.searchbox input[type="search"] {
  width: 100%;
  border: 2px solid var(--linea);
  border-radius: 14px;
  padding: 15px 16px 15px 46px;
  font-size: 16px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.searchbox input[type="search"]:focus {
  border-color: var(--azul-300);
  box-shadow: 0 0 0 4px rgba(74, 144, 217, .15);
  outline: none;
}
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.filters select {
  min-width: 0;
  font-size: 14px;
  padding: 12px 32px 12px 12px;
  text-overflow: ellipsis;
}
/* En pantallas muy angostas, apilamos para que el texto se lea completo */
@media (max-width: 400px) {
  .filters { grid-template-columns: 1fr; }
}

select, input, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--gris-900);
  border: 2px solid var(--linea);
  border-radius: var(--radio-sm);
  padding: 13px 14px;
  background: #fff;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--azul-300);
  box-shadow: 0 0 0 4px rgba(74, 144, 217, .15);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6b7b' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0 4px;
}
@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
.stat {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radio-sm);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--sombra-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 88px;
  height: 100%;
}
.stat .num { font-size: 24px; font-weight: 800; line-height: 1.05; }
.stat .num.upd { font-size: 15px; }
.stat .lbl { font-size: 11px; color: var(--gris-600); margin-top: 0; font-weight: 700; }
.stat.t-desaparecido .num { color: var(--rojo); }
.stat.t-encontrado .num { color: var(--verde); }
.stat.t-update .num { color: var(--azul-500); }
.stat.t-total .num { color: var(--azul-700); }

/* Accesos rápidos del inicio — estilo botón cálido */
.quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0 4px;
}
@media (max-width: 559px) {
  .quick { grid-template-columns: repeat(2, 1fr); }
}
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: linear-gradient(170deg, #ffffff, #f4f9ff);
  border: 1.5px solid #d7e3f0;
  border-radius: 16px;
  padding: 16px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--azul-700);
  box-shadow: 0 3px 10px rgba(13, 59, 102, .10);
  transition: transform .1s ease, box-shadow .2s, border-color .2s;
}
.quick-card:hover { box-shadow: 0 6px 18px rgba(13, 59, 102, .18); border-color: var(--azul-300); }
.quick-card:active { transform: translateY(2px) scale(.98); }
.quick-card .qi {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  background: var(--azul-700);
  color: #fff;
  border-radius: 50%;
  font-size: 26px;
  box-shadow: 0 4px 10px rgba(13, 59, 102, .30);
}

/* Banda de emergencia al pie del inicio */
.emergency-foot { margin-top: 26px; }
.emergency-foot .emergency-grid { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 560px) {
  .emergency-foot .emergency-grid { grid-template-columns: repeat(6, 1fr); }
}
.emergency-note { text-align: center; font-size: 12px; color: var(--gris-600); margin-top: 10px; }
.manifesto { line-height: 1.6; max-width: 60ch; margin: 0 auto; }

/* ---------- Sección resultados ---------- */
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 12px;
}
.results-head h2 { font-size: 16px; }
.results-head span { font-size: 13px; color: var(--gris-600); }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 14px;
}
@media (min-width: 560px) {
  .results { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

.card-person {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  overflow: hidden;
  box-shadow: var(--sombra-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .12s ease, box-shadow .2s;
}
.card-person:hover { transform: translateY(-3px); box-shadow: var(--sombra-md); }
.card-person:active { transform: translateY(0); }
.card-person .ph {
  position: relative;
  aspect-ratio: 4 / 5;
  background: linear-gradient(135deg, #e7eef5, #d7e2ee) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  color: #aebccb;
}
.card-person .ph .badge { position: absolute; top: 10px; left: 10px; }
.card-person .info { padding: 12px; }
.card-person .info h3 { font-size: 15px; line-height: 1.25; margin-bottom: 5px; }
.card-person .info .meta { font-size: 12px; color: var(--gris-600); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
/* El color lo heredan los SVG; cada ícono define si usa relleno o contorno. */
.ic { width: 13px; height: 13px; flex: none; color: var(--gris-600); vertical-align: middle; }

/* ---------- Insignias de estatus ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2px;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow: var(--sombra-sm);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.desaparecido { background: var(--rojo-bg); color: var(--rojo); }
.badge.encontrado { background: var(--verde-bg); color: var(--verde); }
.badge.hospitalizado { background: var(--naranja-bg); color: var(--naranja); }
.badge.fallecido { background: #eceef0; color: #4a5560; }

/* ---------- Estado vacío ---------- */
.empty {
  grid-column: 1/-1;
  text-align: center;
  color: var(--gris-600);
  padding: 48px 20px;
  background: var(--card);
  border: 2px dashed var(--linea);
  border-radius: var(--radio);
}
.empty .ico { font-size: 42px; margin-bottom: 10px; }
.empty strong { display: block; color: var(--gris-900); margin-bottom: 4px; }

.spinner { grid-column: 1/-1; text-align: center; color: var(--gris-400); padding: 40px; }

/* ---------- Botón flotante ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 999px;
  background: var(--rojo);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(224, 49, 49, .45);
  z-index: 45;
  transition: transform .1s;
}
.fab .plus { font-size: 26px; line-height: 1; }
.fab:active { transform: scale(.95); }

/* ---------- Modal de ficha ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(10, 46, 82, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 60;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  background: #fff;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 20px;
  position: relative;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .5; } }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, .06); color: var(--gris-900);
  font-size: 16px; cursor: pointer; z-index: 2;
}
.modal-card .gallery { display: flex; gap: 8px; overflow-x: auto; margin: 4px 0 16px; scroll-snap-type: x mandatory; }
.modal-card .gallery img { height: 210px; border-radius: 14px; scroll-snap-align: start; box-shadow: var(--sombra-sm); }
.modal-card h2 { margin: 10px 0 12px; font-size: 22px; letter-spacing: -.3px; }
.detail-grid { border: 1px solid var(--linea); border-radius: var(--radio-sm); overflow: hidden; }
.detail-row { display: flex; gap: 10px; padding: 11px 14px; font-size: 14px; }
.detail-row:nth-child(odd) { background: #f8fafc; }
.detail-row .k { color: var(--gris-600); min-width: 116px; font-weight: 600; flex: none; }
.detail-row .v { color: var(--gris-900); }
.contact-box {
  background: var(--verde-bg);
  border: 1px solid #c4e7d6;
  border-radius: var(--radio-sm);
  padding: 16px;
  margin-top: 16px;
}
.contact-box strong { display: block; margin-bottom: 8px; color: #1d6b4f; }
.contact-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.contact-actions a {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #c4e7d6; color: var(--azul-700);
  padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.map-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px; color: var(--azul-500); font-weight: 700;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 22px; }
}

/* ---------- Formulario ---------- */
.form-wrap { max-width: 620px; }
.card {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 20px;
  box-shadow: var(--sombra-sm);
}
.section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 800; color: var(--azul-700);
  margin: 26px 0 14px; padding-top: 18px;
  border-top: 1px solid var(--linea);
}
.section-title:first-of-type { border-top: none; padding-top: 2px; margin-top: 4px; }
.section-title .step {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  background: var(--azul-700); color: #fff;
  border-radius: 50%; font-size: 13px;
}
form label { display: block; margin-bottom: 16px; font-size: 13px; font-weight: 700; color: #36465a; }
form label input, form label select, form label textarea { margin-top: 7px; font-weight: 400; }
.row { display: flex; gap: 12px; }
.row label { flex: 1; min-width: 0; }
.req { color: var(--rojo); }
.muted { color: var(--gris-600); font-size: 13px; font-weight: 400; }

.geo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filelabel {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px dashed var(--azul-300);
  border-radius: var(--radio-sm);
  padding: 22px;
  text-align: center;
  color: var(--azul-700);
  background: #f4f9ff;
  cursor: pointer;
  font-weight: 700;
  transition: background .2s;
}
.filelabel:hover { background: #e9f3ff; }
.filelabel input { display: none; }
.filelabel .big { font-size: 28px; }
.preview { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.preview img { width: 76px; height: 76px; object-fit: cover; border-radius: var(--radio-sm); box-shadow: var(--sombra-sm); }

.formmsg { padding: 14px; border-radius: var(--radio-sm); margin: 10px 0; font-size: 14px; font-weight: 600; }
.formmsg.ok { background: var(--verde-bg); color: #1d6b4f; }
.formmsg.err { background: var(--rojo-bg); color: var(--rojo); }
.consent { font-size: 12px; color: var(--gris-600); text-align: center; margin-top: 14px; }

.notice {
  background: #fff8e6; border: 1px solid #ffe6a6; border-radius: var(--radio-sm);
  padding: 16px; margin: 4px 0;
}
.notice strong { display: block; margin-bottom: 6px; }

/* ---------- Pie ---------- */
.footer {
  max-width: var(--max);
  margin: 22px auto 0;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}
.footer p {
  color: var(--gris-600);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
.footer .manifesto {
  background: #f4f7fb;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 18px 20px;
  color: var(--gris-600);
  font-size: 13.5px;
  line-height: 1.7;
  max-width: 100%;
  box-shadow: var(--sombra-sm);
}
.footer .manifesto strong { color: var(--azul-700); }
.footer .manifesto p { color: var(--gris-600); font-size: 13px; line-height: 1.6; text-align: center; margin: 0 0 12px; }
.m-title { display: block; text-align: center; font-size: 14px; color: var(--azul-700); margin-bottom: 8px; }
.m-list { list-style: none; display: grid; gap: 8px; padding: 0; margin: 0; }
.m-list li {
  position: relative;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--gris-600);
  text-align: left;
}
.m-list li::before { content: "•"; position: absolute; left: 4px; color: var(--azul-500); font-weight: 800; }
.m-list li strong { color: var(--gris-900); }
.btn-support {
  display: flex;
  width: fit-content;
  margin: 16px auto 0;
  background: var(--azul-700);
  color: #fff;
  box-shadow: var(--sombra-md);
}
.btn-support:hover { background: var(--azul-500); }

/* ---------- Compartir en redes ---------- */
.share {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 20px;
  box-shadow: var(--sombra-sm);
  text-align: center;
  margin-top: 22px;
}
.share h2 { font-size: 16px; margin-bottom: 4px; }
.share p { margin-bottom: 14px; }
.share-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.share-btn {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: none; cursor: pointer; padding: 0;
  box-shadow: var(--sombra-md);
  transition: transform .1s ease;
}
.share-btn:active { transform: scale(.92); }
.share-btn svg { width: 26px; height: 26px; fill: #fff; }
.share-btn.wa { background: #25D366; }
.share-btn.fb { background: #1877F2; }
.share-btn.x  { background: #000000; }
.share-btn.ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.share-toast {
  margin: 14px auto 0;
  background: var(--gris-900); color: #fff;
  font-size: 13px; padding: 10px 16px; border-radius: 999px;
  display: inline-block;
}

/* ---------- Login admin ---------- */
.login-wrap { max-width: 420px; margin: 32px auto; }

/* ---------- Recursos de ayuda ---------- */
.emergency {
  background: #ffffff;
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 16px;
  box-shadow: var(--sombra-sm);
  margin-bottom: 16px;
}
.emergency h2 { font-size: 15px; margin-bottom: 12px; }
.emergency-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.emergency-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--rojo); color: #fff;
  border-radius: var(--radio-sm); padding: 12px 4px;
  box-shadow: 0 4px 12px rgba(224, 49, 49, .3);
  transition: transform .08s;
}
.emergency-btn:active { transform: scale(.96); }
.emergency-btn b { font-size: 19px; line-height: 1.1; color: #fff; }
.emergency-foot .emergency-btn b { font-size: 16px; }
.emergency-btn span { font-size: 10px; color: #fff; opacity: .9; margin-top: 2px; }

#reslist { display: grid; gap: 12px; }
.res-card {
  background: var(--card);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  padding: 16px;
  box-shadow: var(--sombra-sm);
}
.res-head { display: flex; gap: 12px; align-items: flex-start; }
.res-ico {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  background: #eef3f8; border-radius: 12px; font-size: 22px;
}
.res-head h3 { font-size: 16px; line-height: 1.25; }
.res-meta { font-size: 12px; color: var(--gris-600); margin-top: 3px; }
.res-cat {
  display: inline-block; font-weight: 700; color: var(--azul-700);
  background: #eaf2fb; padding: 1px 8px; border-radius: 999px; font-size: 11px;
}
.res-desc { font-size: 14px; color: var(--gris-900); margin: 10px 0 12px; }
.res-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.res-act {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f4f9ff; border: 1px solid var(--linea); color: var(--azul-700);
  padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
}
.res-act.tel { background: var(--verde-bg); border-color: #c4e7d6; color: #1d6b4f; }
.res-act:active { transform: scale(.97); }

/* Acceso a recursos desde el inicio */
.help-link {
  display: flex; align-items: center; gap: 10px;
  background: #fff4f4; border: 1px solid #ffd7d7; border-radius: var(--radio-sm);
  padding: 13px 16px; margin-top: 14px; font-weight: 600; color: var(--rojo);
}
.help-link .arrow { margin-left: auto; }
