/* =========================================================================
   Contexto Municipal · Sistema de diseño y estilos premium
   Inspirado en la estética moderna de Magnific / Freepik Detail View
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Paleta base (Dark Mode de alta fidelidad) */
  --bg-main: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #151d30;
  --bg-card-hover: #1c263e;
  --bg-glass: rgba(17, 24, 39, 0.78);
  --bg-glass-elevated: rgba(22, 32, 53, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-glow: rgba(255, 170, 51, 0.35);

  /* Acentos y gradientes */
  --accent-primary: #ff8a3d;
  --accent-secondary: #ffb84d;
  --accent-amber: #f59e0b;
  --accent-gold: #ffd166;
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-crimson: #f43f5e;

  /* Gradiente insignia Magnific/Freepik Style */
  --grad-hero: linear-gradient(135deg, #ffd166 0%, #ff8a3d 50%, #f43f5e 100%);
  --grad-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0) 100%);
  --grad-glow: radial-gradient(circle at 50% 0%, rgba(255, 138, 61, 0.15) 0%, transparent 70%);

  /* Regiones Naturales de Colombia */
  --region-andina: #10b981;
  --region-caribe: #0ea5e9;
  --region-pacifica: #8b5cf6;
  --region-orinoquia: #f59e0b;
  --region-amazonia: #059669;
  --region-insular: #06b6d4;

  /* Tipografía */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Texto */
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inv: #0b0f19;

  /* Sombras */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.1);
  --shadow-glow: 0 0 24px rgba(255, 138, 61, 0.25);

  /* Bordes redondeados */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Transiciones */
  --tr-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-smooth: 280ms cubic-bezier(0.16, 1, 0.3, 1);
  --tr-spring: 450ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================================
   Reset y configuración base
   ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  background-image: var(--grad-glow);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  user-select: none;
}

ul, ol {
  list-style: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Iconos SVG inline */
.ico {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.ico--sm { width: 14px; height: 14px; }
.ico--lg { width: 22px; height: 22px; }
.ico--fav { stroke: var(--accent-crimson); fill: var(--accent-crimson); }

/* =========================================================================
   Barra de Navegación Superior (Header estilo Freepik/Magnific)
   ========================================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.75rem;
  transition: background-color var(--tr-smooth), border-color var(--tr-smooth);
}

.header-inner {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  transition: transform var(--tr-fast);
}
.brand:hover {
  transform: translateY(-1px);
}

.brand-symbol {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--grad-hero);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(255, 138, 61, 0.4);
}
.brand-symbol svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2.2;
}

.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  background: linear-gradient(135deg, #ffffff 60%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  font-size: 0.72rem;
  color: var(--accent-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Barra de búsqueda central */
.search {
  position: relative;
  flex: 1;
  max-width: 580px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast), background-color var(--tr-fast);
}
.search-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18);
  background: var(--bg-card);
}

.search-input {
  flex: 1;
  color: var(--text-main);
  font-size: 0.95rem;
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Resultados desplegables de búsqueda */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  z-index: 200;
  padding: 0.4rem;
}

.sr {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--tr-fast);
}
.sr:hover, .sr.is-active {
  background: var(--bg-card-hover);
}
.sr__thumb {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sr__thumb .thumb-shape {
  fill: url(#mc-thumb-grad);
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 0.5;
}
.sr__text {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.sr__text b {
  color: #ffffff;
  font-size: 0.95rem;
}
.sr__text small {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.sr__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}
.sr--empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Acciones en header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Botones genéricos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--tr-fast);
  white-space: nowrap;
}

.btn--primary {
  background: var(--grad-hero);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(255, 138, 61, 0.35);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 138, 61, 0.5);
}
.btn--primary:active {
  transform: translateY(0);
}

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn--secondary:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
}

.btn--ghost {
  color: var(--text-secondary);
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.btn--icon:hover {
  background: var(--bg-card);
  color: #ffffff;
  border-color: var(--border-medium);
}
.btn--icon.is-on {
  color: var(--accent-crimson);
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn--lg {
  padding: 0.75rem 1.35rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}
.btn--sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-xs);
}

.btn-badge {
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.btn--accent {
  background: linear-gradient(135deg, #ffd166 0%, #ff9f4a 100%);
  color: #0b0f19 !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 14px rgba(255, 209, 102, 0.35);
  border: none !important;
}
.btn--accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 209, 102, 0.55);
  filter: brightness(1.05);
}
.btn--accent:active {
  transform: translateY(0);
}

