:root {
  --verde-musgo-profundo: #457724;
  --verde-olivo: #75aa52;
  --gris-pizarra: #334155;
  --sombra: rgba(0, 0, 0, 0.08);
}

.contenedor-vertical {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 20px;
}

/* ========================================================
   TABLERO SUPERIOR DE ESTADÍSTICAS
   ======================================================== */
.tablero-superior {
  width: 100%;
  height: auto;
  min-height: 120px;
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
}

.estadistica-box {
  flex: 1 1 200px;
  background: #f8f9fa;
  border: 1px solid #edf2f7;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  text-align: center;
}

.estadistica-box h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gris-pizarra);
  margin: 0 0 0.5rem 0;
}

.estadistica-box p {
  font-size: 2rem;
  font-weight: 700;
  color: var(--verde-musgo-profundo);
  margin: 0;
  line-height: 1;
}

/* ========================================================
   MAPA Y CONTENEDOR PRINCIPAL
   ======================================================== */
.mapa-superior {
  width: 100%;
  height: 70vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 15px var(--sombra);
  overflow: hidden;
  position: relative;
}

.mapa-superior #mapa {
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

/* ========================================================
   CONTROL FLOTANTE DE FILTROS EN MAPA (ESTILO LEAFLET)
   ======================================================== */
.control-filtro-mapa {
  position: absolute;
  top: 80px; /* Debajo de los controles estándar de Leaflet */
  right: 10px;
  z-index: 1000;
  font-family: inherit;
}

/* Botón cuadrado idéntico a los controles nativos de Leaflet */
.btn-filtro-flotante {
  width: 34px;
  height: 34px;
  background-color: #ffffff;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333333;
  transition: all 0.2s ease;
}

.btn-filtro-flotante:hover {
  background-color: #f4f4f4;
  color: var(--verde-musgo-profundo);
}

/* Menú desplegable flotante */
.menu-filtro-flotante {
  position: absolute;
  top: 0;
  right: 44px; /* Abre hacia la izquierda */
  width: 290px;
  max-width: 82vw;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  border: 1px solid #d1d5db;
  padding: 14px;
  max-height: 75vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

.menu-filtro-flotante.oculto {
  display: none !important;
}

.menu-filtro-flotante::-webkit-scrollbar {
  width: 5px;
}

.menu-filtro-flotante::-webkit-scrollbar-thumb {
  background-color: #cbd5e0;
  border-radius: 10px;
}

.menu-filtro-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--verde-musgo-profundo);
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
}

.btn-cerrar-filtro {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
}

.btn-cerrar-filtro:hover {
  color: #111827;
}

/* Grupos y controles dentro del filtro flotante */
.filtro-flotante-grupo {
  margin-bottom: 12px;
}

.filtro-flotante-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--verde-musgo-profundo);
  margin-bottom: 5px;
  letter-spacing: 0.3px;
}

.buscador-flotante-wrap {
  width: 100%;
}

.buscador-flotante-wrap input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  box-sizing: border-box;
  background: #f8fafc;
  transition: all 0.2s ease;
}

.buscador-flotante-wrap input:focus {
  outline: none;
  border-color: var(--verde-olivo);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(117, 170, 82, 0.2);
}

.select-filtro-flotante {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  background-color: #f8fafc;
  color: #1e293b;
  cursor: pointer;
}

.select-filtro-flotante:focus {
  outline: none;
  border-color: var(--verde-olivo);
  background-color: #ffffff;
}

.lista-filtros-scroll {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}


/* ========================================================
   ITEMS Y CHECKBOXES DENTRO DEL FILTRO
   ======================================================== */
.checkbox-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.checkbox-item:hover {
  background-color: rgba(46, 125, 50, 0.08);
}

