:root {
  --noche: #10141F;
  --negro: #191919;
  --azul: #1B62F2;
  --azul-prof: #103FB0;
  --azul-claro: #6F9BF7;
  --azul-suave: #C3DBF2;
  --texto: #E8ECF5;
  --coral: #F54863;
  --sec: rgba(232, 236, 245, .62);
  --ter: rgba(232, 236, 245, .42);
  --sup: rgba(232, 236, 245, .045);
  --sup-2: rgba(232, 236, 245, .08);
  --linea: rgba(195, 219, 242, .13);
  --tierra: rgba(195, 219, 242, .065);
  --tierra-borde: rgba(195, 219, 242, .26);
  --ctx: rgba(195, 219, 242, .025);
  --ctx-borde: rgba(195, 219, 242, .10);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--noche); color: var(--texto); }
body { font: 400 14px/1.45 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 392px; height: 100vh; }

/* ---------- mapa ---------- */
.mapa {
  position: relative; overflow: hidden; min-height: 0;
  background:
    radial-gradient(ellipse at 45% 40%, rgba(27, 98, 242, .10), transparent 60%),
    radial-gradient(circle, rgba(195, 219, 242, .07) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--noche);
}
#mapa { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
#mapa.arrastrando { cursor: grabbing; }

.pais { fill: var(--tierra); stroke: var(--tierra-borde); stroke-width: .6; vector-effect: non-scaling-stroke; transition: fill .7s ease, opacity .45s ease, stroke .3s; }
.pais.contexto { fill: var(--ctx); stroke: var(--ctx-borde); pointer-events: none; }
.pais.activo { cursor: pointer; }
.pais.hover { stroke: var(--texto); stroke-width: 1.4; }
.pais.elegido { stroke: var(--texto); stroke-width: 1.8; }

#mapa.modo-huecos .pais.activo:not(.es-hueco):not(.con-op) { opacity: .28; }
#mapa.modo-huecos .pais.contexto { opacity: .4; }

.corte { stroke: var(--linea); stroke-width: 1; stroke-dasharray: 2 5; vector-effect: non-scaling-stroke; }
.corte-txt { fill: var(--ter); font-size: 8.5px; letter-spacing: .22em; font-weight: 500; }

.cob { vector-effect: non-scaling-stroke; pointer-events: none; }
.cob.gptw { fill: var(--azul-claro); stroke: var(--azul-claro); stroke-width: 1.3; }
.cob.indirecto { fill: var(--texto); stroke: var(--texto); stroke-width: 1.2; stroke-dasharray: 4 3; }
.cob.foco { stroke-width: 2.2; }

