:root {
  --bg: #f8fafc; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #f59e0b; --brand-d: #b45309; --brand-ink: #1f1300;
  --leve: #eab308; --mod: #f97316; --pel: #dc2626; --ok: #16a34a; --info: #2563eb;
  --shadow: 0 6px 20px rgba(15, 23, 42, .18); --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #111a2e; --text: #e5e7eb; --muted: #94a3b8; --line: #22304a; --shadow: 0 6px 20px rgba(0, 0, 0, .55); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Encabezado */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.brand { flex: 1; min-width: 0; }
.brand b { font-size: 17px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; opacity: .8; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-size: 26px; }
.banner { background: #fef3c7; color: #78350f; font-size: 12.5px; padding: 6px 12px; text-align: center; border-bottom: 1px solid #fde68a; }
.sponsor { background: #1f2937; color: #fde68a; font-size: 12.5px; padding: 6px 12px; text-align: center; }
.sponsor a { color: #fff; font-weight: 600; }

/* Estructura */
main { flex: 1; position: relative; min-height: 0; }
.view { position: absolute; inset: 0; overflow: auto; display: none; }
.view.active { display: block; }
#view-map { overflow: hidden; }
#map { position: absolute; inset: 0; z-index: 0; }
.pad { padding: 14px; max-width: 760px; margin: 0 auto; }
.nav { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { background: none; border: 0; padding: 8px 4px 7px; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.nav button span { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--brand-d); font-weight: 700; }
@media (prefers-color-scheme: dark) { .nav button.on { color: var(--brand); } }

/* Controles sobre el mapa */
.search { position: absolute; z-index: 500; top: 10px; left: 10px; right: 58px; display: flex; max-width: 460px; box-shadow: var(--shadow); border-radius: 12px; overflow: hidden; background: var(--card); }
.search input { flex: 1; border: 0; padding: 11px 12px; background: transparent; outline: none; min-width: 0; }
.search button { border: 0; background: var(--card); padding: 0 12px; cursor: pointer; font-size: 16px; }
.chips { position: absolute; z-index: 500; top: 58px; left: 10px; display: flex; gap: 6px; }
.chips button { border: 0; background: var(--card); color: var(--text); padding: 6px 11px; border-radius: 99px; font-size: 12.5px; box-shadow: var(--shadow); cursor: pointer; }
.chips button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.roundbtn { position: absolute; z-index: 500; right: 10px; top: 120px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 20px; cursor: pointer; }
.fab { position: absolute; z-index: 500; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--brand); color: var(--brand-ink); border: 0; padding: 14px 22px; border-radius: 99px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow); cursor: pointer; white-space: nowrap; }
.fab:active { transform: translateX(-50%) scale(.97); }
.crosshair { position: absolute; z-index: 450; left: 50%; top: 50%; transform: translate(-50%, -100%); pointer-events: none; display: none; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .4)); }
.pickhint { position: absolute; z-index: 500; top: 58px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 7px 12px; border-radius: 10px; font-size: 13px; display: none; width: max-content; max-width: 92%; text-align: center; }
.pickbar { position: absolute; z-index: 500; left: 10px; right: 10px; bottom: 14px; display: none; gap: 8px; justify-content: center; }
body.picking .crosshair, body.picking .pickhint, body.picking .pickbar { display: flex; }
body.picking .pickhint { display: block; }
body.picking .fab, body.picking .chips, body.picking .roundbtn { display: none; }

/* Botones */
.btn { border: 1px solid var(--line); background: var(--card); padding: 10px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; box-shadow: var(--shadow); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.ghost { box-shadow: none; }
.btn.small { padding: 6px 10px; font-size: 13px; box-shadow: none; }
.btn.danger { color: var(--pel); }
.btn:disabled { opacity: .55; cursor: default; }

/* Pines */
.pinwrap { background: none; border: 0; }
.pin { display: block; width: 24px; height: 24px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.pin.leve { background: var(--leve); } .pin.moderado { background: var(--mod); } .pin.peligroso { background: var(--pel); }
.pin.reparado { background: var(--ok); } .pin.enviado { outline: 3px solid var(--info); }
.pin.oculto { opacity: .45; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background-color: rgba(245, 158, 11, .35); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background-color: rgba(245, 158, 11, .9); color: #1f1300; font-weight: 700; }

/* Chips de estado */
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; }
.chip.leve { background: var(--leve); color: #3b2a00; } .chip.moderado { background: var(--mod); } .chip.peligroso { background: var(--pel); }
.chip.reportado { background: #64748b; } .chip.enviado { background: var(--info); } .chip.reparado { background: var(--ok); } .chip.oculto { background: #111827; }

/* Popup */
.leaflet-popup-content { margin: 10px 12px; }
.pp { width: 100%; }
.pp-img { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; cursor: zoom-in; margin-bottom: 8px; background: #e2e8f0; display: block; }
.pp-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.pp-addr { font-weight: 700; margin-bottom: 2px; }
.pp-desc { margin: 4px 0; color: #334155; }
.pp-meta { font-size: 12px; color: #64748b; margin-bottom: 8px; }
.pp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-admin { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #cbd5e1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pp-admin select { padding: 5px; border-radius: 8px; border: 1px solid #cbd5e1; }

/* Lista */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters input, .filters select { padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); min-width: 0; }
.filters input { grid-column: 1 / -1; }
.cards { display: grid; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; gap: 12px; cursor: pointer; }
.card:hover { border-color: var(--brand); }
.thumb { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: var(--line); flex: none; display: grid; place-items: center; font-size: 28px; }
.card-body { min-width: 0; flex: 1; }
.card-body h4 { margin: 0 0 4px; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.card-body p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Estadísticas y Apoyo */
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.kpi b { font-size: 26px; display: block; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 14px; }
.box h3 { margin: 0 0 10px; font-size: 16px; }
.box p { margin: 6px 0; }
.row { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-size: 13.5px; }
.row .lbl { flex: 0 0 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .bar { flex: 1; height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; }
.row .bar i { display: block; height: 100%; background: var(--brand); }
.row .num { width: 30px; text-align: right; color: var(--muted); }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: 8px; }
.cols div { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.cols i { display: block; background: var(--brand); border-radius: 5px 5px 0 0; min-height: 2px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sponsor-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.adbox { min-height: 90px; margin: 10px 0; }
.small { font-size: 12.5px; color: var(--muted); }

/* Diálogos */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, 94vw); background: var(--card); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2, 6, 23, .6); }
.dlg { padding: 16px; max-height: 88dvh; overflow: auto; }
.dlg h2 { margin: 0 0 10px; font-size: 18px; }
.dlg label.f { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13.5px; }
.dlg input[type=text], .dlg input[type=email], .dlg input[type=password], .dlg textarea { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.dlg textarea { min-height: 70px; resize: vertical; }
.photo-box { border: 2px dashed var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.photo-box img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.photo-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sev { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sev label { cursor: pointer; }
.sev input { position: absolute; opacity: 0; pointer-events: none; }
.sev span { display: block; border: 2px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; height: 100%; }
.sev span small { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; margin-top: 2px; }
.sev input:checked + span { border-color: var(--brand); background: rgba(245, 158, 11, .15); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
#lightbox { width: min(900px, 96vw); background: #000; }
#lightbox img { width: 100%; display: block; max-height: 90dvh; object-fit: contain; }

.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 14px; border-radius: 12px; z-index: 3000; max-width: 90vw; text-align: center; box-shadow: var(--shadow); }
