:root {
  --fondo: #0e1117;
  --panel: #171b22;
  --panel-2: #202631;
  --borde: #2e3440;
  --texto: #f5f5f5;
  --texto-suave: #aab2c0;
  --mapa-fondo: #f7f7f7;
  --morado: #8051a9;
  --naranja: #f57c00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--fondo);
  color: var(--texto);
  font-family: Arial, Helvetica, sans-serif;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0;
  font-size: 34px;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--texto-suave);
  font-size: 14px;
}

.acciones-header {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.selector-vista {
  display: flex;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: 6px;
}

.btn-vista {
  border: none;
  background: transparent;
  color: var(--texto-suave);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-vista:hover {
  background: #2b313c;
  color: white;
}

.btn-vista.activo {
  background: var(--morado);
  color: white;
}

.resumen {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.resumen-card {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 16px;
}

.resumen-card span {
  display: block;
  color: var(--texto-suave);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.resumen-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.15;
}

.resumen-card small {
  display: block;
  margin-top: 7px;
  color: var(--texto-suave);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.resumen-card.colombia-resumen {
  border-color: #2e3440;
}

.resumen-card.total-nacional {
  border-color: #8051a9;
  background: linear-gradient(180deg, #1d2230 0%, #171b22 100%);
}

.resumen-card.total-nacional span {
  color: #d7c2f0;
}

.resumen-card.dato-general {
  background: #141922;
  border-color: #3a4250;
}

.resumen-card.diferencia {
  border-color: #f57c00;
}

.resumen-card.diferencia span {
  color: #ffd4a8;
}

.layout {
  display: grid;
  grid-template-columns: minmax(650px, 1fr) 420px;
  gap: 18px;
  align-items: start;
  margin-top: 28px;
}

.mapa-card {
  position: relative;
  background: var(--mapa-fondo);
  border: 1px solid #333;
  border-radius: 14px;
  padding: 118px 10px 44px;
  overflow: hidden;
}

.mapa-info-superior {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 44;
  max-width: min(460px, calc(100% - 360px));
  padding: 12px 14px;
  background: rgba(247, 247, 247, 0.94);
  border: 1px solid rgba(17, 24, 39, 0.45);
  border-radius: 14px;
  color: #111827;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
}

.mapa-modo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: #5f347f;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mapa-modo::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--morado);
  box-shadow: 0 0 0 4px rgba(128, 81, 169, 0.16);
}

.mapa-info-superior h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  line-height: 1.12;
}

.mapa-info-superior p {
  margin: 5px 0 0;
  color: #374151;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}

.mapa-firma {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 23;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 520px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(247, 247, 247, 0.90);
  border: 1px solid rgba(17, 24, 39, 0.20);
  color: #374151;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

#mapa {
  width: 100%;
  display: block;
  touch-action: none;
}

#mapa.mapa-zoom-activo {
  cursor: grab;
}

#mapa.mapa-arrastrando {
  cursor: grabbing;
}

.mapa-tabs {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 45;
  display: flex;
  gap: 8px;
  background: rgba(247, 247, 247, 0.96);
  border: 1px solid #333;
  border-radius: 999px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.btn-modo-mapa {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  background: transparent;
  color: #111;
}

.btn-modo-mapa.activo {
  background: var(--morado);
  color: white;
}

.btn-modo-mapa:hover {
  background: #e6e6e6;
}

.btn-modo-mapa.activo:hover {
  background: var(--morado);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: 22px;
}

.panel h2 {
  margin: 0;
  font-size: 27px;
}

.panel p {
  color: var(--texto-suave);
  line-height: 1.45;
}

.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 22px;
}

.chip {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}

.chip-morado {
  background: var(--morado);
  color: white;
}

.chip-naranja {
  background: var(--naranja);
  color: white;
}

.chip-blanco {
  background: #f5f5f5;
  color: #111;
}

.dato {
  padding: 13px 0;
  border-bottom: 1px solid var(--borde);
}

.dato span {
  display: block;
  color: var(--texto-suave);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.dato strong {
  display: block;
  font-size: 20px;
}

.nota {
  margin-top: 18px;
  font-size: 13px;
}

.btn-secundario,
.btn-volver {
  width: 100%;
  border: 1px solid #424a57;
  background: #2b313c;
  color: white;
  border-radius: 8px;
  padding: 11px 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 18px;
}

.btn-volver {
  width: auto;
  margin-top: 0;
  background: var(--morado);
  border-color: #a987d9;
}

.btn-secundario:hover,
.btn-volver:hover {
  background: #3a4250;
}

.mapa-card .btn-volver {
  position: absolute;
  top: 92px;
  right: 18px;
  z-index: 46;
  width: auto;
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.mapa-controles {
  position: absolute;
  top: 68px;
  left: 18px;
  z-index: 36;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: calc(100% - 36px);
  background: rgba(247, 247, 247, 0.94);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.mapa-controles.modo-municipal,
.mapa-controles.modo-exterior {
  left: 18px;
  right: auto;
}

.mapa-controles select {
  min-width: 230px;
  max-width: 320px;
  border: 1px solid #777;
  background: white;
  color: #111;
  border-radius: 8px;
  padding: 9px 10px;
  font-weight: 700;
  outline: none;
}

.btn-mapa {
  border: 1px solid #6d3f93;
  background: var(--morado);
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.btn-mapa:hover {
  background: #6f4497;
}

.btn-mapa:disabled {
  background: #a5a5a5;
  border-color: #888;
  color: #333;
  cursor: default;
}

.btn-mapa.btn-reset-zoom {
  background: #2b313c;
  border-color: #424a57;
}

.btn-mapa.btn-reset-zoom:hover {
  background: #3a4250;
}

.leyenda-mapa {
  position: absolute;
  right: 18px;
  bottom: 54px;
  z-index: 24;
  width: 238px;
  background: rgba(247, 247, 247, 0.96);
  border: 1px solid rgba(17, 24, 39, 0.48);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  color: #111;
  backdrop-filter: blur(6px);
}

.leyenda-mapa.en-panel {
  position: static;
  width: 100%;
  margin-top: 18px;
  box-shadow: none;
  z-index: auto;
  background: #f7f7f7;
}

.leyenda-mapa.en-panel svg {
  height: 118px;
}

.leyenda-mapa.en-panel .leyenda-solida {
  grid-template-columns: 1fr;
}

.leyenda-mapa-titulo {
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
}

.leyenda-mapa svg {
  width: 100%;
  height: 135px;
  display: block;
}

.leyenda-label {
  font-size: 10px;
  font-weight: 800;
  fill: #111;
}

.leyenda-nota {
  margin-top: 4px;
  font-size: 10px;
  color: #333;
  line-height: 1.25;
  text-align: center;
}

.leyenda-solida {
  display: grid;
  gap: 7px;
  margin-top: 4px;
}

.leyenda-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
}

.leyenda-color {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid #222;
  flex-shrink: 0;
}

.oculto {
  display: none !important;
}

.region {
  stroke: #202020;
  stroke-width: 0.85;
  fill-opacity: 0.92;
  cursor: pointer;
  transition: fill-opacity 0.12s ease, stroke-width 0.12s ease;
}

.region:hover {
  fill-opacity: 1;
  stroke: #000000;
  stroke-width: 2.2;
}

.region.seleccionado {
  stroke: #ffff00;
  stroke-width: 3;
}

.region.sin-datos,
.region.sin-municipios {
  cursor: default;
}

.region.sin-datos {
  fill-opacity: 0.35;
}

.inset-mapa {
  position: absolute;
  background: rgba(247, 247, 247, 0.97);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 8px;
  z-index: 12;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.inset-mapa:hover {
  border-color: var(--morado);
}

.inset-titulo {
  color: #111;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
  text-align: center;
}

.inset-internacional {
  top: 68px;
  right: 18px;
  width: 245px;
}

.inset-colombia {
  left: 18px;
  bottom: 18px;
  width: 230px;
}

#mapa-inset-internacional {
  width: 100%;
  height: 130px;
  display: block;
}

#mapa-inset-colombia {
  width: 100%;
  height: 190px;
  display: block;
}

.inset-region {
  stroke: #202020;
  stroke-width: 0.65;
  fill-opacity: 0.95;
}

/* TABLA DE RESULTADOS */

.tabla-seccion {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: 18px;
}

.tabla-encabezado {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 14px;
}

.tabla-encabezado h2 {
  margin: 0;
  font-size: 26px;
}

.tabla-encabezado p {
  margin: 6px 0 0;
  color: var(--texto-suave);
  font-size: 14px;
}

.tabla-filtros {
  display: grid;
  grid-template-columns: minmax(230px, 1.4fr) minmax(190px, 1fr) minmax(170px, 0.8fr) minmax(180px, 0.8fr);
  gap: 10px;
  margin-bottom: 14px;
}

.tabla-control {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tabla-control label {
  color: var(--texto-suave);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tabla-busqueda,
.tabla-select {
  width: 100%;
  border: 1px solid #424a57;
  background: #0f131a;
  color: white;
  border-radius: 10px;
  padding: 12px 13px;
  font-weight: 700;
  outline: none;
}

.tabla-busqueda::placeholder {
  color: #7f8796;
}

.tabla-select {
  cursor: pointer;
}

.tabla-contenedor {
  overflow-x: auto;
  border: 1px solid var(--borde);
  border-radius: 12px;
}

.tabla-resultados {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.tabla-resultados th,
.tabla-resultados td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--borde);
  text-align: left;
  white-space: nowrap;
}

.tabla-resultados th {
  background: #111720;
  color: var(--texto-suave);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tabla-resultados th button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

.tabla-resultados th button:hover {
  color: white;
}

.tabla-resultados tbody tr {
  cursor: pointer;
}

.tabla-resultados tbody tr:hover {
  background: #202631;
}

.tabla-resultados tbody tr.fila-activa {
  background: rgba(128, 81, 169, 0.24);
}

.tabla-resultados td strong {
  color: white;
}

.badge-lider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.badge-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #111;
}

.celda-numero {
  text-align: right;
}

.tabla-vacia {
  padding: 22px;
  color: var(--texto-suave);
  text-align: center;
}

@media (max-width: 1100px) {
  .app-header {
    flex-direction: column;
  }

  .acciones-header {
    align-items: flex-start;
    width: 100%;
  }

  .selector-vista {
    flex-wrap: wrap;
    border-radius: 14px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .resumen {
    grid-template-columns: repeat(2, 1fr);
  }

  .mapa-card {
    padding: 18px 10px 18px;
  }

  .mapa-info-superior,
  .mapa-firma {
    position: static;
    transform: none;
    max-width: none;
    width: 100%;
    margin-bottom: 10px;
    border-radius: 12px;
  }

  .mapa-tabs,
  .mapa-controles {
    position: static;
    margin-bottom: 10px;
    flex-direction: column;
    align-items: stretch;
    max-width: none;
    border-radius: 12px;
  }

  .mapa-controles select {
    min-width: 100%;
    max-width: 100%;
  }

  .mapa-card .btn-volver {
    position: static;
    margin-bottom: 10px;
  }

  .leyenda-mapa {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .inset-internacional,
  .inset-colombia {
    width: 180px;
  }

  #mapa-inset-internacional {
    height: 95px;
  }

  #mapa-inset-colombia {
    height: 150px;
  }

  .tabla-encabezado {
    flex-direction: column;
  }

  .tabla-filtros {
    grid-template-columns: 1fr;
  }
}

/* TOOLTIP BONITO DEL MAPA */
.tooltip-mapa {
  position: fixed;
  z-index: 99999;
  width: 355px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  color: #151515;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.30);
  padding: 12px;
  pointer-events: none;
  font-family: Arial, Helvetica, sans-serif;
}

.tooltip-mapa.oculto {
  display: none !important;
}

.tooltip-titulo {
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 3px;
  color: #111;
}

.tooltip-titulo span {
  color: #555;
  font-weight: 800;
}

.tooltip-subtitulo {
  font-size: 12px;
  color: #444;
  margin-bottom: 10px;
  font-weight: 700;
}

.tooltip-tabla {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

.tooltip-tabla th {
  font-size: 12px;
  text-align: left;
  color: #333;
  background: #f0f1f3;
  padding: 7px 8px;
  border-bottom: 1px solid #d9dce1;
}

.tooltip-tabla th:nth-child(2),
.tooltip-tabla th:nth-child(3) {
  text-align: right;
}

.tooltip-tabla td {
  padding: 8px;
  border-bottom: 1px solid #e4e6ea;
  font-size: 13px;
  background: #fff;
}

.tooltip-tabla tbody tr:nth-child(odd) td {
  background: #f7f7f8;
}

.tooltip-tabla tbody tr:last-child td {
  border-bottom: none;
}

.tooltip-candidato {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.tooltip-color {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.tooltip-color-blanco {
  border: 1px solid #999;
}

.tooltip-numero {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* CAPITALES PRINCIPALES COLOMBIA */
.capitales-colombia {
  pointer-events: none;
}

.capital-linea {
  stroke: rgba(15, 23, 42, 0.55);
  stroke-width: 1.15;
  stroke-linecap: round;
}

.capital-punto {
  fill: #111827;
  stroke: #ffffff;
  stroke-width: 1.8;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.capital-label {
  fill: #111827;
  stroke: #ffffff;
  stroke-width: 4px;
  paint-order: stroke fill;
  stroke-linejoin: round;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.01em;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.65));
}

/* EXPORTACIONES LIMPIAS - ESTILO INTEGRADO */
.exportaciones-card {
  max-width: 1500px;
  margin: 0 auto 18px;
  background:
    radial-gradient(circle at top left, rgba(128, 81, 169, 0.22), transparent 30%),
    linear-gradient(180deg, #171b22 0%, #141922 100%);
  border: 1px solid rgba(170, 178, 192, 0.18);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.exportaciones-info {
  min-width: 250px;
}

.exportaciones-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: #d7c2f0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.exportaciones-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--morado);
  box-shadow: 0 0 0 4px rgba(128, 81, 169, 0.16);
}

.exportaciones-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  color: var(--texto);
}

.exportaciones-card p {
  margin: 5px 0 0;
  color: var(--texto-suave);
  font-size: 13px;
  line-height: 1.3;
}

.acciones-exportacion {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.btn-exportar {
  min-width: 128px;
  border: 1px solid rgba(170, 178, 192, 0.18);
  background: rgba(14, 17, 23, 0.72);
  color: var(--texto);
  border-radius: 14px;
  padding: 9px 11px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.btn-exportar:hover {
  transform: translateY(-1px);
  background: rgba(32, 38, 49, 0.96);
  border-color: rgba(215, 194, 240, 0.42);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.exportar-tag {
  min-width: 42px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f5;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.exportar-texto {
  display: grid;
  gap: 1px;
}

.exportar-texto strong {
  font-size: 13px;
  line-height: 1.05;
}

.exportar-texto small {
  color: var(--texto-suave);
  font-size: 11px;
  line-height: 1.05;
  font-weight: 700;
}

.btn-exportar-principal {
  border-color: rgba(215, 194, 240, 0.34);
  background: linear-gradient(135deg, #8051a9 0%, #5f347f 100%);
}

.btn-exportar-principal .exportar-tag {
  background: rgba(255, 255, 255, 0.16);
}

.btn-exportar-principal small {
  color: #eadcf8;
}

.btn-exportar-principal:hover {
  background: linear-gradient(135deg, #8c5cba 0%, #6f4497 100%);
  border-color: rgba(235, 221, 250, 0.62);
}

@media (max-width: 1100px) {
  .exportaciones-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .acciones-exportacion {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 650px) {
  .acciones-exportacion {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn-exportar {
    min-width: 0;
  }
}

.app-footer {
  max-width: 1500px;
  margin: 22px auto 0;
  padding: 14px 18px;
  color: var(--texto-suave);
  background: rgba(23, 27, 34, 0.72);
  border: 1px solid var(--borde);
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}


/* FIX REAL: la nomenclatura ternaria no debe verse dentro de la interfaz.
   La leyenda para PNG/SVG se genera de forma independiente en la exportación. */
#leyenda-mapa,
.leyenda-mapa {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
