/* ============================================================
   MAPA DEL DELITO — PARTIDO DE LA COSTA
   Rediseño estético (rama rediseno-v2): controles flotantes
   sobre el mapa, jerarquía más clara, acabado sobrio. Sin
   cambios de funcionalidad ni de estructura.
   ============================================================ */

:root {
  --bg: #141416;
  --rail: #17171a;
  --panel: #1c1c1f;
  --panel-2: #232327;
  --panel-3: #2c2c31;
  --line: #33333a;
  --line-soft: #26262b;
  --edge: rgba(255, 255, 255, .07);       /* borde sobre superficies con blur */
  --glass: rgba(22, 22, 25, .84);         /* panel translúcido flotante */
  --glass-2: rgba(28, 28, 32, .9);
  --text: #edecef;
  --muted: #9a9aa4;
  --muted-2: #74747e;
  --accent: #4d8dfd;
  --accent-hover: #6a9efd;
  --accent-soft: rgba(77, 141, 253, .16);
  --accent-ring: rgba(77, 141, 253, .38);
  --ok: #35b877;
  --warn: #e0a13a;
  --danger: #e05757;
  --radius: 14px;
  --radius-sm: 10px;
  --rail-w: 60px;
  --rail-h: 58px;
  --drawer-w: 340px;
  --shadow-float: 0 10px 34px rgba(0, 0, 0, .40), 0 2px 8px rgba(0, 0, 0, .28);
  --shadow-panel: 0 18px 56px rgba(0, 0, 0, .52), 0 3px 12px rgba(0, 0, 0, .3);
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.01em; }

button {
  font: inherit;
  transition: background .14s var(--ease), border-color .14s var(--ease),
              color .12s ease, transform .06s ease, box-shadow .14s var(--ease);
}