/* =========================================================================
   Contenedor Principal y Estructura Split (Detalle Freepik/Magnific)
   ========================================================================= */
.main-wrapper {
  max-width: 1880px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3.5rem;
  width: 100%;
  flex: 1;
}

/* Breadcrumb elegante */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  transition: color var(--tr-fast);
  cursor: pointer;
}
.crumb:hover {
  color: #ffffff;
}
.crumb__sep {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.crumb--static {
  cursor: default;
  color: var(--text-muted);
}
.crumb--current {
  color: #ffffff;
  font-weight: 600;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rc, var(--accent-primary));
  display: inline-block;
}

/* Layout 2 Columnas: Izquierda Mapa/Visualizador (ampliado), Derecha Ficha/Acciones */
.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 375px;
  gap: 1.5rem;
  align-items: start;
}

/* =========================================================================
   Columna Izquierda: Visualizador del Mapa
   ========================================================================= */
.viewer-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--tr-fast);
}

.map-viewport {
  position: relative;
  width: 100%;
  height: clamp(740px, 80vh, 920px);
  min-height: 720px;
  background: radial-gradient(circle at center, #172138 0%, #0d1322 100%);
  cursor: grab;
  user-select: none;
}
.map-viewport:active {
  cursor: grabbing;
}

/* Estilos internos del SVG del Mapa */
.map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mpio {
  fill: #1a253d;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 0.45;
  transition: fill 180ms ease, opacity 180ms ease;
  vector-effect: non-scaling-stroke;
}
.mpio:hover {
  fill: #2c3a59;
}
.mpio.in-dept {
  fill: #243350;
  stroke: rgba(255, 255, 255, 0.16);
}
.mpio.has-ctx {
  fill: #1b3834;
}
.mpio.has-ctx.in-dept {
  fill: #214d44;
}

.dept-borders {
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 0.9;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
.country-outline {
  fill: none;
  stroke: rgba(255, 255, 255, 0.6);
  stroke-width: 1.2;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.dept-focus {
  fill: none;
  stroke: rgba(255, 170, 51, 0.3);
  stroke-width: 2.2;
  stroke-dasharray: 4 4;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.mpio-hover {
  fill: rgba(255, 255, 255, 0.12);
  stroke: #ffffff;
  stroke-width: 1.2;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.mpio-selected {
  stroke: #ffffff;
  stroke-width: 1.8;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.mpio-pulse {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 3.5;
  pointer-events: none;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
  animation: pulse-ring 2.4s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  50% { opacity: 0.3; }
  100% { transform: scale(1.04); opacity: 0; }
}

/* Rótulos de departamentos en el mapa */
.dept-labels-layer {
  pointer-events: none;
}
.dept-label-node {
  pointer-events: auto;
  cursor: pointer;
}
.dept-name-text {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  fill: rgba(255, 255, 255, 0.78);
  paint-order: stroke fill;
  stroke: rgba(11, 15, 25, 0.88);
  stroke-width: 3.2px;
  stroke-linejoin: round;
  transition: all var(--tr-fast);
  user-select: none;
}
.dept-label-node:hover .dept-name-text {
  fill: #ffaa33;
  filter: drop-shadow(0 2px 8px rgba(255, 170, 51, 0.5));
}
.dept-name-text.is-selected {
  font-weight: 900;
  letter-spacing: 0.14em;
  stroke-width: 4px;
}

/* Marcadores de Capitales departamentales y nacional */
.capital-markers-layer {
  pointer-events: none;
}
.capital-marker-node {
  pointer-events: auto;
  cursor: pointer;
  transition: transform var(--tr-fast);
}
.capital-marker-node:hover {
  filter: drop-shadow(0 2px 6px rgba(255, 209, 102, 0.7));
}
.capital-star {
  fill: var(--accent-gold);
  stroke: #0b0f19;
  stroke-width: 0.8px;
}
.capital-name-text {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  fill: #ffffff;
  paint-order: stroke fill;
  stroke: rgba(11, 15, 25, 0.9);
  stroke-width: 2.6px;
  stroke-linejoin: round;
  user-select: none;
}

/* Capital nacional (Bogotá) */
.capital-marker-node.is-national .capital-nat-ring {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 1.5px;
  stroke-dasharray: 2 1;
}
.capital-marker-node.is-national .capital-nat-bg {
  fill: rgba(244, 63, 94, 0.95);
  stroke: #ffffff;
  stroke-width: 1.2px;
}
.capital-marker-node.is-national .capital-star.is-nat {
  fill: #ffffff;
  stroke: none;
}
.capital-name-text.is-nat {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  fill: var(--accent-gold);
  stroke-width: 3.2px;
}

/* Rótulos en miniatura para municipios seleccionados */
.selected-mpio-labels-layer {
  pointer-events: none;
  user-select: none;
}
.selected-mpio-label-node {
  pointer-events: none;
  user-select: none;
  transition: opacity 0.2s ease;
}
.selected-mpio-label-bg {
  fill: rgba(10, 16, 28, 0.92);
  stroke-width: 1.4px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.7));
}
.selected-mpio-label-dot {
  stroke: #ffffff;
  stroke-width: 0.8px;
}
.selected-mpio-label-text {
  font-family: var(--font-sans, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.25px;
  fill: #ffffff;
  paint-order: stroke fill;
  stroke: rgba(10, 16, 28, 0.95);
  stroke-width: 2.2px;
  stroke-linejoin: round;
  user-select: none;
}

/* Líneas y resaltados de multiselección en el mapa */
.multi-dept-layer {
  pointer-events: none;
}
.multi-dept-contour {
  pointer-events: none;
}
.mpio.is-multisel {
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
  transition: fill 200ms ease, stroke 200ms ease;
}
.mpio.in-multisel-dept {
  transition: fill 200ms ease, stroke 200ms ease;
  cursor: pointer;
}
.mpio.in-multisel-dept:hover {
  fill: rgba(255, 255, 255, 0.12) !important;
  stroke: var(--accent-primary) !important;
  stroke-width: 1.8px !important;
}

/* Controles sobre el mapa */
.map-controls-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
  gap: 0.75rem;
}
.map-controls-overlay > * {
  pointer-events: auto;
}

.map-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.segmented-modes {
  display: inline-flex;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  gap: 0.25rem;
  align-items: center;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  transition: all var(--tr-fast);
}
.mode-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}
.mode-btn[aria-pressed="true"],
.mode-btn.is-active {
  background: var(--grad-hero);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255, 138, 61, 0.3);
}

.tool-count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 0.25rem;
}

/* =========================================================================
   Columna Izquierda: Visor del Mapa + Panel de Selección Separado
   ========================================================================= */
.viewer-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
  width: 100%;
}

