/* ==========================================================================
   Reporta Panamá · hoja de estilos
   Tema oscuro, tipografía Sora/Inter, superficies con borde sutil.
   ========================================================================== */

:root {
  --bg:        #080b11;
  --bg-soft:   #0d1219;
  --surface:   rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --line:      rgba(255, 255, 255, .09);
  --line-2:    rgba(255, 255, 255, .16);
  --text:      #e9eef5;
  --muted:     #93a1b3;
  --accent:    #38bdf8;
  --accent-ink:#04121c;
  --danger:    #f87171;
  --ok:        #4ade80;
  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 18px 48px -24px rgba(0, 0, 0, .85);
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(56, 189, 248, .10), transparent 70%),
    radial-gradient(700px 420px at 8% 0%, rgba(167, 139, 250, .07), transparent 70%);
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -.015em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
em { font-style: normal; color: var(--accent); }
.ico { flex: none; }

.wrap { width: min(1360px, 100% - 2.4rem); margin-inline: auto; }
.muted { color: var(--muted); }

/* ------------------------------- Topbar ---------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(8, 11, 17, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner { display: flex; align-items: center; gap: 1rem; height: 62px; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; margin-right: auto; }

.brand-mark {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--bg);
}

.nav { display: flex; align-items: center; gap: .35rem; }

.nav-link {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border-radius: 999px;
  color: var(--muted); font-weight: 500; font-size: .91rem;
  transition: background .18s ease, color .18s ease;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }

.nav-user {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .75rem; border-radius: 999px;
  border: 1px solid var(--line);
  font-size: .86rem; color: var(--muted);
}

.nav-toggle { display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: .4rem; }

/* ------------------------------- Botones --------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body); font-size: .93rem; font-weight: 600;
  cursor: pointer; transition: transform .12s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #5cc9fb; }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: .5rem .85rem; font-size: .87rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.link-btn { background: none; border: 0; color: var(--accent); font-size: .84rem; cursor: pointer; padding: 0; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }

/* -------------------------------- Hero ----------------------------------- */

.hero { padding: 2.6rem 0 1.6rem; }
.hero-inner { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.hero-copy { max-width: 620px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: .9rem;
}

.hero h1 { font-size: clamp(1.9rem, 3.4vw, 2.9rem); line-height: 1.08; margin-bottom: .7rem; }
.hero p { color: var(--muted); font-size: 1.02rem; max-width: 52ch; }

.hero-stats { display: flex; gap: .7rem; }
.stat {
  min-width: 104px;
  padding: .8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.stat b { display: block; font-family: var(--font-head); font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }

/* ------------------------------- Layout ---------------------------------- */

.layout {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  gap: 1rem;
  padding-bottom: 2.4rem;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* -------------------------------- Sidebar -------------------------------- */

.side { padding: 1.1rem; max-height: calc(100vh - 140px); overflow-y: auto; position: sticky; top: 78px; }

.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; margin-bottom: .8rem; }
.side-head h2 { font-size: .95rem; }
.side-head--sub { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

.search-box {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem .8rem; margin-bottom: 1.1rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--muted);
}
.search-box input { flex: 1; border: 0; background: none; color: var(--text); font: inherit; outline: none; }
.search-box input::placeholder { color: #64748b; }

.filter-group + .filter-group { margin-top: 1rem; }
.filter-title { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .4rem .68rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-soft); color: var(--muted);
  font: inherit; font-size: .84rem; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip); }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.is-on { color: var(--text); border-color: var(--chip); background: color-mix(in srgb, var(--chip) 16%, transparent); }

/* ----------------------------- Lista reportes ---------------------------- */

.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }

.report-item {
  display: grid; grid-template-columns: 10px 1fr; gap: .75rem;
  padding: .7rem .75rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); cursor: pointer;
  transition: border-color .15s ease, transform .12s ease;
}
.report-item:hover { border-color: var(--line-2); transform: translateX(2px); }
.report-item .mark { border-radius: 3px; background: var(--chip); }
.report-item h3 { font-size: .9rem; font-weight: 600; line-height: 1.3; }
.report-item p { font-size: .8rem; color: var(--muted); margin-top: .2rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.report-item .meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: .45rem; font-size: .72rem; color: #6b7c91; }
.report-item .tag { color: var(--chip); font-weight: 600; }

.empty { padding: 1.4rem .6rem; text-align: center; color: var(--muted); font-size: .87rem; }

/* --------------------------------- Mapa ---------------------------------- */

.map-panel { position: relative; overflow: hidden; min-height: 620px; }
.map { height: calc(100vh - 210px); min-height: 560px; width: 100%; background: #0a1017; }

.map-topleft {
  position: absolute; z-index: 500; top: .9rem; left: .9rem;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-start;
}

.map-modes {
  display: inline-flex; gap: .25rem; padding: .25rem;
  border-radius: 999px; background: rgba(8, 11, 17, .82);
  border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted);
  font: 500 .82rem var(--font-body); padding: .35rem .85rem;
  border-radius: 999px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.is-on { background: var(--surface-2); color: var(--text); }

.map-legend {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .5rem .8rem; border-radius: 999px;
  background: rgba(8, 11, 17, .82); border: 1px solid var(--line);
  backdrop-filter: blur(10px); font-size: .82rem; color: var(--muted);
}
.map-legend b { color: var(--text); font-family: var(--font-head); }

.map-cta {
  position: absolute; z-index: 500; bottom: 1rem; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.1rem; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font: 600 .9rem var(--font-body); cursor: pointer;
  box-shadow: 0 12px 30px -12px rgba(56, 189, 248, .7);
}
.map-cta:hover { background: #5cc9fb; }

.map-note {
  position: absolute; z-index: 500; top: .9rem; right: .9rem;
  margin: 0; padding: .45rem .8rem; border-radius: 999px;
  background: rgba(8, 11, 17, .85); border: 1px solid rgba(251, 191, 36, .4);
  backdrop-filter: blur(10px); font-size: .78rem; color: #fbbf24;
}

/* Marcador tipo faro: relleno del color de la categoría, anillo blanco
   y halo del mismo color para que resalte sobre el mapa oscuro. */
.pin {
  width: 30px; height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .72), transparent 46%),
    var(--c);
  border: 3px solid #f8fafc;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent),
    0 10px 20px -6px rgba(0, 0, 0, .95);
  transition: transform .14s ease;
}
.pin:hover { transform: scale(1.2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #0e141d; color: var(--text);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.leaflet-popup-content-wrapper { border-radius: 13px; }
.leaflet-popup-content { margin: .85rem .95rem; font-family: var(--font-body); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-zoom a { background: #0e141d; color: var(--text); border-color: var(--line); }
.leaflet-control-zoom a:hover { background: var(--surface-2); }
.leaflet-control-attribution { background: rgba(8, 11, 17, .7) !important; color: #6b7c91 !important; }
.leaflet-control-attribution a { color: #8aa0b6 !important; }

.pop-title { display: flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-weight: 600; font-size: .95rem; }
.pop-cat { width: 9px; height: 9px; border-radius: 50%; }
.pop-body { margin-top: .4rem; font-size: .85rem; color: var(--muted); max-width: 250px; }
.pop-foot { display: flex; justify-content: space-between; gap: .8rem; margin-top: .6rem; font-size: .72rem; color: #6b7c91; }

/* Cluster: círculo oscuro con borde de acento, coherente con los marcadores */
.marker-cluster { background: transparent; border-radius: 50%; }
.marker-cluster div {
  color: #e9eef5;
  font-family: var(--font-head);
  font-weight: 600;
  background: rgba(11, 17, 25, .94);
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow:
    0 0 0 5px rgba(56, 189, 248, .16),
    0 12px 24px -8px rgba(0, 0, 0, .95);
}
.marker-cluster span { line-height: 30px; }

/* ------------------------------- Auth ------------------------------------ */

.auth-wrap { display: flex; justify-content: center; padding: 3rem 0 4rem; }
.auth-card { width: min(460px, 100%); padding: 1.8rem; }
.auth-head { text-align: center; margin-bottom: 1.4rem; }
.auth-head .brand-mark { width: 34px; height: 34px; margin: 0 auto .8rem; box-shadow: inset 0 0 0 9px var(--bg); }
.auth-head h1 { font-size: 1.5rem; margin-bottom: .35rem; }
.auth-head p { color: var(--muted); font-size: .92rem; }

.field { margin-bottom: .95rem; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .4rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .72rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-soft); color: var(--text);
  font: inherit; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .16);
}
.field textarea { resize: vertical; min-height: 96px; }
.field .hint { font-size: .76rem; color: #6b7c91; margin-top: .35rem; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.captcha-row { display: flex; align-items: center; gap: .8rem; }
.captcha-q {
  flex: none; min-width: 150px;
  padding: .72rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font-head); font-size: .95rem;
}

.form-error {
  display: flex; align-items: center; gap: .55rem;
  padding: .7rem .9rem; margin-bottom: 1rem;
  border: 1px solid rgba(248, 113, 113, .35); border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, .1); color: #fca5a5; font-size: .87rem;
}
.form-note {
  display: flex; align-items: center; gap: .55rem;
  padding: .7rem .9rem; margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--muted); font-size: .86rem;
}
.auth-alt { text-align: center; margin-top: 1.1rem; font-size: .88rem; color: var(--muted); }
.auth-alt a { color: var(--accent); }

/* ------------------------------ Formulario ------------------------------- */

.page-form { padding: 2.2rem 0 3rem; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; align-items: start; }
.form-card { padding: 1.6rem; }
.form-card h1 { font-size: 1.4rem; margin-bottom: .35rem; }
.form-card > p { color: var(--muted); font-size: .9rem; margin-bottom: 1.4rem; }

.pick-map { height: 380px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: .6rem; }
.pick-fallback {
  height: 380px; display: flex; align-items: center; justify-content: center;
  padding: 1.2rem; text-align: center; color: var(--muted); font-size: .86rem;
  border: 1px dashed var(--line-2); border-radius: var(--radius); margin-bottom: .6rem;
  background: var(--bg-soft);
}
.geo-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.geo-status { font-size: .78rem; color: var(--muted); }
.geo-status:not(:empty) { color: var(--accent); }
.coords-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .8rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: .84rem; color: var(--muted);
}
.coords-pill.has { color: var(--text); border-color: var(--accent); }

/* ------------------------------- Flash ----------------------------------- */

.flash-stack { width: min(1360px, 100% - 2.4rem); margin: 1rem auto -.4rem; display: grid; gap: .5rem; }
.flash {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); font-size: .89rem;
}
.flash-ok { border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .1); color: #86efac; }
.flash-error { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .1); color: #fca5a5; }

/* ------------------------------- Footer ---------------------------------- */

.site-foot { border-top: 1px solid var(--line); margin-top: 1rem; }
.foot-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.4rem 0; flex-wrap: wrap; }
.foot-inner strong { font-family: var(--font-head); font-weight: 600; }
.foot-inner p { color: var(--muted); font-size: .82rem; }

/* ------------------------------- Admin ----------------------------------- */

.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.admin-head h1 { font-size: 1.6rem; margin-bottom: .25rem; }

.kpi-grid { display: flex; gap: .5rem; flex-wrap: wrap; }
.kpi {
  min-width: 92px; padding: .65rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.kpi b { display: block; font-family: var(--font-head); font-size: 1.25rem; line-height: 1.1; }
.kpi span { font-size: .72rem; color: var(--muted); }
.kpi-line span::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--k); margin-right: .35rem; vertical-align: middle;
}