.ic {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

.muted { color: var(--muted); }

/* ============================================================
   LAYOUT — barra superior + rail flotante + escenario del mapa
   ============================================================ */

.shell { display: flex; flex-direction: column; height: 100%; }
.app { display: flex; flex: 1; min-height: 0; position: relative; }

/* ---- barra superior: marca + buscador de direcciones ---- */
.topbar {
  position: relative;
  z-index: 20;
  flex: none;
  display: flex; align-items: center; gap: 14px;
  background: var(--rail);
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 14px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex: none; }
.topbar-brand:hover { text-decoration: none; }
.topbar-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.topbar-mark .ic { width: 15px; height: 15px; stroke-width: 1.8; }
.topbar-name { display: flex; flex-direction: column; line-height: 1.12; }
.topbar-name strong { color: var(--text); font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.topbar-name em {
  color: var(--muted-2); font-style: normal;
  font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase;
}

.topbar-search {
  position: relative;
  display: flex; align-items: center;
  width: 300px; flex: none; height: 34px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0 5px 0 11px;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-search .tb-search-ic { width: 15px; height: 15px; color: var(--muted-2); }
.topbar-search #btn-geo {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: transparent; border: 0; color: var(--muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.topbar-search #btn-geo:hover { color: var(--text); background: var(--panel-3); }
.topbar-search #btn-geo:active { transform: scale(.92); }
.topbar-search #btn-geo .ic { width: 15px; height: 15px; }
.topbar-search #btn-geo.loading { opacity: .5; }

/* ---- rail: flota sobre el mapa ---- */
.rail {
  position: absolute;
  left: 12px; top: 12px; bottom: 12px;
  width: var(--rail-w);
  z-index: 40;
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 10px;
  gap: 3px;
}
.rail-spacer { flex: 1; }

.rail-btn {
  position: relative;
  width: 48px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: 0;
  color: var(--muted);
  padding: 8px 2px 6px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1;
}
.rail-btn span { font-size: 9px; font-weight: 500; letter-spacing: .01em; }
.rail-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.rail-btn:active { transform: scale(.94); }
.rail-btn.active { color: var(--text); background: var(--accent-soft); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; background: var(--accent); border-radius: 3px;
}
.rail-primary { color: var(--accent); }
.rail-primary .ic {
  background: var(--accent); color: #fff;
  width: 34px; height: 34px; border-radius: 11px; padding: 6px;
  box-shadow: 0 4px 14px rgba(77, 141, 253, .4);
  transition: background .14s var(--ease), box-shadow .14s var(--ease);
}
.rail-primary:hover { background: transparent; }
.rail-primary:hover .ic { background: var(--accent-hover); box-shadow: 0 5px 18px rgba(77, 141, 253, .5); }
.rail-primary span { color: var(--muted); }

.stage { position: relative; flex: 1; overflow: hidden; isolation: isolate; }
#map, #admin-map { position: absolute; inset: 0; }
.stage #map { z-index: 0; }

/* ============================================================
   PANELES LATERALES (drawers) — flotan sobre el mapa
   ============================================================ */

.drawer {
  position: absolute;
  top: 12px;
  left: calc(var(--rail-w) + 32px);
  width: var(--drawer-w);
  max-width: calc(100vw - var(--rail-w) - 48px);
  height: auto;
  max-height: calc(100% - 24px);
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: var(--shadow-panel);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-in .22s var(--ease);
}
@keyframes drawer-in {
  from { transform: translateX(-10px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.drawer-head strong { font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.drawer-close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--muted); cursor: pointer;
}
.drawer-close:hover { background: var(--panel-3); color: var(--text); }
.drawer-close:active { transform: scale(.92); }
.drawer-close .ic { width: 17px; height: 17px; }
.drawer-body { overflow-y: auto; flex: 0 1 auto; min-height: 0; padding: 12px 14px 16px; }
.drawer-foot {
  color: var(--muted-2); font-size: 10.5px; line-height: 1.4;
  padding: 9px 14px 13px; margin: 0; border-top: 1px solid var(--line-soft);
}
.drawer-label {
  font-size: 10.5px; font-weight: 600; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 16px 2px 8px;
}
.drawer-label:first-child { margin-top: 2px; }
.drawer-count { margin: 14px 2px 0; }

/* filtros de categoría */
#cat-filters { display: flex; flex-direction: column; gap: 2px; }
.mdd-chk {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; cursor: pointer; user-select: none;
  padding: 8px 9px; border-radius: var(--radius-sm);
  transition: background .12s ease;
}
.mdd-chk:hover { background: var(--panel-2); }
.mdd-chk:has(input:checked) { background: rgba(255, 255, 255, .035); }
.mdd-chk input {
  width: 16px; height: 16px; accent-color: var(--accent);
  flex: none; cursor: pointer;
}
.mdd-chk .dot {
  width: 9px; height: 9px; border-radius: 3px;
  display: inline-block; flex: none; opacity: .9;
}
.mdd-chk:has(input:not(:checked)) { color: var(--muted); }
.mdd-chk:has(input:not(:checked)) .dot { opacity: .3; }

select, input[type="datetime-local"], textarea {
  background-color: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit; line-height: 1.25;
}
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 100%; height: 38px; padding: 0 34px 0 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%2397979f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  background-size: 12px 12px;
}
select::-ms-expand { display: none; }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#count {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 13px; font-size: 12.5px; color: var(--text);
}
#count::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* buscador de direcciones (vive en la barra superior) */
#addr-search {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 12.5px; padding: 0 8px;
}
#addr-search::placeholder { color: var(--muted-2); }
#addr-results {
  position: absolute; left: -1px; right: -1px; top: calc(100% + 6px);
  list-style: none; margin: 0; padding: 5px;
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--edge);
  border-radius: var(--radius); max-height: 60vh; overflow: auto;
  box-shadow: var(--shadow-float); z-index: 60;
}
#addr-results li {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .1s ease;
}
#addr-results li:hover, #addr-results li.active { background: var(--panel-3); }
#addr-results li.empty { color: var(--muted); cursor: default; font-size: 12.5px; line-height: 1.4; }

/* ============================================================
   CATÁLOGO DE CAPAS (menú "Capas", dos niveles)
   ============================================================ */

#capas-badge {
  margin-left: auto; margin-right: 6px;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px;
}

/* "apagar" / "apagar todas": junto al número, para sacar todas las capas
   prendidas de una. Sutil a propósito, no es una acción frecuente. */
.capas-clear {
  background: transparent; border: 0; margin-right: 4px;
  color: var(--muted-2); font: inherit; font-size: 10.5px; font-weight: 400;
  cursor: pointer; padding: 4px 2px;
  text-decoration: underline; text-decoration-color: var(--line);
  text-underline-offset: 2px;
}
.capas-clear:hover { color: var(--muted); text-decoration-color: var(--muted); }