/* Tarjeta Externa de Selección Múltiple (FUERA del mapa) */
.selection-panel-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slide-up 240ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.selection-panel-card[hidden] {
  display: none !important;
}

/* Barra superior: resumen, paleta grupal y acciones */
.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 26, 44, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.selection-bar__left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.selection-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 138, 61, 0.15);
  border: 1px solid rgba(255, 138, 61, 0.4);
  color: #ffffff;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.selection-badge .ico {
  color: var(--accent-primary);
}

.palette-container {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.palette-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.palette-swatches {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.palette-swatch-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: transform var(--tr-fast), border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.palette-swatch-btn:hover {
  transform: scale(1.25);
  border-color: #ffffff;
  box-shadow: 0 0 10px currentColor;
}

.custom-color-picker {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  overflow: hidden;
  transition: background var(--tr-fast);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
.custom-color-picker:hover {
  background: rgba(255, 255, 255, 0.25);
}
.custom-color-picker input[type="color"] {
  position: absolute;
  inset: -10px;
  width: 44px;
  height: 44px;
  opacity: 0;
  cursor: pointer;
}
.color-picker-icon {
  font-size: 0.75rem;
  pointer-events: none;
}

.selection-bar__right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.btn--danger-outline {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #ff6b81;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--tr-fast);
  cursor: pointer;
}
.btn--danger-outline:hover {
  background: rgba(244, 63, 94, 0.25);
  border-color: #f43f5e;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(244, 63, 94, 0.35);
}

/* =========================================================================
   Contenedor y Bloques Departamentales
   ========================================================================= */
.selected-departments-container {
  padding: 1.15rem 1.25rem;
  background: rgba(11, 16, 28, 0.95);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  width: 100%;
}

/* Scrollbar estilizado */
.selected-departments-container::-webkit-scrollbar {
  width: 6px;
}
.selected-departments-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.selected-departments-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
.selected-departments-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Bloque individual de un departamento */
.dept-selection-block {
  background: rgba(18, 25, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3.5px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all var(--tr-fast);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.dept-selection-block:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(22, 31, 52, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dept-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dept-block-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dept-block-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: rgba(6, 182, 212, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.35);
  letter-spacing: 0.06em;
}

.dept-block-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: color var(--tr-fast);
}
.dept-block-name:hover {
  color: var(--accent-gold);
  text-decoration: underline;
}

.dept-block-count {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

.dept-block-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dept-whole-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.5rem;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: var(--radius-xs);
  font-size: 0.74rem;
}

.btn-clear-dept-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #ff6b81;
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.btn-clear-dept-group:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: #f43f5e;
  color: #ffffff;
}

/* Grilla de municipios dentro del bloque */
.dept-block-mpios {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.multisel-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  background: #172238;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #ffffff;
  transition: all var(--tr-fast);
}
.multisel-chip:hover {
  background: #1f2e4b;
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.chip-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip-tag--dept {
  background: rgba(6, 182, 212, 0.22);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.35);
}
.chip-tag--mpio {
  background: rgba(255, 138, 61, 0.2);
  color: #fb923c;
  border: 1px solid rgba(255, 138, 61, 0.35);
}

.chip-name {
  font-weight: 600;
  cursor: pointer;
}
.chip-name:hover {
  color: #ffd166;
  text-decoration: underline;
}

.chip-color-wrapper {
  position: relative;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  cursor: pointer;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  transition: transform var(--tr-fast);
}
.chip-color-wrapper:hover {
  transform: scale(1.22);
}
.chip-color-input {
  position: absolute;
  inset: -6px;
  width: 32px;
  height: 32px;
  opacity: 0;
  cursor: pointer;
}

.chip-remove {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--tr-fast);
  background: rgba(255, 255, 255, 0.06);
  border: none;
}
.chip-remove:hover {
  color: #ffffff;
  background: #f43f5e;
  transform: scale(1.15);
}




.zoom-group {
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.zoom-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
}
.zoom-btn:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
}
.zoom-btn:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}
.zoom-btn[aria-pressed="true"] {
  background: rgba(255, 138, 61, 0.2);
  color: var(--accent-primary);
}

