/* ================================================================
   Territoria — sistema visual ClickUp (ver ./visual/*.md)
   Tokens semánticos, glass morphism, flat design, Figtree + DM Mono
   ================================================================ */

:root {
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --r: 10px;
  --r-sm: 7px;
  --r-lg: 14px;
  --font: 'Figtree', -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.25, .46, .45, .94);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
}

:root[data-theme="light"] {
  --bg: #F8F9FA;
  --bg2: #FFFFFF;
  --bg3: #F3F4F6;
  --surface: #ECEDF1;
  --border: rgba(10, 10, 20, .08);
  --border2: rgba(10, 10, 20, .04);
  --t1: #16161D;
  --t2: #4A4A55;
  --t3: #8A8A96;
  --accent: #5E5CE6;
  --accent-h: #4A48C9;
  --accent-ring: rgba(94, 92, 230, .22);
  --done: #1A9640;
  --progress: #0A7AE0;
  --review: #C07800;
  --urgent: #D03030;
  --glass: rgba(255, 255, 255, .78);
  --glass-raised: rgba(255, 255, 255, .88);
  --glass-modal: rgba(255, 255, 255, .94);
  --glass-border: rgba(10, 10, 20, .08);
  --shadow-sm: 0 1px 4px rgba(20, 20, 40, .08);
  --shadow-md: 0 4px 16px rgba(20, 20, 40, .10);
  --shadow-lg: 0 12px 40px rgba(20, 20, 40, .14);
}

:root[data-theme="dark"] {
  --bg: #0D0D0F;
  --bg2: #1A1A1C;
  --bg3: #242426;
  --surface: #2C2C2E;
  --border: rgba(255, 255, 255, .08);
  --border2: rgba(255, 255, 255, .04);
  --t1: rgba(255, 255, 255, .90);
  --t2: rgba(255, 255, 255, .55);
  --t3: rgba(255, 255, 255, .28);
  --accent: #5E5CE6;
  --accent-h: #7B79F5;
  --accent-ring: rgba(94, 92, 230, .28);
  --done: #30D158;
  --progress: #0A84FF;
  --review: #FF9F0A;
  --urgent: #FF453A;
  --glass: rgba(18, 18, 20, .82);
  --glass-raised: rgba(26, 26, 28, .90);
  --glass-modal: rgba(30, 30, 32, .94);
  --glass-border: rgba(255, 255, 255, .07);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

/* ---------------- Base ---------------- */

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

/* El atributo hidden SIEMPRE gana: sin esto, cualquier regla con display
   (flex/grid) lo anula y el elemento queda visible aunque JS lo oculte. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--t1);
  background: var(--bg);
  overflow: hidden;
  transition: background .2s var(--ease), color .2s var(--ease);
}

.mono { font-family: var(--mono); letter-spacing: .02em; }

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--t3) 40%, transparent);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--t3); }

/* Lucide: line icons planos, stroke 1.75, heredan currentColor */
svg.lucide { width: 15px; height: 15px; stroke-width: 1.75; flex-shrink: 0; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pinDrop {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes heartbeat {
  0%, 40%, 100% { transform: scale(1); }
  8% { transform: scale(1.1); }
  16% { transform: scale(1); }
  24% { transform: scale(1.06); }
}
@keyframes ringPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--urgent) 45%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

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

.app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* móvil: excluye la barra de URL dinámica (iOS/Android) */
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------------- Sidebar (glass nivel 1) ---------------- */

.sidebar {
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-right: 1px solid var(--glass-border);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border2);
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 6px var(--accent-ring);
}
.brand-mark svg.lucide { width: 17px; height: 17px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 10.5px; color: var(--t3); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; }

.side-section { margin-bottom: 22px; }

.side-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 0 6px;
  margin-bottom: 8px;
}

.side-list { display: flex; flex-direction: column; gap: 2px; }