.capas-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.capas-search .ic { width: 16px; height: 16px; color: var(--muted-2); flex: none; }
#capas-q {
  flex: 1; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
  font: inherit; font-size: 13px;
}
#capas-q:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* nivel 1: categorías */
.cat-cat {
  display: flex; flex-direction: column; gap: 3px;
  width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 12px 13px; margin-bottom: 8px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.cat-cat:hover { border-color: var(--line); background: var(--panel-3); }
.cat-cat:active { transform: scale(.99); }
.cat-cat-tit { font-size: 14px; font-weight: 600; }
.cat-cat-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

/* nivel 2: capas de la categoría */
.cat-capa {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 11px 12px; margin-bottom: 7px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.cat-capa:hover { border-color: var(--line); background: var(--panel-3); }
.cat-capa-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; opacity: .9; }
.cat-capa-tit { flex: 1; font-size: 13.5px; }
.cat-capa-sw {
  width: 34px; height: 19px; border-radius: 999px; flex: none;
  background: var(--line); border: 1px solid var(--line); position: relative;
  transition: background .16s var(--ease);
}
.cat-capa-sw::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 15px; height: 15px; border-radius: 50%; background: var(--muted);
  transition: transform .16s var(--ease), background .16s var(--ease);
}
.cat-capa.on { border-color: var(--accent); background: var(--accent-soft); }
.cat-capa.on .cat-capa-sw { background: var(--accent); }
.cat-capa.on .cat-capa-sw::after { transform: translateX(15px); background: #fff; }
.cat-capa.loading { opacity: .55; pointer-events: none; }

/* desplegable de tarjetas debajo de una capa prendida */
.cat-capa-cards { margin: -2px 0 9px; padding-left: 8px; }
.cat-cards-toggle {
  width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--muted);
  font: inherit; font-size: 12px; padding: 5px 4px 7px; cursor: pointer;
}
.cat-cards-toggle::before { content: "\25B8  "; }
.cat-cards-toggle.open::before { content: "\25BE  "; }
.cat-cards-toggle:hover { color: var(--text); }
.cat-card {
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--muted-2);
  border-radius: 9px; padding: 9px 11px; margin-bottom: 6px; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.cat-card:hover { border-color: var(--accent); background: var(--panel-3); }
.cat-card-name { font-size: 13px; font-weight: 600; margin: 0; }
.cat-card-sub { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; }
.cat-card-dir { font-size: 12px; color: var(--text); margin: 3px 0 0; }
.cat-card-tel { font-size: 12.5px; color: var(--text); margin: 3px 0 0; }
.cat-card-tel a { color: var(--accent); }

/* ============================================================
   LISTA DE REPORTES
   ============================================================ */

#lp-list { display: flex; flex-direction: column; gap: 8px; }
.lp-group {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: 0;
  color: var(--muted); font: inherit; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 4px 6px; cursor: pointer; margin-top: 4px;
}
.lp-group:first-child { margin-top: 0; }
.lp-group:hover { color: var(--text); }
.lp-group::before { content: "\25BE "; color: var(--muted-2); margin-right: 6px; font-size: 10px; }
.lp-group.collapsed::before { content: "\25B8 "; }
.lp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; opacity: .95; margin-right: 8px; vertical-align: middle; }
.lp-group-n {
  background: var(--panel-2); color: var(--muted); font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; letter-spacing: 0;
}
.lp-card {
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--muted-2);
  border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer; user-select: none;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.lp-card:hover { border-color: var(--accent); background: var(--panel-3); }
.lp-card:active { transform: scale(.99); }
.lp-card .lp-addr { font-size: 13.5px; margin: 0 0 3px; color: var(--text); font-weight: 600; letter-spacing: -.005em; }
.lp-card .lp-when { color: var(--muted-2); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 6px; }
.lp-card .lp-desc { font-size: 13px; line-height: 1.45; color: var(--text); }
.lp-card .lp-note { color: var(--muted-2); font-size: 10.5px; font-style: normal; margin: 7px 0 0; }
.lp-empty { color: var(--muted); font-size: 13px; padding: 14px 4px; line-height: 1.5; }

/* subtítulo (período) y línea legal: sólo se ven en la hoja de celular */
.lp-sub { display: none; }
.lp-legal { display: none; margin: 0; }