/* Modo maximizado / Pantalla Completa del Visor de Mapa */
.viewer-card.is-maximized {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  box-shadow: none !important;
  background: #090d16 !important;
  display: flex !important;
  flex-direction: column !important;
}

.viewer-card.is-maximized .map-viewport {
  flex: 1 1 0 !important;
  height: auto !important;
  min-height: 0 !important;
}

.viewer-card.is-maximized .map-bottom-panel {
  flex-shrink: 0 !important;
}

.viewer-card.is-maximized .viewer-footer {
  flex-shrink: 0 !important;
}

body:has(.viewer-card.is-maximized) {
  overflow: hidden !important;
}

/* Minimapa / Locator */
.map-locator {
  position: absolute;
  bottom: 3.6rem;
  right: 1.25rem;
  width: 130px;
  height: 140px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}
.map-locator svg {
  width: 100%;
  height: 100%;
}
.loc-land { fill: rgba(255, 255, 255, 0.08); }
.loc-depts { fill: none; stroke: rgba(255, 255, 255, 0.15); stroke-width: 0.6; }
.loc-view { fill: rgba(255, 138, 61, 0.2); stroke: var(--accent-primary); stroke-width: 1.5; }
.loc-dot { fill: var(--accent-crimson); stroke: #ffffff; stroke-width: 3; }

/* Tooltip flotante en el mapa */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xs);
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #ffffff;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -130%);
  z-index: 50;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: opacity 120ms ease;
}
.map-tooltip b { font-size: 0.9rem; }
.map-tooltip span { color: var(--text-secondary); font-size: 0.75rem; }
.map-tooltip i { color: var(--accent-emerald); font-style: normal; font-size: 0.72rem; }

/* Barra inferior del visualizador */
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.viewer-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* =========================================================================
   Columna Derecha: Panel Lateral (Ficha de Detalle estilo Freepik)
   ========================================================================= */
.sidebar-wrapper {
  position: sticky;
  top: 5rem;
}

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-sizing: border-box;
  width: 100%;
}

.side-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.side-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pill--region {
  background: rgba(255, 255, 255, 0.06);
  color: var(--rc, var(--accent-primary));
  border: 1px solid currentColor;
}
.pill--gold {
  background: rgba(255, 209, 102, 0.12);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 209, 102, 0.3);
}

/* Silueta miniatura del municipio */
.side-glyph {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 4px;
  flex-shrink: 0;
}
.side-glyph .thumb-shape {
  fill: url(#mc-thumb-grad);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 0.75;
}

.side-title {
  font-family: var(--font-display);
  font-size: 1.95rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: #ffffff;
}

/* =========================================================================
   Selector Dual y Desplegable con Pestañas (Municipio & Departamento)
   ========================================================================= */
.dept-selector-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 20;
}
.dept-selector-wrap.is-open {
  z-index: 295;
}