.side-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  text-align: left;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.side-item:hover { background: var(--surface); color: var(--t1); }
.side-item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.side-item.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}
.side-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.side-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--t3);
  background: var(--bg3);
  padding: 1px 7px;
  border-radius: 99px;
}
.side-item.is-active .count {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Filtro de categoría desactivado = apagado, no accent */
#category-filter .side-item.is-active { background: transparent; color: var(--t1); }
#category-filter .side-item.is-active::before { display: none; }
#category-filter .side-item:not(.is-active) { opacity: .38; }
#category-filter .side-item:hover { background: var(--surface); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot--neutral { background: var(--t3); }
.dot--open { background: var(--progress); }
.dot--done { background: var(--done); }

/* Color de categoría dinámico vía --tc (inline style desde la API) */
.cat-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--tc, var(--t3)) 14%, transparent);
  color: var(--tc, var(--t3));
}
.cat-ico svg.lucide { width: 13px; height: 13px; }

/* Segmented control (Anónimos / Registrados) */
.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
}
.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 4px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--t2);
  transition: background .12s var(--ease), color .12s var(--ease), box-shadow .12s var(--ease);
}
.seg-btn svg.lucide { width: 12px; height: 12px; }
.seg-btn:hover { color: var(--t1); }
.seg-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.seg-btn.is-active {
  background: var(--bg2);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.side-hint {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 11.5px;
  color: var(--t2);
}
.side-hint p { display: flex; gap: 8px; align-items: flex-start; }
.side-hint svg.lucide { width: 13px; height: 13px; margin-top: 2px; color: var(--t3); }
.side-hint em { font-style: normal; font-weight: 600; color: var(--t1); }
.side-hint strong.mono { color: var(--accent); font-weight: 500; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border2);
  font-size: 11px;
  color: var(--t3);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--t3);
  transition: background .2s var(--ease);
}
.pulse-dot.is-online { background: var(--done); animation: pulse 2.4s infinite var(--ease); }
.pulse-dot.is-offline { background: var(--urgent); }

/* ---------------- Topbar (glass nivel 1) ---------------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 30;
}

.topbar-title { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.topbar-title h1 { font-size: 16px; font-weight: 600; letter-spacing: -.3px; white-space: nowrap; }
.topbar-sub { font-size: 11px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-stats { display: flex; gap: 18px; margin-left: auto; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.stat .mono { font-size: 15px; font-weight: 500; }
.stat label { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--t3); }
.stat--alert .mono { color: var(--urgent); }

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--t2);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--t3) 14%, transparent); color: var(--t1); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.icon-btn--sm { width: 26px; height: 26px; }
.icon-btn.is-spinning svg.lucide { animation: spin .8s linear infinite; }

.only-mobile { display: none; }

/* ---------------- Banner offline ---------------- */

.offline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--urgent);
  background: color-mix(in srgb, var(--urgent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--urgent) 30%, transparent);
  border-radius: var(--r);
  animation: fadeUp .2s var(--ease);
}
.offline-banner code { font-size: 11.5px; }
.offline-banner .btn { margin-left: auto; }

/* ---------------- Mapa (Leaflet + OpenStreetMap) ---------------- */

.map-wrap { flex: 1; padding: 16px; min-height: 0; }

.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg3);
  box-shadow: var(--shadow-sm);
}

#map { position: absolute; inset: 0; z-index: 1; background: var(--bg3); }

.leaflet-container { font-family: var(--font); cursor: crosshair; }
.leaflet-dragging .leaflet-container { cursor: grabbing; }

/* OpenFreeMap (vector, canvas de MapLibre): estándar en light,
   invertido en dark para legibilidad */
:root[data-theme="dark"] .maplibregl-canvas {
  filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.55);
}
.leaflet-gl-layer { z-index: 1; }

/* Controles Leaflet al sistema visual */
.leaflet-bar {
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}
.leaflet-bar a {
  width: 28px !important;
  height: 28px !important;
  line-height: 28px !important;
  background: var(--glass-modal) !important;
  color: var(--t2) !important;
  border-bottom: 1px solid var(--border2) !important;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.leaflet-bar a:last-child { border-bottom: none !important; }
.leaflet-bar a:hover { background: var(--surface) !important; color: var(--t1) !important; }
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--bg2) 78%, transparent) !important;
  color: var(--t3) !important;
  font-family: var(--font);
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--t2) !important; }