/* info */
.info-disclaimer {
  font-size: 13px; line-height: 1.55; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); padding: 12px 13px; margin: 2px 0 16px;
}
.info-links { display: flex; flex-direction: column; gap: 1px; }
.info-links a {
  display: block; padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
  transition: background .12s ease;
}
.info-links a:hover { background: var(--panel-2); text-decoration: none; }
.info-src { color: var(--muted-2); font-size: 11px; line-height: 1.5; margin: 16px 2px 0; }

/* ============================================================
   FLOTANTES SOBRE EL MAPA
   ============================================================ */

.legal-mini {
  position: absolute;
  left: calc(var(--rail-w) + 24px);       /* al costado del rail flotante, no debajo */
  bottom: 12px;
  margin: 0;
  font-size: 10.5px; color: var(--muted);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--edge);
  padding: 5px 12px; border-radius: 999px;
  pointer-events: none;
  z-index: 20;
}

#place-hint {
  position: absolute;
  bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 45;
  background: var(--accent); color: #fff;
  padding: 10px 12px 10px 18px; border-radius: 999px;
  font-size: 14px; display: flex; gap: 12px; align-items: center;
  white-space: nowrap; box-shadow: 0 8px 26px rgba(77, 141, 253, .45);
  max-width: calc(100vw - 24px);
  animation: hint-in .22s var(--ease);
}
@keyframes hint-in { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
#place-hint button {
  background: #fff; border: 0; color: #1a1a1a; font-weight: 600;
  border-radius: 999px; padding: 8px 16px; cursor: pointer; flex: none;
}
#place-hint button:active { transform: scale(.95); }
body.placing #map { cursor: crosshair; }

#toast {
  position: fixed;
  bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--edge); color: var(--text);
  padding: 11px 16px; border-radius: var(--radius); z-index: 1200; font-size: 13px;
  box-shadow: var(--shadow-panel);
  animation: hint-in .22s var(--ease);
}

/* ============================================================
   PINES Y POPUP
   ============================================================ */

.mdd-pin span, .cat-pin span {
  display: block; border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .45);
  transition: transform .13s var(--ease), box-shadow .13s var(--ease);
}
.mdd-pin span { width: 17px; height: 17px; }
.cat-pin span { width: 15px; height: 15px; }
.mdd-pin:hover span, .cat-pin:hover span { transform: scale(1.18); }

/* marcador seleccionado (clase que agrega map-common al abrir su globo) */
.leaflet-marker-icon.mdd-sel { z-index: 1000 !important; }
.mdd-pin.mdd-sel span, .cat-pin.mdd-sel span {
  transform: scale(1.42);
  box-shadow: 0 0 0 4px var(--accent-ring), 0 0 0 1px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .5);
}