.dual-selector-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.selector-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--tr-fast);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.selector-tab-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}
.selector-tab-btn[aria-expanded="true"] {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(255, 138, 61, 0.25);
}
.selector-tab-icon {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: var(--radius-xs);
  background: rgba(255, 138, 61, 0.14);
  color: var(--accent-primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.selector-tab-btn .dept-avatar {
  width: 26px;
  height: 26px;
  min-width: 26px;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: var(--radius-xs);
  background: rgba(6, 182, 212, 0.16);
  border: 1px solid rgba(6, 182, 212, 0.35);
  color: #38bdf8;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.selector-tab-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.selector-tab-text small {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.selector-tab-text b {
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.selector-chevron {
  color: var(--text-muted);
  transition: transform var(--tr-fast), color var(--tr-fast);
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}
.selector-tab-btn[aria-expanded="true"] .selector-chevron {
  transform: rotate(90deg);
  color: var(--accent-primary);
}

/* Backdrop para cerrar al hacer clic afuera */
.dept-backdrop {
  position: fixed;
  inset: 0;
  z-index: 280;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in 140ms ease;
}
.dept-backdrop[hidden],
.dept-backdrop.is-hidden {
  display: none !important;
}

/* Menú desplegable flotante */
.dept-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), 0 20px 48px rgba(0, 0, 0, 0.75);
  z-index: 300;
  max-height: 440px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drop-slide 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.dept-dropdown[hidden],
.dept-dropdown.is-hidden {
  display: none !important;
}
@keyframes drop-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dept-drop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.5rem;
}

.dept-drop-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px;
  border-radius: var(--radius-xs);
  gap: 3px;
  flex: 1;
}
.drop-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
  white-space: nowrap;
}
.drop-tab:hover {
  color: #ffffff;
}
.drop-tab.is-active {
  background: var(--bg-card);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.drop-close-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--tr-fast);
}
.drop-close-btn:hover {
  background: rgba(244, 63, 94, 0.18);
  color: var(--accent-crimson);
}

.dept-drop-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-subtle);
}
.dept-drop-search-wrap .ico {
  color: var(--text-muted);
}
.dept-drop-input {
  flex: 1;
  font-size: 0.85rem;
  color: #ffffff;
}
.dept-drop-input::placeholder {
  color: var(--text-muted);
}
.dept-drop-clear {
  color: var(--text-muted);
  padding: 2px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.dept-drop-clear:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.dept-drop-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dept-drop-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dept-drop-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dept-drop-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--text-main);
  text-align: left;
  transition: all var(--tr-fast);
  cursor: pointer;
}
.dept-drop-item:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
}
.dept-drop-item.is-current {
  background: rgba(255, 138, 61, 0.14);
  color: var(--accent-primary);
  font-weight: 600;
}
.dept-drop-item.is-multisel-row {
  background: rgba(255, 255, 255, 0.06);
  border-left: 2.5px solid var(--accent-primary);
}

.drop-item-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.drop-item-check {
  width: 19px;
  height: 19px;
  border-radius: 4px;
  border: 1.5px solid var(--border-medium);
  background: rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  color: transparent;
  cursor: pointer;
  transition: all var(--tr-fast);
  padding: 0;
  flex-shrink: 0;
}
.drop-item-check:hover {
  border-color: var(--accent-primary);
  background: rgba(255, 138, 61, 0.15);
}
.drop-item-check.is-checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
}
.drop-item-check .ico {
  width: 13px;
  height: 13px;
  stroke-width: 3;
}

.drop-item-color {
  position: relative;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  transition: transform var(--tr-fast);
}
.drop-item-color:hover {
  transform: scale(1.2);
  border-color: #ffffff;
}
.drop-item-color-input {
  position: absolute;
  inset: -6px;
  width: 30px;
  height: 30px;
  opacity: 0;
  cursor: pointer;
}

.dept-drop-item__name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dept-drop-item__badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.dept-drop-item.is-current .dept-drop-item__badge {
  background: rgba(255, 138, 61, 0.25);
  color: var(--accent-primary);
}
.dept-drop-item__star {
  color: var(--accent-gold);
}
.dept-drop-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
}
.dept-drop-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Botones de acción principales */
.side-actions {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.5rem;
}

