:root {
  --bg: #1b2733;
  --bg2: #22303d;
  --txt: #eef3f7;
  --muted: #9fb0bd;
  --primary: #e8523f;
  --primary-d: #c63d2c;
  --linea: #33454f;
  --ok: #27ae60;
  --warn: #f1c40f;
  --sombra: 0 6px 24px rgba(0,0,0,.35);
  --radio: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--txt);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: #7fd1ff; }

/* Banner */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1200;
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #2a3b49, #1b2733);
  border-bottom: 1px solid var(--linea);
  padding: 8px 12px; min-height: 52px;
}
.banner__txt { display: flex; flex-direction: column; line-height: 1.25; font-size: .82rem; }
.banner__txt strong { font-size: .95rem; }
.banner__txt span { color: var(--muted); }
.banner__txt b { color: var(--warn); }
.banner__help {
  margin-left: auto; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: #33454f; color: var(--txt); border: 1px solid var(--linea);
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
}

/* Mapa */
#mapa { position: fixed; inset: 52px 0 0 0; background: #2b3a46; }
.leaflet-container { background: #2b3a46; font-family: inherit; }

/* Marcadores tipo gota (teardrop). COLOR = categoría de daño; FORMA = nivel de confianza. */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative;
  width: var(--sz);
  height: calc(var(--sz) * 34 / 24);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.45));
}
.pin__svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pin__path { fill: var(--cat); stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.pin__glyph {
  position: absolute; top: 0; left: 0;
  width: 100%; height: var(--sz);                 /* el círculo superior ≈ cuadrado de lado sz */
  display: grid; place-items: center;
  font-size: calc(var(--sz) * .46); line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 2px #fff, 0 1px 2px rgba(0,0,0,.45);  /* halo: legible sobre cualquier color */
}
/* Verificado (8–10): inconfundible — borde más grueso, brillo y sello ✓. */
.pin--verificado .pin__path { stroke-width: 2.6; }
.pin--verificado { filter: drop-shadow(0 0 5px rgba(255,255,255,.65)) drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.pin--verificado::after {
  content: '✓'; position: absolute; top: -2px; right: -2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #1f8f4e; color: #fff; font-size: 10px; font-weight: 900;
  display: grid; place-items: center; border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
/* Comunidad (con confirmaciones): sólido, sin el anillo de verificado. */
.pin--comunidad .pin__path { stroke-width: 2.2; }
/* No verificado: borde punteado = señal clara de "sin confirmar". */
.pin--no_verificado .pin__path { stroke-dasharray: 3 2.4; stroke-width: 1.9; }
/* Ubicación aproximada: refuerza el punteado del borde. */
.pin--aprox .pin__path { stroke-dasharray: 2.6 2; }
/* Fe de vida (rescate): realce estático fuerte (anillo + brillo rojo) para destacar. */
.pin--sos { filter: drop-shadow(0 0 6px rgba(255,45,85,.9)) drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
.pin--sos .pin__path { stroke-width: 2.8; }
.pin--dup { opacity: .5; }

/* Globo de agrupación (cluster): neutro, con el conteo. No usa color de categoría para no
   confundirse con un tipo de daño; comunica "varios reportes aquí, acércate para verlos". */
.cl-wrap { background: none !important; }
.cl {
  width: var(--s); height: var(--s);
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #44596b, #202d39);
  border: 2px solid rgba(255,255,255,.9);
  color: #fff; font-weight: 800; font-size: calc(var(--s) * .36); line-height: 1;
  box-shadow: 0 3px 9px rgba(0,0,0,.5), 0 0 0 4px rgba(68,89,107,.28);
}
/* Anula el estilo verde/amarillo por defecto del plugin (usamos el nuestro). */
.marker-cluster, .marker-cluster div { background: none !important; }
.marker-cluster { width: auto !important; height: auto !important; }

/* Cluster de la capa de DAÑO satelital (HOT): rojizo, distinto del cluster neutro de reportes,
   para que no se confunda "daño detectado por IA" con "reportes ciudadanos". */
.cl-dano {
  width: var(--s); height: var(--s); display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #b4321e, #6d1410);
  border: 2px solid rgba(255,255,255,.92);
  color: #fff; font-weight: 800; font-size: calc(var(--s) * .34); line-height: 1;
  box-shadow: 0 3px 9px rgba(0,0,0,.5), 0 0 0 4px rgba(180,50,30,.25);
}
/* Leyenda de la capa de daño */
.leyenda-dano {
  background: rgba(20,28,36,.92); color: #eaf0f6; border-radius: 10px; padding: 9px 11px;
  font-size: .76rem; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,.45); max-width: 220px;
}
.leyenda-dano .ld-tit { font-weight: 800; margin-bottom: 4px; font-size: .82rem; }
.leyenda-dano .ld-row { display: flex; align-items: center; gap: 7px; }
.leyenda-dano .ld-row i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,.7); flex: none; }
.leyenda-dano .ld-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.leyenda-dano .ld-pie { margin-top: 5px; opacity: .85; font-style: italic; }
.leyenda-dano .ld-fuente { margin-top: 3px; opacity: .6; font-size: .68rem; }
/* Botón "Reportar este edificio" dentro del popup de un punto de daño */
.dano-reportar {
  margin-top: 8px; width: 100%; border: none; border-radius: 8px; cursor: pointer;
  padding: 8px 10px; font-weight: 700; font-size: .82rem; color: #fff;
  background: var(--primary, #b4321e);
}
.dano-reportar:hover { filter: brightness(1.08); }
/* Pin de persona buscada (desaparecida) */
.pin-buscada {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #7c3aed, #4c1d95);
  border: 2px solid #fff; box-shadow: 0 2px 7px rgba(0,0,0,.5); font-size: 14px;
}
/* Aviso de coincidencia con la lista de desaparecidos, dentro del formulario */
.match-aviso {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: .82rem; font-weight: 600;
  background: #14351f; border: 1px solid #1f7a4d; color: #b8f0cf;
}
.op { font-weight: 400; opacity: .7; }

/* Botones flotantes */
.fab-col { position: fixed; right: 14px; bottom: 18px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.fab {
  border: none; border-radius: 28px; cursor: pointer; font-size: 1rem; font-weight: 700;
  box-shadow: var(--sombra); color: #fff;
}
.fab--primary { background: var(--primary); padding: 14px 20px; }
.fab--primary:active { background: var(--primary-d); }
.fab--ghost { width: 48px; height: 48px; background: #2a3b49; border: 1px solid var(--linea); color: var(--txt); font-size: 1.3rem; }

/* Leyenda */
.leyenda-toggle {
  position: fixed; left: 14px; bottom: 18px; z-index: 1100;
  background: #2a3b49; color: var(--txt); border: 1px solid var(--linea);
  border-radius: 20px; padding: 9px 14px; font-size: .85rem; font-weight: 600; cursor: pointer; box-shadow: var(--sombra);
}
.leyenda {
  position: fixed; left: 14px; bottom: 64px; z-index: 1100; width: min(86vw, 320px);
  background: var(--bg2); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 14px 16px; box-shadow: var(--sombra); font-size: .85rem;
}
.leyenda h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 7px; }
.leyenda h2:first-child { margin-top: 0; }
.leyenda ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.leyenda__tipos { grid-template-columns: 1fr 1fr; }
.leyenda__conf { font-size: .82rem; line-height: 1.3; }
.leyenda__conf li { display: flex; align-items: flex-start; gap: 7px; }
/* Chips de filtro por tipo */
.chip {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: #1f2c38; color: var(--txt); border: 1px solid var(--linea);
  border-radius: 9px; padding: 7px 8px; font: inherit; font-size: .8rem; cursor: pointer;
  text-align: left; transition: opacity .12s, border-color .12s, background .12s;
}
.chip:hover { border-color: #4a5e6b; }
.chip__dot {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--cat); border: 1.5px solid rgba(255,255,255,.85);
  display: grid; place-items: center; font-size: .7rem; line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.chip--off { opacity: .42; background: #18222b; }
.chip--off .chip__dot { filter: grayscale(1); }
/* Ejemplos de confianza en la leyenda */
.ej { flex: none; width: 16px; height: 16px; border-radius: 50%; margin-top: 1px; display: grid; place-items: center; font-size: 9px; font-weight: 900; }
.ej--v { background: #2fb56a; color: #fff; border: 2px solid #fff; box-shadow: 0 0 4px rgba(255,255,255,.5); }
.ej--nv { background: transparent; border: 2px dashed var(--muted); }
.leyenda__nota { color: var(--muted); margin: 12px 0 0; font-size: .8rem; line-height: 1.35; }

/* Modales y paneles */
.modal, .panel {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(8,12,16,.72); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.panel { align-items: flex-end; }
.modal__caja, .panel__caja {
  background: var(--bg2); border: 1px solid var(--linea); border-radius: 18px;
  width: min(540px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: var(--sombra); padding: 20px;
}
.panel__caja { border-radius: 18px 18px 0 0; padding: 16px 18px 24px; }
.modal__caja h1 { margin: 0 0 10px; font-size: 1.4rem; }
.aviso__lista { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; font-size: .95rem; line-height: 1.35; }
.aviso__desap { background: #1f2c38; border: 1px solid var(--linea); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel__head h2 { margin: 0; font-size: 1.2rem; }
.panel__x { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; }

/* Selector de modo de reporte (sobreviviente / víctima) */
.modo-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.modo-tab {
  border: 1px solid var(--linea); background: #1b2733; color: var(--txt); border-radius: 10px;
  padding: 12px 8px; font-weight: 700; font-size: .92rem; cursor: pointer; line-height: 1.25;
}
.modo-tab.activo { border-color: var(--primary); background: #33272a; box-shadow: 0 0 0 1px var(--primary) inset; }
.modo-tab:focus-visible { outline: 2px solid #7fd1ff; }

/* Formulario */
.form__campo { border: none; padding: 0; margin: 0 0 18px; }
.form__campo legend { font-weight: 700; font-size: .95rem; padding: 0; margin-bottom: 8px; color: var(--txt); }
.ubic-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.ubic-estado { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }
.ubic-estado.ok { color: var(--ok); font-weight: 600; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cats label { position: relative; }
.cats input { position: absolute; opacity: 0; }
.cats span {
  display: block; padding: 11px 10px; border: 1px solid var(--linea); border-radius: 10px;
  background: #1f2c38; font-size: .9rem; cursor: pointer; text-align: center;
}
.cats--2 { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.rescate-q { font-size: .9rem; margin: 12px 0 6px; color: var(--txt); }
input[type="tel"], #repEquipoCual { width: 100%; background: #1f2c38; color: var(--txt); border: 1px solid var(--linea); border-radius: 10px; padding: 11px; font: inherit; font-size: .95rem; margin-bottom: 8px; }
.cats input:checked + span { border-color: var(--primary); background: #33272a; box-shadow: 0 0 0 1px var(--primary) inset; }
.cats input:focus-visible + span { outline: 2px solid #7fd1ff; }
textarea {
  width: 100%; background: #1f2c38; color: var(--txt); border: 1px solid var(--linea);
  border-radius: 10px; padding: 10px; font: inherit; font-size: .95rem; resize: vertical;
}
.pii-aviso { color: var(--warn); font-size: .85rem; margin: 8px 0 0; line-height: 1.3; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form__nota { color: var(--muted); font-size: .82rem; margin: 10px 0 0; line-height: 1.35; }

/* Botones */
.btn { border: none; border-radius: 11px; padding: 13px 18px; font: inherit; font-weight: 700; cursor: pointer; }
.btn--primary { background: var(--primary); color: #fff; width: 100%; font-size: 1.02rem; }
.btn--primary:disabled { background: #4a3a38; color: #9b8b88; cursor: not-allowed; }
.btn--primary:active:not(:disabled) { background: var(--primary-d); }
.btn--mini { background: #2a3b49; color: var(--txt); border: 1px solid var(--linea); padding: 11px 14px; font-size: .9rem; flex: 1; }
.btn--mini.activo { border-color: var(--primary); background: #33272a; }

/* Popup */
.leaflet-popup-content-wrapper { background: var(--bg2); color: var(--txt); border-radius: 12px; }
.leaflet-popup-tip { background: var(--bg2); }
.leaflet-popup-content { margin: 12px 14px; font-size: .9rem; line-height: 1.4; min-width: 210px; }
.pop__badge { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .03em; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; }
.pop__badge--nv { background: #57606a; color: #fff; }
.pop__badge--v { background: var(--primary); color: #fff; }
.pop__tit { font-weight: 700; font-size: 1rem; margin: 8px 0 2px; }
.pop__meta { color: var(--muted); font-size: .82rem; margin: 2px 0; }
.pop__desc { margin: 8px 0; }
.pop__aprox { color: var(--warn); font-size: .78rem; }
.pop__votos { display: flex; gap: 8px; margin-top: 10px; }
.pop__votos button { flex: 1; border: 1px solid var(--linea); background: #1f2c38; color: var(--txt); border-radius: 9px; padding: 9px; font-weight: 700; cursor: pointer; font-size: .85rem; }
.pop__votos .si:active { background: #1d3a28; border-color: var(--ok); }
.pop__votos .no:active { background: #3a1d1d; }
.pop__conteo { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.pop__testigos { font-size: .82rem; color: #6fc28a; font-weight: 600; margin: 6px 0; }
.pop__dup { font-size: .8rem; color: var(--muted); font-style: italic; margin: 4px 0; }

/* Lista */
.lista { display: grid; gap: 16px; }
.lista__sector h3 { margin: 0 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--linea); padding-bottom: 5px; }
.lista__item { background: #1f2c38; border: 1px solid var(--linea); border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; }
.lista__item h4 { margin: 0 0 3px; font-size: .95rem; display: flex; align-items: center; gap: 7px; }
.lista__item .pop__meta { margin: 3px 0; }
.lista__votos { display: flex; gap: 8px; margin-top: 8px; }
.lista__votos button { flex: 1; border: 1px solid var(--linea); background: #25323e; color: var(--txt); border-radius: 8px; padding: 8px; font-weight: 700; cursor: pointer; font-size: .82rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 2000;
  background: #11181f; color: #fff; border: 1px solid var(--linea); border-radius: 10px;
  padding: 11px 16px; font-size: .9rem; box-shadow: var(--sombra); max-width: 90vw; text-align: center;
}
.toast--ok { border-color: var(--ok); }
.toast--err { border-color: var(--primary); }

@media (min-width: 720px) {
  .panel { align-items: center; }
  .panel__caja { border-radius: 18px; }
  .cats { grid-template-columns: 1fr 1fr 1fr; }
}