.hueco-sup { fill: url(#rayado); stroke: var(--coral); stroke-width: 1.4; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.sincanal-sup { fill: none; stroke: var(--azul-suave); stroke-width: 1.4; stroke-dasharray: 1 3; stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none; }

.anillo { fill: none; vector-effect: non-scaling-stroke; pointer-events: none; }
.disco { stroke: none; pointer-events: none; }
.sede { pointer-events: none; }

.burbuja { fill: rgba(111, 155, 247, .16); stroke: var(--azul-suave); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }

.capa-etq { font-size: 12px; stroke-width: 3px; }
.etq { pointer-events: none; paint-order: stroke; stroke: var(--noche); stroke-linejoin: round; transition: opacity .4s; }
.etq-nombre { fill: var(--texto); font-size: .82em; font-weight: 600; letter-spacing: .14em; }
.etq-valor { fill: var(--azul-suave); font-size: .9em; font-weight: 500; }
.etq-hueco { fill: var(--coral); font-size: .7em; font-weight: 600; letter-spacing: .14em; }
.etq.apagada { opacity: 0; }

.aviso {
  position: absolute; top: 14px; left: 16px; right: 16px; margin: 0; z-index: 2; pointer-events: none;
  font-size: 11.5px; color: var(--sec); letter-spacing: .02em;
}
.aviso b { color: var(--azul-claro); font-weight: 600; letter-spacing: .14em; margin-right: 6px; }

.vistas { position: absolute; top: 44px; left: 16px; display: flex; flex-wrap: wrap; gap: 6px; z-index: 2; }
.vistas button, .zoom button {
  background: rgba(16, 20, 31, .82); border: 1px solid var(--linea); border-radius: 999px;
  padding: 4px 11px; font-size: 11.5px; color: var(--sec); cursor: pointer; backdrop-filter: blur(6px);
}
.vistas button:hover, .zoom button:hover { color: var(--texto); border-color: rgba(195, 219, 242, .35); }
.vistas button[aria-pressed="true"] { color: var(--texto); border-color: var(--azul-claro); }
.zoom { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.zoom button { width: 34px; height: 34px; padding: 0; font-size: 16px; border-radius: 10px; }

.leyenda {
  position: absolute; left: 16px; bottom: 16px; z-index: 2; max-width: min(340px, calc(100% - 80px));
  background: rgba(16, 20, 31, .86); border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px;
  font-size: 11.5px; color: var(--sec); backdrop-filter: blur(6px); display: grid; gap: 6px;
}
.leyenda:empty { display: none; }
.ley { display: flex; align-items: center; gap: 8px; }
.ley svg { flex: none; }
.ley-rampa { display: grid; gap: 3px; }
.ley-rampa .barra { height: 8px; border-radius: 4px; }
.ley-rampa .ext { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ter); }

.tip {
  position: absolute; z-index: 5; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s; min-width: 200px; max-width: 280px;
  background: rgba(16, 20, 31, .96); border: 1px solid rgba(195, 219, 242, .22); border-radius: 12px;
  padding: 10px 12px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.tip.ver { opacity: 1; transform: none; }
.tip h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.tip p { margin: 2px 0; color: var(--sec); }
.tip .alerta { color: var(--coral); font-weight: 500; }

/* ---------- panel ---------- */
.panel { overflow-y: auto; border-left: 1px solid var(--linea); padding: 22px 20px 28px; display: flex; flex-direction: column; gap: 22px; }
.marca .logo { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.marca .logo span { color: var(--coral); }
.marca h1 { margin: 6px 0 2px; font-size: 22px; line-height: 1.2; font-weight: 600; }
.marca .sub { margin: 0; font-size: 12px; color: var(--ter); }

h2 {
  margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--azul-claro);
}
.bloque { display: grid; gap: 4px; }
.grupo { display: grid; gap: 2px; padding: 8px 0 10px; border-bottom: 1px solid var(--linea); }
.grupo:last-child { border-bottom: 0; }
.grupo-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.grupo-cab .titulo { font-weight: 600; font-size: 13.5px; }
.grupo-cab .titulo small { font-weight: 400; color: var(--ter); margin-left: 6px; font-size: 11.5px; }

.fila { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: 8px; cursor: pointer; }
.fila:hover, .fila.foco { background: var(--sup-2); }
.fila .nombre { flex: 1; min-width: 0; }
.fila .cuenta { font-size: 11.5px; color: var(--ter); white-space: nowrap; }
.fila .cuenta.caliente { color: var(--texto); }
.muestra { width: 14px; height: 14px; flex: none; }
.ir { background: none; border: 0; padding: 0 2px; color: var(--ter); cursor: pointer; font-size: 13px; }
.ir:hover { color: var(--texto); }

.sw {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 30px; height: 17px; border-radius: 999px; background: rgba(232, 236, 245, .14); position: relative; transition: background .2s;
}
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--texto); transition: transform .2s; }
.sw:checked { background: var(--azul); }
.sw:checked::after { transform: translateX(13px); }
.sw:focus-visible { outline: 2px solid var(--azul-claro); outline-offset: 2px; }

.seg { display: flex; background: var(--sup); border: 1px solid var(--linea); border-radius: 10px; padding: 3px; gap: 3px; margin-top: 6px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 4px; font-size: 12px; color: var(--sec); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--azul); color: #fff; }
.seg-ayuda { font-size: 11.5px; color: var(--ter); margin: 6px 0 0; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--sup); border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.1; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--sec); }
.kpi .l { font-size: 11.5px; color: var(--sec); margin-top: 2px; }
.kpi.alerta .v { color: var(--coral); }

.hueco-lista { margin: 10px 0 0; display: grid; gap: 10px; }
.hueco-lista h3 { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.hueco-lista h3 i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--sup-2); color: var(--texto); border: 1px solid transparent; cursor: pointer; }
.chip:hover { border-color: var(--linea); }
.chip small { color: var(--ter); margin-left: 4px; }
.vacio { font-size: 12px; color: var(--ter); margin: 0; }

.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 12px; }
.tabla th { text-align: left; font-weight: 500; color: var(--ter); padding: 4px 6px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 6px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla th.n { text-align: right; }
.tabla tr { cursor: pointer; }
.tabla tbody tr:hover td { background: var(--sup); }
.tabla .canales { font-size: 11px; color: var(--ter); }
.tabla .hueco td:first-child { box-shadow: inset 2px 0 0 var(--coral); }

.relleno { color: var(--ter); margin-left: 2px; cursor: help; }

.ficha { background: var(--sup); border: 1px solid rgba(195, 219, 242, .2); border-radius: 14px; padding: 14px; position: relative; }
.ficha h3 { margin: 0 0 2px; font-size: 17px; font-weight: 600; padding-right: 24px; }
.ficha .meta { font-size: 12px; color: var(--sec); margin: 0 0 10px; }
.ficha .cerrar { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--ter); font-size: 18px; cursor: pointer; }
.ficha ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ficha li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12.5px; padding: 8px 10px; border-radius: 10px; background: var(--sup); }
.ficha li .et { color: var(--sec); font-size: 11.5px; }
.ficha li .caliente { color: var(--texto); font-weight: 600; }

.pie { margin-top: auto; font-size: 11px; color: var(--ter); }
.pie p { margin: 0 0 10px; }
.filete { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--azul), var(--coral)); }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .mapa { height: 82vh; min-height: 520px; }
  .panel { border-left: 0; border-top: 1px solid var(--linea); padding: 20px 16px 28px; }
  .leyenda { bottom: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  .pais, .burbuja, .etq, .tip, .sw, .sw::after { transition: none; }
}