.admin-filters {
  display: grid; grid-template-columns: 180px 220px 1fr auto;
  gap: .8rem; align-items: end; padding: 1rem; margin-bottom: 1rem;
}
.admin-filters .field { margin: 0; }
.admin-filters-actions { display: flex; align-items: center; gap: .8rem; padding-bottom: .15rem; }

.admin-table-wrap { overflow-x: auto; padding: .4rem .4rem 0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .7rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.admin-table td { padding: .75rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover td { background: var(--surface); }

.row-cat {
  display: inline-block; font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--c); margin-bottom: .25rem;
}
.row-title { display: block; font-family: var(--font-head); font-weight: 600; font-size: .9rem; }
.row-desc { color: var(--muted); font-size: .78rem; margin-top: .2rem; max-width: 340px; }

.estado-form select {
  padding: .38rem .55rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-soft); color: var(--text); font: inherit; font-size: .8rem;
  box-shadow: inset 3px 0 0 var(--k); cursor: pointer;
}

.row-actions { display: flex; gap: .35rem; }
.row-actions form { display: inline; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn-danger:hover { color: #fca5a5; border-color: rgba(248, 113, 113, .5); }
.admin-note { padding: .7rem .8rem; font-size: .8rem; }

/* ----------------------------- Responsive -------------------------------- */

@media (max-width: 1080px) {
  .layout, .form-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .map { height: 66vh; min-height: 440px; }
  .admin-filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .nav { position: absolute; top: 62px; right: 0; left: 0;
    flex-direction: column; align-items: stretch; gap: .2rem;
    padding: .8rem 1.2rem 1.1rem;
    background: var(--bg-soft); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav.open { display: flex; }
  .nav-toggle { display: inline-flex; }
  .nav-user { justify-content: center; }
  .hero { padding: 1.8rem 0 1.2rem; }
  .hero-stats { width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .field-row { grid-template-columns: 1fr; }
  .admin-filters { grid-template-columns: 1fr; }
  .foot-inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ------------------------- Aviso / legal / anti-bot ---------------------- */

.emergency {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .75rem .95rem; margin-bottom: 1.1rem;
  border: 1px solid rgba(248, 113, 113, .35); border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, .08); color: #fca5a5; font-size: .86rem;
}
.emergency .ico { margin-top: 1px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.check { display: flex; align-items: flex-start; gap: .55rem; margin: .2rem 0 1rem; font-size: .86rem; color: var(--muted); }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); flex: none; }
.check a { color: var(--accent); }

.legal h1 { margin-bottom: .3rem; }
.legal h2 { font-size: 1rem; margin: 1.4rem 0 .5rem; }
.legal p { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }
.legal ul { margin: .3rem 0 .8rem 1.1rem; padding: 0; color: var(--muted); font-size: .9rem; }
.legal li { margin-bottom: .3rem; }
.legal a { color: var(--accent); }

.foot-emergency { color: #f0a3a3; font-size: .78rem; margin-top: .35rem; max-width: 62ch; }

/* ------------------------------- Cuenta ---------------------------------- */
.account-head { display: flex; align-items: center; gap: 1rem; }
.account-avatar {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--accent);
}
.account-head h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.account-head p { font-size: .84rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.account-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==========================================================================
   App shell móvil (≤820px): mapa a pantalla completa + barra inferior
   ========================================================================== */

.bottom-nav,
.map-filter-btn,
.sheet-top,
.sheet-backdrop { display: none; }

@media (max-width: 820px) {
  body {
    --app-top: 56px;
    --app-bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    padding-top: var(--app-top);
    padding-bottom: var(--app-bottom);
  }
  body.page-map { padding: 0; overflow: hidden; }

  /* Barra superior compacta */
  .topbar { position: fixed; top: 0; left: 0; right: 0; }
  .topbar-inner { height: var(--app-top); }
  .nav, .nav-toggle { display: none !important; }

  /* El mapa es lo principal */
  body.page-map .hero { display: none; }
  body.page-map .layout { display: block; padding: 0; }
  body.page-map .map-panel {
    position: fixed;
    top: var(--app-top); left: 0; right: 0; bottom: var(--app-bottom);
    border: 0; border-radius: 0; box-shadow: none; min-height: 0;
  }
  body.page-map .map { height: 100%; min-height: 0; }
  body.page-map .map-cta { display: none; }

  /* Controles sobre el mapa */
  .map-topleft { top: .7rem; left: .7rem; z-index: 1000; max-width: calc(100% - 9.5rem); }
  .map-legend {
    display: block; font-size: .76rem; padding: .42rem .7rem; max-width: 100%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .map-note { top: 3.6rem; right: .7rem; font-size: .72rem; z-index: 1000; }
  .mode-btn { padding: .3rem .7rem; font-size: .78rem; }

  .map-filter-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    position: absolute; z-index: 1000; top: .7rem; right: .7rem;
    padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--line);
    background: rgba(8, 11, 17, .9); backdrop-filter: blur(12px);
    color: var(--text); font: 600 .82rem var(--font-body); cursor: pointer;
  }
  .map-filter-btn:active { transform: scale(.97); }
  .filter-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink); font-size: .68rem; font-weight: 700;
  }

  /* Barra inferior tipo app */
  .bottom-nav {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0;
    height: var(--app-bottom); padding: 0 .9rem env(safe-area-inset-bottom, 0px);
    background: rgba(8, 11, 17, .92); backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: .18rem;
    padding: .5rem; color: var(--muted); font-size: .68rem; font-weight: 500;
    transition: color .15s ease;
  }
  .bn-item.is-active { color: var(--text); }
  .bn-item.is-active .ico { color: var(--accent); }

  .bn-fab {
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    transform: translateY(-15px); font-size: .68rem; font-weight: 700;
  }
  .bn-fab-icon {
    display: flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 12px 26px -8px rgba(56, 189, 248, .85), 0 0 0 6px rgba(8, 11, 17, .92);
    transition: transform .12s ease;
  }
  .bn-fab:active .bn-fab-icon { transform: scale(.94); }
  .bn-fab-label { color: var(--text); }

  /* Panel de filtros deslizable */
  .side {
    position: fixed; z-index: 1300;
    left: 0; right: 0; bottom: 0; top: auto;
    max-height: 85vh; max-height: 85dvh; margin: 0;
    border-radius: 22px 22px 0 0;
    padding: 1.1rem 1.05rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(calc(100% + 24px));
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    overflow-y: auto; overscroll-behavior: contain;
    box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, .9);
  }
  .side.open { transform: translateY(0); }

  .sheet-top {
    display: flex; align-items: center; justify-content: center;
    position: relative; margin: -.35rem 0 .9rem;
  }
  .sheet-grab { width: 44px; height: 4px; border-radius: 999px; background: var(--line-2); }
  .sheet-close {
    position: absolute; right: -.2rem; top: -.4rem;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  }
  .side-head--sub { margin-top: 1rem; padding-top: 1rem; }

  .sheet-backdrop {
    position: fixed; inset: 0; z-index: 1200;
    background: rgba(3, 6, 10, .6);
  }
  .sheet-backdrop:not([hidden]) { display: block; }

  /* Modales/formularios con aire para la barra inferior */
  .page-form { padding-top: 1.4rem; }

  /* En móvil, primero la ubicación (mapa + GPS), luego el formulario */
  .form-main { order: 2; }
  .form-side { order: 1; }
  .pick-map, .pick-fallback { height: 320px; }
}