.map-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  font-size: 11px;
  color: var(--t2);
  background: var(--glass-modal);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  animation: fadeUp .2s var(--ease);
}
.map-hint svg.lucide { width: 12px; height: 12px; color: var(--t3); }

/* ---------------- Pins (divIcon de Leaflet) ---------------- */

.pin-anchor { background: none; border: none; }

.pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 30px;
  transform-origin: 50% 100%; /* late anclado a la punta: no se despega del punto */
  animation: pinDrop .22s var(--spring), heartbeat 2.4s .4s infinite var(--ease);
  transition: filter .15s var(--ease);
}
.pin:hover { filter: brightness(1.08); }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .pin-head { box-shadow: 0 0 0 3px var(--accent-ring); }

.pin-head {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  color: #fff;
  border: 2px solid var(--bg2);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--spring), box-shadow .15s var(--ease);
}
.pin-head svg.lucide { transform: rotate(45deg); width: 14px; height: 14px; stroke-width: 2; }
.pin:hover .pin-head { transform: rotate(-45deg) scale(1.12); box-shadow: var(--shadow-md); }

.pin .pin-head { background: var(--tc, var(--accent)); }
.pin--resuelto .pin-head { background: var(--done); }
.pin--resuelto {
  opacity: .72;
  animation: pinDrop .22s var(--spring); /* resuelto ya no late */
}

.pin-tip {
  width: 5px;
  height: 5px;
  margin-top: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--t1) 30%, transparent);
}

.pin--priority .pin-head { animation: ringPulse 1.6s infinite var(--ease); }

.pin.is-selected .pin-head {
  transform: rotate(-45deg) scale(1.18);
  border-color: var(--accent);
}

/* ---------------- Glass modal base ---------------- */

.glass-modal {
  background: var(--glass-modal);
  backdrop-filter: blur(36px) saturate(180%);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

/* ---------------- Popover nueva denuncia ---------------- */

.popover {
  position: absolute;
  width: 320px;
  max-width: calc(100% - 24px);
  padding: 16px 18px;
  z-index: 1100;
  cursor: default;
  animation: scaleIn .2s var(--spring);
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.popover-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.popover-head h2 svg.lucide { color: var(--accent); width: 16px; height: 16px; }

.field { display: block; margin-bottom: 12px; }
.field--row { display: flex; align-items: center; }

.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 5px;
}

.input {
  width: 100%;
  padding: 7.5px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--t1);
  background: var(--bg3);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  resize: vertical;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--t3); }
.input.is-invalid { border-color: var(--urgent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--urgent) 22%, transparent); }