/* Anillo de progreso de completado */
.progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.ring-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring__bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 5;
}
.ring__fg {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
}
.progress__text {
  display: flex;
  flex-direction: column;
}
.progress__text b {
  font-size: 0.9rem;
  color: #ffffff;
}
.progress__text span {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Lista de hechos / Metadatos */
.facts {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 0;
}
.facts__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  font-size: 0.85rem;
}
.facts dt {
  color: var(--text-muted);
}
.facts dd {
  color: var(--text-main);
  font-weight: 500;
  text-align: right;
}
.code-chip {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  color: var(--accent-gold);
}
.muted {
  color: var(--text-muted);
}

/* Bloques laterales (Tags y Enlaces) */
.side-block {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.side-block__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Etiquetas interactivas */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}
.tag--auto {
  border: 1px solid var(--border-subtle);
}
.tag--user {
  background: rgba(255, 138, 61, 0.14);
  color: var(--accent-primary);
  border: 1px solid rgba(255, 138, 61, 0.3);
  padding-right: 0.3rem;
  gap: 0.3rem;
}
.tag__text {
  color: inherit;
  font-weight: 500;
}
.tag__remove {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: inherit;
  opacity: 0.7;
  transition: opacity var(--tr-fast);
}
.tag__remove:hover { opacity: 1; }
.tag-input input {
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  color: var(--text-main);
  width: 120px;
  transition: all var(--tr-fast);
}
.tag-input input:focus {
  width: 160px;
  border-color: var(--accent-primary);
  border-style: solid;
}

/* Enlaces externos rápidos de investigación */
.links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
}
.link-card:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
  border-color: var(--border-medium);
}
.link-card span {
  flex: 1;
  text-align: left;
}

/* =========================================================================
   Sección Inferior: Editor de Contexto Municipal
   ========================================================================= */
.editor-section {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.save-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}
.save-status-pill[data-state="saving"] span { color: var(--accent-amber); }
.save-status-pill[data-state="saved"] span { color: var(--accent-emerald); }
.save-status-pill[data-state="error"] span { color: var(--accent-crimson); }

/* Cuadrícula de secciones del editor */
.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.sec {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
  position: relative;
}
.sec:focus-within {
  border-color: hsl(var(--hue, 40), 90%, 55%);
  box-shadow: 0 0 0 3px hsla(var(--hue, 40), 90%, 55%, 0.12);
}
.sec.is-filled {
  border-color: rgba(255, 255, 255, 0.12);
}
.sec--wide {
  grid-column: 1 / -1;
}

.sec__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.sec__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: hsla(var(--hue, 40), 85%, 55%, 0.14);
  color: hsl(var(--hue, 40), 90%, 65%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sec__title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
}
.sec__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sec__input {
  width: 100%;
  min-height: 90px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  transition: background-color var(--tr-fast), border-color var(--tr-fast);
}
.sec--wide .sec__input {
  min-height: 110px;
}
.sec__input:focus {
  background: #0f1523;
  border-color: rgba(255, 255, 255, 0.2);
}
.sec__input::placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* =========================================================================
   Sección Municipios Relacionados (Tarjetas tipo Vector Freepik)
   ========================================================================= */
.related-section {
  margin-top: 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.related__group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.15rem;
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform var(--tr-smooth), border-color var(--tr-smooth), box-shadow var(--tr-smooth);
  cursor: pointer;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}
.card.has-ctx {
  border-color: rgba(16, 185, 129, 0.35);
}

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.85;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card__thumb svg {
  width: 75%;
  height: 75%;
}
.card__thumb .thumb-shape {
  fill: url(#mc-thumb-grad);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 0.6;
}
.card__chip {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-gold);
}
.card__star {
  position: absolute;
  top: 6px;
  left: 6px;
  color: var(--accent-gold);
}

.card__body {
  display: flex;
  flex-direction: column;
}
.card__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card__bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-emerald);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 300ms ease;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* =========================================================================
   Sección Explorador Regional y Departamental
   ========================================================================= */
.explore-section {
  margin-top: 3.5rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.regions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.region {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.region__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
}
.region__title .muted {
  margin-left: auto;
  font-size: 0.8rem;
}

.region__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.dept-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
}
.dept-chip:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
  border-color: var(--border-medium);
}
.dept-chip__iso {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-primary);
}
.dept-chip__count {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* =========================================================================
   Modal de "Mis Contextos" (<dialog>)
   ========================================================================= */
.modal-dialog {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  color: var(--text-main);
  padding: 0;
  max-width: 680px;
  width: 92vw;
  max-height: 88vh;
  margin: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}
.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal-dialog.admin-dialog {
  max-width: 1080px;
  width: 95vw;
}

.modal-dialog.export-dialog {
  max-width: 620px;
  width: 92vw;
}

.modal-dialog.login-dialog {
  max-width: 440px;
  width: 92vw;
}
.modal-dialog.login-dialog::backdrop {
  background: rgba(7, 10, 19, 0.88);
  backdrop-filter: blur(8px);
}

.dialog-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 88vh;
  overflow: hidden;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.dialog-header h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
}