.checkbox-item input {
  margin-right: 10px;
  accent-color: var(--verde-musgo-profundo);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-item label {
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.botones-filtro-flotante {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}

.btn-filtro-accion {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-filtro-accion:hover {
  background-color: var(--verde-musgo-profundo);
  color: #ffffff;
  border-color: var(--verde-musgo-profundo);
}

/* ========================================================
   PANEL INFERIOR (LEYENDA Y DESCARGA)
   ======================================================== */
.panel-inferior-mapa {
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  padding: 1.2rem 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
}

.leyenda {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.leyenda h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--gris-pizarra);
  font-weight: 700;
  margin-right: 0.5rem;
}

.leyenda-item {
  display: flex;
  align-items: center;
  background: #f8f9fa;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  cursor: default;
}

.leyenda-item:hover {
  background: #edf2f7;
  transform: translateY(-1px);
}

[class*="leyenda-color"] {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.leyenda-color1 { background: #ffa07a; }
.leyenda-color2 { background: #ff7f50; }
.leyenda-color3 { background: #ff6347; }
.leyenda-color4 { background: #ff4500; }
.leyenda-color5 { background: #dc143c; }
.leyenda-color6 { background: #b22222; }

.contenedor-botones-descarga {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
}

.btn-descarga-unificada {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-descarga-unificada:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn-descargar-principal {
  background-color: var(--verde-musgo-profundo);
}
.btn-descargar-principal:hover {
  background-color: #33591b;
}

.btn-descargar-imagen {
  background-color: #0d9488;
  color: #ffffff;
}
.btn-descargar-imagen:hover {
  background-color: #0f766e;
}

/* Selector de País en la Barra de Descarga / Acciones */
.selector-pais-barra {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1.5px solid #d1d5db;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  margin-left: 0.35rem;
}

.selector-pais-barra:hover,
.selector-pais-barra:focus-within {
  border-color: var(--verde-musgo-profundo);
  box-shadow: 0 3px 8px rgba(69, 119, 36, 0.2);
}

.selector-pais-barra i,
.selector-pais-barra svg {
  width: 17px;
  height: 17px;
  color: var(--verde-musgo-profundo);
  stroke-width: 2.2;
}

.selector-pais-barra .lbl-pais-texto {
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.selector-pais-barra select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  outline: none;
  padding: 0.2rem 0.4rem;
}

.selector-pais-barra select:focus {
  outline: none;
}



/* ========================================================
   SECCIONES GENERALES Y TIPOGRAFÍA
   ======================================================== */
section {
  padding: 4rem 2rem;
  max-width: 1200px;
  margin: auto;
}

section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  border-left: 6px solid var(--verde-musgo-profundo);
  padding-left: 15px;
  margin-bottom: 1rem;
  color: var(--gris-pizarra);
}

section h2 {
  font-size: 2rem;
  padding-left: 10px;
  margin-bottom: 1.5rem;
  font-weight: 400;
  color: var(--gris-pizarra);
}

/* ========================================================
   RESPONSIVE DESIGN (MÓVILES Y PANTALLAS PEQUEÑAS)
   ======================================================== */
@media (max-width: 768px) {
  .contenedor-vertical {
    padding: 0 10px;
    gap: 12px;
    margin: 0.75rem auto;
  }

  /* Tablero compacto en una sola fila de 3 columnas para no robar espacio al mapa */
  .tablero-superior {
    padding: 0.65rem 0.5rem;
    gap: 0.45rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    min-height: auto;
    border-radius: 10px;
  }

  .estadistica-box {
    padding: 0.5rem 0.3rem;
    border-radius: 8px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .estadistica-box h3 {
    font-size: 0.7rem;
    line-height: 1.15;
    margin: 0 0 0.3rem 0;
  }

  .estadistica-box p {
    font-size: 1.25rem;
    word-break: break-word;
  }

  /* Contenedor del mapa amplio y responsivo */
  .mapa-superior {
    height: 58vh;
    min-height: 380px;
    border-radius: 10px;
  }

  /* Control flotante de filtros adaptado para no salirse de pantalla */
  .control-filtro-mapa {
    top: 10px;
    right: 10px;
  }

  .menu-filtro-flotante {
    right: 0;
    top: 40px;
    width: 270px;
    max-width: calc(100vw - 32px);
  }

  /* Panel inferior y leyenda compacta en 3 columnas */
  .panel-inferior-mapa {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
    gap: 0.85rem;
    border-radius: 10px;
  }

  .leyenda {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem 0.5rem;
    width: 100%;
  }

  .leyenda h3 {
    grid-column: span 3;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    text-align: left;
  }

  .leyenda-item {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  /* Botones de descarga alineados horizontalmente en móvil */
  .contenedor-botones-descarga {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 8px;
  }

  .btn-descargar-principal,
  .btn-descargar-imagen {
    flex: 1;
    width: 50%;
    padding: 0.65rem 0.4rem;
    font-size: 0.82rem;
    text-align: center;
    white-space: nowrap;
    border-radius: 6px;
  }
}

.contenedor-botones-descarga {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Estilo del botón Descargar Imagen */
.btn-descargar-imagen {
  padding: 0.75rem 1.4rem;
  background-color: var(--verde-olivo);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(117, 170, 82, 0.25);
  transition: all 0.2s ease;
}

.btn-descargar-imagen:hover {
  background-color: var(--verde-musgo-profundo);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(69, 119, 36, 0.35);
}

.btn-descargar-imagen:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(69, 119, 36, 0.2);
}

/* ========================================================
   TABLA DE DATOS DE CONFLICTOS Y EXPORTACIÓN DE BASE DE DATOS
   ======================================================== */
.card-tabla-conflictos {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 18px var(--sombra);
  padding: 1.5rem;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-tabla-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 2px solid #edf2f7;
  padding-bottom: 1rem;
}

.card-tabla-titulo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-tabla-titulo svg,
.card-tabla-titulo i {
  color: var(--verde-musgo-profundo);
  width: 28px;
  height: 28px;
}

.card-tabla-titulo h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gris-pizarra);
  margin: 0;
  padding: 0;
}

.card-tabla-titulo p {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0.2rem 0 0 0;
}

.card-tabla-acciones-exportar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-exportar {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: #ffffff;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn-export-sql {
  background-color: #2563eb;
}
.btn-export-sql:hover {
  background-color: #1d4ed8;
  transform: translateY(-2px);
}

.btn-export-json {
  background-color: var(--verde-musgo-profundo);
}
.btn-export-json:hover {
  background-color: #33591b;
  transform: translateY(-2px);
}

.btn-export-csv {
  background-color: var(--verde-olivo);
}
.btn-export-csv:hover {
  background-color: #5d8c3e;
  transform: translateY(-2px);
}

.card-tabla-filtros {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.buscador-tabla-wrap {
  flex: 1;
  min-width: 260px;
  position: relative;
  display: flex;
  align-items: center;
}

.buscador-tabla-wrap i,
.buscador-tabla-wrap svg {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.buscador-tabla-wrap input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.buscador-tabla-wrap input:focus {
  border-color: var(--verde-olivo);
  box-shadow: 0 0 0 3px rgba(117, 170, 82, 0.18);
}

.select-tabla-wrap select {
  padding: 0.65rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--gris-pizarra);
  background: #ffffff;
  outline: none;
  cursor: pointer;
}

.tabla-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  max-height: 520px;
  position: relative;
}

.tabla-datos-conflictos {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.tabla-datos-conflictos thead {
  position: sticky;
  top: 0;
  background-color: #f8fafc;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tabla-datos-conflictos th {
  padding: 0.75rem 0.85rem;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.tabla-datos-conflictos td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.tabla-datos-conflictos tbody tr:hover {
  background-color: #f8fafc;
}

.badge-id-tabla {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background-color: #f1f5f9;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  white-space: nowrap;
}

.badge-estado-tabla {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-estado-tabla.activo {
  background-color: #fee2e2;
  color: #dc2626;
}

.badge-estado-tabla.latente {
  background-color: #fef3c7;
  color: #d97706;
}

.badge-estado-tabla.resuelto {
  background-color: #dcfce7;
  color: #16a34a;
}

.btn-ubicar-mapa {
  background-color: #f1f5f9;
  color: var(--verde-musgo-profundo);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-ubicar-mapa:hover {
  background-color: var(--verde-olivo);
  color: #ffffff;
  border-color: var(--verde-olivo);
}

@media (max-width: 768px) {
  .card-tabla-conflictos {
    padding: 1rem;
    gap: 1rem;
  }
  .card-tabla-titulo h2 {
    font-size: 1.1rem;
  }
  .card-tabla-acciones-exportar {
    width: 100%;
    display: flex;
    gap: 0.4rem;
  }
  .btn-exportar {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 0.4rem;
    font-size: 0.75rem;
  }
  .buscador-tabla-wrap {
    min-width: 100%;
  }
  .select-tabla-wrap select {
    width: 100%;
  }
}