.field-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 2px 0 6px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--t3);
}
.field-note svg.lucide { width: 12px; height: 12px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.field-note strong { color: var(--t2); }

.phone-link { font-size: 10px; color: var(--t3); text-decoration: none; }
.phone-link:hover { color: var(--accent); text-decoration: underline; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4.5px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--t2);
  background: var(--bg3);
  border: 1px solid var(--glass-border);
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.chip svg.lucide { width: 12px; height: 12px; }
.chip:hover { color: var(--t1); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.chip.is-active {
  background: color-mix(in srgb, var(--tc, var(--accent)) 15%, transparent);
  color: var(--tc, var(--accent));
  border-color: color-mix(in srgb, var(--tc, var(--accent)) 30%, transparent);
}

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 34px;
  height: 18px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border2);
  position: relative;
  transition: background .15s var(--ease);
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 1px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--spring);
}
.toggle input:checked + .toggle-track { background: var(--done); border-color: transparent; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(15px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.toggle-text { font-size: 12.5px; font-weight: 500; color: var(--t2); }

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------------- Logo personalizado ---------------- */

.brand-logo {
  max-height: 36px;
  max-width: 46%; /* deja sitio al texto "City Safe" a su derecha */
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.logo-preview-row { margin-bottom: 10px; }
.logo-preview {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  background: var(--bg3);
}
.logo-preview img { max-height: 56px; max-width: 100%; object-fit: contain; }
.logo-preview-empty { font-size: 11.5px; color: var(--t3); }
input[type="file"].input { padding: 5px 8px; font-size: 11.5px; }

/* ---------------- Rango de fechas ---------------- */

.date-range { display: flex; align-items: flex-end; gap: 6px; }

.date-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.date-field span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
}
.date-field .input { padding: 6px 8px; font-size: 12px; }

.date-range .icon-btn { margin-bottom: 3px; }

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] input[type="time"] { color-scheme: dark; }

.tz-note { font-size: 10.5px; color: var(--t3); margin-top: 6px; }

/* ---------------- Buscador de ciudad ---------------- */

.city-search { position: relative; }
.city-search svg.lucide {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  color: var(--t3);
  pointer-events: none;
}
.city-search .input { padding-left: 30px; }

.city-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.city-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6.5px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background .12s var(--ease);
}
.city-result:hover { background: var(--surface); }
.city-result:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.city-result svg.lucide { width: 13px; height: 13px; color: var(--t3); }
.city-result span { display: flex; flex-direction: column; min-width: 0; }
.city-result strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-result small {
  font-size: 11px;
  color: var(--t3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.city-result-empty { padding: 8px 10px; font-size: 12px; color: var(--t3); }

.onboarding-box { max-width: 420px; }
.onboarding-box .modal-actions { margin-top: 10px; }
.onboarding-box .modal-actions .btn--ghost { margin-right: 0; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5.5px 13px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background .12s var(--ease), color .12s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn svg.lucide { width: 13px; height: 13px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 6px var(--accent-ring); }
.btn--primary:hover:not(:disabled) { background: var(--accent-h); transform: translateY(-1px); }

.btn--ghost { background: transparent; color: var(--t2); border-color: var(--glass-border); font-weight: 500; }
.btn--ghost:hover { background: color-mix(in srgb, var(--t3) 10%, transparent); color: var(--t1); }

.btn--small { padding: 4px 9px; font-size: 11.5px; font-weight: 500; border-color: currentColor; }

/* ---------------- Tarjeta de detalle ---------------- */

.detail-card {
  position: absolute;
  width: 330px;
  max-width: calc(100% - 24px);
  padding: 16px 18px;
  z-index: 1050;
  cursor: default;
  animation: scaleIn .2s var(--spring);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.detail-head .cat-ico { width: 30px; height: 30px; border-radius: 8px; margin-top: 1px; }
.detail-head .cat-ico svg.lucide { width: 15px; height: 15px; }
.detail-title { flex: 1; min-width: 0; }
.detail-title h2 { font-size: 15px; font-weight: 600; letter-spacing: -.1px; line-height: 1.3; overflow-wrap: break-word; }
.detail-title time { font-family: var(--mono); font-size: 10.5px; color: var(--t3); }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 11px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.pill .dot { width: 5px; height: 5px; background: currentColor; }
.pill--open { background: color-mix(in srgb, var(--progress) 15%, transparent); color: var(--progress); border: 1px solid color-mix(in srgb, var(--progress) 30%, transparent); }
.pill--done { background: color-mix(in srgb, var(--done) 15%, transparent); color: var(--done); border: 1px solid color-mix(in srgb, var(--done) 30%, transparent); }
.pill--tc {
  background: color-mix(in srgb, var(--tc, var(--accent)) 15%, transparent);
  color: var(--tc, var(--accent));
  border: 1px solid color-mix(in srgb, var(--tc, var(--accent)) 30%, transparent);
}
.pill--priority {
  background: color-mix(in srgb, var(--urgent) 15%, transparent);
  color: var(--urgent);
  border: 1px solid color-mix(in srgb, var(--urgent) 30%, transparent);
}
.pill svg.lucide { width: 11px; height: 11px; }

.detail-desc { font-size: 13px; color: var(--t2); margin-bottom: 12px; overflow-wrap: break-word; }
.detail-desc:empty { display: none; }

.detail-author {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--t3);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border2);
}
.detail-author svg.lucide { width: 13px; height: 13px; }
.detail-author strong { color: var(--t2); font-weight: 600; }

/* Módulo de votación colectiva */
.vote-row { display: flex; gap: 8px; }

.vote-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-border);
  background: var(--bg3);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t2);
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease), transform .15s var(--ease);
}
.vote-btn svg.lucide { width: 14px; height: 14px; }
.vote-btn .mono { font-size: 13px; font-weight: 500; }
.vote-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.vote-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.vote-btn:disabled { opacity: .6; cursor: wait; }