.dialog-filter-bar {
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}
.dialog-filter-bar input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.88rem;
}
.dialog-filter-bar input:focus {
  border-color: var(--accent-primary);
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1.5rem;
}

.ctx-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left;
  transition: all var(--tr-fast);
}
.ctx-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}
.ctx-item__thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.ctx-item__thumb .thumb-shape {
  fill: url(#mc-thumb-grad);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 0.7;
}
.ctx-item__main {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ctx-item__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.ctx-item__meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.ctx-item__tags {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.ctx-item__tags em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--accent-primary);
}
.ctx-item__progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}
.ctx-item__progress i {
  width: 48px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  position: relative;
  overflow: hidden;
}
.ctx-item__progress i::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: calc(var(--p, 0) * 100%);
  background: var(--accent-emerald);
}
.ctx-item__progress small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ctx-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.ctx-empty .ico {
  width: 38px;
  height: 38px;
  opacity: 0.5;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* =========================================================================
   Pantalla de Carga y Errores (Loader)
   ========================================================================= */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  transition: opacity 350ms ease, visibility 350ms ease;
}
.loader-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-primary);
  animation: spin 900ms linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #ffffff;
}
.loader-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 420px;
  text-align: center;
}

.loader-fallback {
  margin-top: 1rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.loader-fallback code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-crimson);
  word-break: break-all;
}

/* =========================================================================
   Toasts y Notificaciones
   ========================================================================= */
.toasts-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-medium);
  color: #ffffff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  animation: slide-up 260ms cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform var(--tr-fast), opacity var(--tr-fast);
}
.toast--ok .ico { color: var(--accent-emerald); }
.toast--error .ico { color: var(--accent-crimson); }
.toast.is-leaving {
  opacity: 0;
  transform: translateY(10px);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   Footer Global
   ========================================================================= */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 2rem 1.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* =========================================================================
   Animaciones de entrada y Responsividad
   ========================================================================= */
.anim-in {
  animation: fade-in 350ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
  .sidebar-wrapper {
    position: static;
  }
  .map-viewport {
    height: 620px;
    min-height: 540px;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0.65rem 1rem;
  }
  .header-inner {
    flex-wrap: wrap;
  }
  .search {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .main-wrapper {
    padding: 1rem 1rem 3rem;
  }
  .map-viewport {
    height: 500px;
    min-height: 440px;
  }
  .side-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* =========================================================================
   Estilos del Diálogo de Exportación de Imagen (PNG/JPG)
   ========================================================================= */
.export-opt-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.export-opt-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.export-format-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.format-pill {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--tr-fast);
}
.format-pill:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.04);
}
.format-pill input[type="radio"] {
  margin-top: 0.25rem;
  accent-color: var(--accent-primary);
  cursor: pointer;
}
.format-pill.is-active,
.format-pill:has(input:checked) {
  border-color: var(--accent-primary);
  background: rgba(255, 138, 61, 0.08);
}
.format-pill__content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.format-pill__content strong {
  font-size: 0.9rem;
  color: #ffffff;
}
.format-pill__content small {
  font-size: 0.74rem;
  line-height: 1.3;
}

.export-feature-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.export-feature-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
}
.feature-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}
.export-feature-item div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.export-feature-item strong {
  font-size: 0.84rem;
  color: #ffffff;
}

.export-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.export-check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all var(--tr-fast);
}
.export-check-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}
.export-check-item input[type="checkbox"] {
  margin-top: 0.15rem;
  accent-color: var(--accent-primary);
  cursor: pointer;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.export-check-item span strong {
  color: #ffffff;
}
.export-feature-item small {
  font-size: 0.74rem;
}

.export-summary-box {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* =========================================================================
   Perfil y Menú de Sesión en Header
   ========================================================================= */
.user-menu-wrapper {
  position: relative;
}

.user-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 0.28rem 0.75rem 0.28rem 0.35rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--tr-fast);
  box-shadow: var(--shadow-sm);
}

.user-profile-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 170, 51, 0.4);
  box-shadow: 0 0 12px rgba(255, 138, 61, 0.2);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8a3d, #ffd166);
  color: #0b0f19;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.user-info-text {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1;
}

.user-display-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  background: rgba(255, 138, 61, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(255, 138, 61, 0.3);
}