.mdd-popup { min-width: 196px; }
.mdd-tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}
.mdd-popup .mdd-addr { margin: 9px 0 3px; color: var(--text); font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; }
.mdd-popup .srv-name { font-weight: 600; margin: 9px 0 3px; color: var(--text); font-size: 14px; }
.mdd-popup .mdd-when { margin: 3px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.mdd-popup .mdd-desc { margin: 7px 0 0; color: var(--text); font-size: 13px; line-height: 1.45; }
.mdd-popup .mdd-note { margin: 8px 0 0; color: var(--muted-2); font-size: 10.5px; font-style: normal; line-height: 1.4; }
.mdd-popup .srv-tel { margin: 5px 0 0; font-size: 13px; color: var(--text); }
.mdd-popup .srv-tel a { color: var(--accent); }

.leaflet-popup-content-wrapper {
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
}
.leaflet-popup-tip { background: var(--glass-2); border: 1px solid var(--edge); }
.leaflet-popup-content { margin: 14px 16px; }
/* la "×" de cerrar: separada de la esquina y con área de toque cómoda */
.leaflet-popup-close-button {
  top: 7px !important; right: 8px !important;
  width: 26px !important; height: 26px !important;
  line-height: 26px !important;
  border-radius: 8px !important;
  color: var(--muted) !important;
  transition: background .12s ease, color .12s ease;
}
.leaflet-popup-close-button:hover {
  color: var(--text) !important;
  background: var(--panel-3) !important;
}
/* que el texto no pase por debajo de la × */
.leaflet-popup-content .mdd-popup { padding-right: 14px; }

.you-are-here {
  width: 15px; height: 15px; background: var(--accent);
  border: 3px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 5px var(--accent-ring);
}
.search-pin { font-size: 24px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }

/* ============================================================
   BOTONES + MODALES + FORMULARIO
   ============================================================ */

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: #43434c; background: var(--panel-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 3px 14px rgba(77, 141, 253, .32);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 18px rgba(77, 141, 253, .42); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1a1a; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.armed { outline: 2px solid #fff; outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: default; }

.modal {
  position: fixed; inset: 0;
  background: rgba(6, 6, 8, .66);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
  animation: fade-in .16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; width: 100%; max-width: 440px; max-height: 90vh;
  overflow: auto; padding: 20px 20px 22px;
  box-shadow: var(--shadow-panel);
  animation: modal-in .22s var(--ease);
}
@keyframes modal-in { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h2 { margin: 0 0 12px; font-size: 18px; }
.modal-box label.field { display: block; margin: 14px 0 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.modal-box select, .modal-box textarea, .modal-box input[type="datetime-local"] { width: 100%; }
.modal-box textarea { min-height: 92px; resize: vertical; }
.close-x {
  float: right; background: transparent; border: 0; color: var(--muted);
  cursor: pointer; line-height: 1; display: flex; padding: 2px; border-radius: 6px;
}
.close-x:hover { color: var(--text); }
.close-x .ic { width: 20px; height: 20px; }

.row-between { display: flex; justify-content: space-between; align-items: center; }
.help { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.rules { font-size: 12px; color: var(--warn); margin: 10px 0; }
#f-charcount { font-size: 12px; color: var(--muted); }
#f-coords { font-size: 12px; color: var(--muted); margin: 8px 0; }
.check-line { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; font-size: 13px; }
.check-line input { margin-top: 3px; accent-color: var(--accent); }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; }
#captcha-slot { margin: 12px 0 4px; min-height: 0; }
#captcha-slot:not(:empty) { min-height: 65px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
#form-errors .msg { margin: 6px 0; font-size: 13px; padding: 8px 10px; border-radius: 8px; }
.msg.err { background: rgba(224, 87, 87, .16); color: #ff9d9d; }
.msg.warn { background: rgba(224, 161, 58, .16); color: #ffce85; }

/* ============================================================
   LEAFLET — zoom flotante abajo a la derecha, al tono oscuro
   ============================================================ */

/* mover el control de zoom (único control en la esquina sup-izq) a abajo-derecha */
.leaflet-top.leaflet-left { top: auto; bottom: 0; left: auto; right: 0; }
.leaflet-top.leaflet-left .leaflet-control { margin: 0 14px 34px 0 !important; }

.leaflet-bar {
  border: 1px solid var(--edge) !important;
  border-radius: 12px !important; overflow: hidden;
  box-shadow: var(--shadow-float) !important;
}
.leaflet-bar a {
  background: var(--glass) !important; color: var(--text) !important;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--edge) !important;
  width: 32px !important; height: 32px !important; line-height: 32px !important;
  font-size: 17px !important;
}
.leaflet-bar a:hover { background: var(--panel-3) !important; }
.leaflet-bar a:last-child { border-bottom: 0 !important; }
.leaflet-control-attribution {
  background: rgba(18, 18, 20, .7) !important; color: var(--muted-2) !important;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border-radius: 6px 0 0 0; font-size: 10px !important;
}
.leaflet-control-attribution a { color: #8fa8cc !important; }

/* ============================================================
   RESPONSIVE — CELULAR (rail flotante abajo)
   ============================================================ */

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .topbar-search { width: 100%; height: 36px; }

  .rail {
    left: 10px; right: 10px; bottom: 10px; top: auto;
    width: auto; height: var(--rail-h);
    flex-direction: row; justify-content: space-around; align-items: center;
    padding: 0 6px; border-radius: 16px; gap: 0;
  }
  .rail-spacer { display: none; }
  .rail-btn { width: auto; flex: 1; max-width: 78px; padding: 6px 2px 5px; }
  .rail-btn.active::before {
    left: 50%; top: 4px; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 3px;
  }
  .rail-primary .ic { width: 30px; height: 30px; }

  .drawer {
    left: 10px; right: 10px; top: auto;
    bottom: calc(var(--rail-h) + 28px);
    width: auto; max-width: none;
    height: auto; max-height: calc(100% - var(--rail-h) - 44px);
    border-radius: 18px;
    animation: sheet-in .24s var(--ease);
  }
  @keyframes sheet-in {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }

  /* la línea legal pasa al pie de la hoja; el zoom sube a la esquina
     superior derecha para no quedar tapado por la hoja */
  .legal-mini { display: none; }
  #place-hint { bottom: calc(var(--rail-h) + 26px); }
  .leaflet-top.leaflet-left { top: 0; bottom: auto; }
  .leaflet-top.leaflet-left .leaflet-control { margin: 12px 12px 0 0 !important; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; }

  /* ---- reportes, filtros y capas = hoja inferior arrastrable ---- */
  .drawer.sheet {
    max-height: calc(100% - 88px);       /* la altura fina la maneja el JS */
    transition: height .28s var(--ease);
    will-change: height;
  }
  .drawer.sheet.dragging { transition: none; }

  .sheet-head {
    position: relative;
    padding-top: 20px;
    cursor: grab;
    touch-action: none;
    flex-wrap: wrap;
  }
  .sheet-head::before {
    content: ""; position: absolute; top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 999px;
    background: var(--line);
  }
  .sheet-head:active::before { background: var(--muted-2); }
  #lp-head #lp-close { display: none; }   /* la de reportes no tiene "cerrar": se arrastra */

  .lp-sub {
    display: inline-block; margin-left: 8px;
    color: var(--muted-2); font-size: 11px; font-weight: 500;
    text-transform: uppercase; letter-spacing: .03em;
  }
  .lp-legal {
    display: block; flex: none;
    padding: 9px 14px 11px; margin: 0;
    border-top: 1px solid var(--line-soft);
    color: var(--muted-2); font-size: 10px; line-height: 1.4;
  }
}

/* ============================================================
   PANEL DE MODERACIÓN
   ============================================================ */

.admin { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.admin h1 { font-size: 18px; }

.login-card {
  max-width: 360px; margin: 60px auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.login-card input { width: 100%; margin: 6px 0 12px; }
#login-error { color: #ff9d9d; font-size: 13px; min-height: 18px; }

.panel-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-top .spacer { flex: 1; }
#mode-label { font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 6px; margin: 14px 0; }
.tab {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .panel-grid { grid-template-columns: 1fr; } }
#admin-map { position: relative; height: 320px; border-radius: var(--radius); }

#report-list { display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow: auto; }
.rcard {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; user-select: none;
}
.rcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rcard-status { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rcard-status.s-approved { color: var(--ok); }
.rcard-status.s-rejected { color: var(--danger); }
.rcard-desc { margin: 6px 0; }
.rcard-meta { margin: 2px 0; font-size: 12px; color: var(--muted); }
.rcard-meta.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.rcard-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rcard-actions .btn { padding: 5px 10px; font-size: 13px; }
.backlink { font-size: 13px; }

.tools-box {
  margin-top: 18px; padding: 12px 14px;
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
}
.tools-box h3 { margin: 0 0 4px; font-size: 13px; }
.tools-box p { margin: 4px 0 10px; font-size: 12px; color: var(--muted); }
.tools-box .btn { padding: 6px 12px; font-size: 13px; margin-right: 6px; }

/* ============================================================
   PÁGINAS DE TEXTO (cómo funciona / términos / privacidad)
   ============================================================ */

.doc { max-width: 720px; margin: 0 auto; padding: 28px 18px 80px; }
.doc h1 { font-size: 22px; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 8px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { color: var(--text); }
.doc .lead { color: var(--muted); margin-top: 0; }
.doc ul { padding-left: 20px; }
.doc li { margin: 5px 0; }
.doc .note {
  background: rgba(224, 161, 58, .12); border-left: 3px solid var(--warn);
  padding: 10px 12px; border-radius: 6px; font-size: 13.5px; color: #ffce85; margin: 16px 0;
}
.doc .updated { font-size: 12px; color: var(--muted); }
.doc .back { display: inline-block; margin-bottom: 18px; font-size: 13px; }
.doc .cat-legend { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.doc .cat-legend .row { display: flex; gap: 10px; align-items: baseline; }
.doc .cat-legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; position: relative; top: 1px; }