.vote-btn--up:hover:not(:disabled), .vote-btn--up.is-voted {
  background: color-mix(in srgb, var(--done) 15%, transparent);
  color: var(--done);
  border-color: color-mix(in srgb, var(--done) 30%, transparent);
}
.vote-btn--down:hover:not(:disabled), .vote-btn--down.is-voted {
  background: color-mix(in srgb, var(--urgent) 15%, transparent);
  color: var(--urgent);
  border-color: color-mix(in srgb, var(--urgent) 30%, transparent);
}

/* Reporte propio: se muestran los conteos sin botones votables */
.vote-count {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--glass-border);
  background: var(--bg3);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t3);
}
.vote-count svg.lucide { width: 14px; height: 14px; }
.vote-count .mono { font-size: 13px; font-weight: 500; }

.owner-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--t3);
}
.owner-note svg.lucide { width: 13px; height: 13px; flex-shrink: 0; }

.vote-meter { margin-top: 11px; }
.vote-meter-track {
  height: 4px;
  border-radius: 99px;
  background: var(--surface);
  overflow: hidden;
}
.vote-meter-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .3s var(--ease), background .2s var(--ease);
}
.vote-meter-fill.is-full { background: var(--urgent); }
.vote-meter-label {
  display: block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--t3);
}

/* Oficio enviado a la autoridad (dentro de la tarjeta) */
.authority-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--done) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--done) 25%, transparent);
  border-radius: var(--r);
}
.authority-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--done);
}
.authority-head svg.lucide { width: 13px; height: 13px; }
.authority-head time { margin-left: auto; font-size: 10px; font-weight: 400; color: var(--t3); }
.authority-email { font-size: 10.5px; color: var(--t2); margin: 4px 0 8px; }
.authority-text {
  max-height: 140px;
  overflow-y: auto;
  font-family: var(--font);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--t2);
  white-space: pre-wrap;
  margin: 0;
}

/* ---------------- Toasts (sin alert/confirm nativos) ---------------- */

.toast-zone {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 24px);
  z-index: 1300; /* sobre los bottom sheets móviles (1200) */
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--r);
  background: var(--glass-modal);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  animation: fadeUp .2s var(--spring);
}
.toast svg.lucide { width: 14px; height: 14px; }
.toast--ok svg.lucide { color: var(--done); }
.toast--error svg.lucide { color: var(--urgent); }

/* ---------------- Scrim (drawer móvil) ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  backdrop-filter: blur(4px);
  z-index: 35;
}

/* ---------------- Responsive (celulares) ---------------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    max-width: 84vw; /* teléfonos angostos: el drawer nunca tapa todo */
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    box-shadow: none;
    z-index: 60; /* sobre el scrim móvil */
  }
  .scrim { z-index: 55; }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .only-mobile { display: grid; }
  .sidebar-close { order: 99; margin-left: auto; }
  .topbar-stats { display: none; }
  .topbar-sub { display: none; }
  .map-wrap { padding: 0; }
  .map-stage { border-radius: 0; border: none; }

  /* Popover y tarjeta como bottom sheets (anulan el posicionamiento inline) */
  .popover, .detail-card {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 72vh;
    overflow-y: auto;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    animation: sheetUp .25s var(--spring);
    z-index: 1200;
  }

  /* Objetivos táctiles más grandes */
  .vote-btn { padding: 11px 10px; }
  .btn { padding: 9px 15px; }
  .input { padding: 10px 12px; font-size: 16px; } /* 16px evita el zoom de iOS */
  .side-item { padding: 10px 10px; }
  .leaflet-bar a { width: 34px !important; height: 34px !important; line-height: 34px !important; }
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- Panel de administración ---------------- */