.user-role-badge.is-user {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.3);
}

.user-chevron {
  color: var(--text-muted);
  transition: transform var(--tr-fast);
}

.user-profile-btn[aria-expanded="true"] .user-chevron {
  transform: rotate(180deg);
}

/* Menú Desplegable */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--bg-glass-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  padding: 0.6rem;
  z-index: 999;
  animation: fadeInDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 0.65rem 0.5rem;
}

.user-dropdown-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8a3d, #ffd166);
  color: #0b0f19;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-dropdown-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-dropdown-details strong {
  font-size: 0.88rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-details .muted {
  font-size: 0.74rem;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.4rem 0;
}

.user-dropdown-items {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.dropdown-item .ico {
  color: var(--text-muted);
}

.dropdown-item:hover .ico {
  color: var(--accent-primary);
}

.dropdown-item--danger:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
}

.dropdown-item--danger:hover .ico {
  color: #fda4af;
}

/* =========================================================================
   Modal de Inicio de Sesión
   ========================================================================= */
.login-dialog {
  max-width: 440px;
}

.login-header {
  border-bottom: 1px solid var(--border-subtle);
}

.login-brand-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.login-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.login-alert {
  padding: 0.75rem 1rem;
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-sm);
  color: #fda4af;
  font-size: 0.82rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-with-ico {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-ico .ico {
  position: absolute;
  left: 0.85rem;
  color: var(--text-muted);
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.input-with-ico input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.88rem;
  transition: all var(--tr-fast);
}

.input-with-ico input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.2);
}

.login-quick-fill {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-subtle);
}

.quick-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-pills button {
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
  flex: 1;
}

.btn--full {
  width: 100%;
}

/* =========================================================================
   Modal de Panel de Administrador
   ========================================================================= */
.admin-badge-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.2), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(255, 138, 61, 0.35);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(88vh - 140px);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  width: 100%;
}

@media (max-width: 860px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}

.admin-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.admin-stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}

.admin-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-search-wrapper {
  flex: 1;
  min-width: 220px;
}

.admin-search-wrapper input {
  width: 100%;
  padding: 0.5rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.84rem;
}

.admin-search-wrapper input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Formulario de creación de usuario */
.admin-create-card {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  animation: fadeInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-create-header h4 {
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 600;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
}

.admin-form-grid input,
.admin-select {
  padding: 0.55rem 0.75rem;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: #ffffff;
  font-size: 0.84rem;
  width: 100%;
}

.admin-form-grid input:focus,
.admin-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.admin-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* Tabla de Usuarios */
.admin-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  width: 100%;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
  min-width: 720px;
}

.admin-users-table th {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-users-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.admin-users-table tr:last-child td {
  border-bottom: none;
}

.admin-users-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-cell-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8a3d, #ffd166);
  color: #0b0f19;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.user-cell-avatar.is-user {
  background: linear-gradient(135deg, #06b6d4, #10b981);
}

.user-cell-meta strong {
  color: #ffffff;
  display: block;
  font-size: 0.84rem;
}

.user-cell-meta small {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.role-tag.is-admin {
  background: rgba(255, 138, 61, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(255, 138, 61, 0.3);
}

.role-tag.is-user {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.status-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-tag.is-active {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}
.status-tag.is-active::before {
  background: #10b981;
}

.status-tag.is-disabled {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
}
.status-tag.is-disabled::before {
  background: #f43f5e;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.btn-row-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--tr-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-row-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: var(--border-medium);
}

.btn-row-action.is-danger:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
}

/* =========================================================================
   Estados Vacíos (Standby / Sin selección activa)
   ========================================================================= */
.side-card--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.25rem 1.5rem;
}

.empty-compass-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 138, 61, 0.2) 0%, rgba(255, 138, 61, 0.05) 70%);
  border: 1px solid rgba(255, 138, 61, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(255, 138, 61, 0.25);
  animation: pulseGlow 3s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 138, 61, 0.2); }
  50% { transform: scale(1.05); box-shadow: 0 0 32px rgba(255, 138, 61, 0.4); }
}

.empty-facts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
  text-align: left;
}

.empty-fact-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all var(--tr-fast);
}

.empty-fact-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.empty-fact-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.empty-fact-item strong {
  display: block;
  font-size: 0.84rem;
  color: #ffffff;
}

.empty-fact-item small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.editor-empty-placeholder {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
}

.editor-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.editor-empty-placeholder h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 0.4rem;
}

.editor-empty-placeholder p {
  font-size: 0.88rem;
  max-width: 520px;
}