.sidebar-admin-link { margin-left: auto; }

.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-content: start;
}

.admin-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  animation: fadeUp .2s var(--ease);
}
.admin-card--wide { grid-column: 1 / -1; }

.admin-card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.1px;
  margin-bottom: 12px;
}
.admin-card h2 svg.lucide { width: 15px; height: 15px; color: var(--accent); }
.admin-card h2 .count { font-size: 11px; font-weight: 500; color: var(--t3); margin-left: auto; }

.admin-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-row .input { flex: 1; }

.admin-hint { font-size: 11.5px; color: var(--t3); margin-top: 8px; }

.admin-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.admin-list-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  font-size: 12.5px;
}
.admin-list-item .mono { font-size: 11.5px; color: var(--t2); }
.admin-list-item .spacer { flex: 1; }
.admin-list-empty { font-size: 12px; color: var(--t3); padding: 8px 2px; }

.icon-btn--danger:hover { background: color-mix(in srgb, var(--urgent) 12%, transparent); color: var(--urgent); }

/* Selector de icono/color para nuevas categorías */
.icon-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

/* Catálogo completo de Lucide: grilla acotada con scroll propio */
.icon-grid--scroll {
  max-height: 158px; /* ~4 filas */
  overflow-y: auto;
  padding: 2px;
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
}
.icon-grid-note { font-size: 11px; color: var(--t3); margin-top: 6px; }

.color-row { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.color-custom { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; cursor: pointer; }
.color-custom input[type="color"] {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.color-custom input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-custom input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.color-custom .mono { font-size: 11.5px; color: var(--t2); }

/* Lista de categorías compacta: crece hasta un tope y luego scrollea */
#category-list { max-height: 236px; overflow-y: auto; }
.icon-option {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--t2);
  transition: all .12s var(--ease);
}
.icon-option svg.lucide { width: 14px; height: 14px; }
.icon-option:hover { color: var(--t1); border-color: var(--border); }
.icon-option.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.color-option {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease);
}
.color-option:hover { transform: scale(1.15); }
.color-option.is-active { box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--oc); }

/* Tabla de reportes */
.admin-table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 760px; }
.admin-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
  height: 38px;
}
.admin-table tr:hover td { background: var(--bg3); }
.admin-table .title-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.admin-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Modal de oficio + diálogo de confirmación */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
}
.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 22px;
  animation: scaleIn .2s var(--spring);
}
.modal-box h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.modal-box h2 svg.lucide { width: 16px; height: 16px; color: var(--accent); }
.modal-sub { font-size: 12px; color: var(--t3); margin-bottom: 12px; }
.modal-box textarea.input { min-height: 260px; font-size: 12.5px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.modal-actions .btn--ghost { margin-right: auto; }

.dialog-box { max-width: 380px; text-align: center; }
.dialog-box .dialog-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--urgent) 12%, transparent);
  color: var(--urgent);
}
.dialog-box h2 { justify-content: center; }
.dialog-box p { font-size: 13px; color: var(--t2); margin: 6px 0 14px; }
.dialog-box .modal-actions { justify-content: center; }
.dialog-box .modal-actions .btn--ghost { margin-right: 0; }

.btn--danger {
  background: color-mix(in srgb, var(--urgent) 10%, transparent);
  color: var(--urgent);
  border: 1px solid color-mix(in srgb, var(--urgent) 25%, transparent);
}
.btn--danger:hover { background: color-mix(in srgb, var(--urgent) 18%, transparent); transform: translateY(-1px); }

/* Login del panel */
.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.admin-login .modal-box { max-width: 380px; }

@media (max-width: 768px) {
  .admin-main { grid-template-columns: 1fr; padding: 12px; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
