/* ==========================================================================
   IBERÁ TRACKER · HUD urbano (estética Spider-Tracker)
   ========================================================================== */

:root {
  --bg: #05070d;
  --bg2: #070c16;
  --panel: rgba(8, 13, 23, .9);
  --panel-2: rgba(7, 11, 19, .78);
  --line: rgba(110, 210, 255, .16);
  --line-2: rgba(110, 210, 255, .42);
  --cyan: #5fe3ff;
  --cyan-2: #9ff0ff;
  --red: #ff2b3f;
  --red-2: #ff6b78;
  --amber: #ffc857;
  --txt: #dff4ff;
  --muted: #7d93ab;
  --mono: 'Share Tech Mono', ui-monospace, monospace;
  --display: 'Orbitron', sans-serif;
  --body: 'Chakra Petch', sans-serif;
  --chamfer: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { color-scheme: dark; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(1100px 760px at 18% -12%, rgba(255, 43, 63, .13), transparent 62%),
    radial-gradient(900px 700px at 88% 112%, rgba(95, 227, 255, .11), transparent 62%),
    linear-gradient(158deg, #05070d 0%, #070c16 52%, #04060b 100%);
  color: var(--txt);
  font-family: var(--body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(90deg, rgba(95, 227, 255, .045) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(95, 227, 255, .045) 0 1px, transparent 1px 72px);
  mask-image: radial-gradient(ellipse at 50% 45%, #000 10%, transparent 78%);
}

button, input, a { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(255, 43, 63, .45); color: #fff; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(3, 6, 11, .8); }
::-webkit-scrollbar-thumb { background: rgba(95, 227, 255, .28); border: 2px solid rgba(3, 6, 11, .9); }
::-webkit-scrollbar-thumb:hover { background: rgba(95, 227, 255, .5); }

/* ---------- Efectos globales ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 3000; }
.fx-grain {
  position: absolute; inset: -50%;
  opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(3) infinite;
}
.fx-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px);
  opacity: .35;
}
.fx-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 52%, rgba(0, 0, 0, .62) 100%);
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1%); }
  66% { transform: translate(1%, -2%); }
  100% { transform: translate(0, 0); }
}

kbd {
  font-family: var(--mono);
  font-size: .68rem;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  background: rgba(95, 227, 255, .07);
  color: var(--cyan);
}

/* ---------- Boot ---------- */
.boot {
  position: fixed; inset: 0; z-index: 4000;
  display: grid; place-items: center;
  background:
    radial-gradient(600px 420px at 50% 45%, rgba(255, 43, 63, .12), transparent 70%),
    #04060a;
  transition: opacity .55s ease, visibility .55s;
}
.boot.done { opacity: 0; visibility: hidden; }
.boot-inner { width: min(560px, 88vw); text-align: center; }
.boot-logo { width: 86px; height: 86px; margin: 0 auto 18px; color: var(--red); filter: drop-shadow(0 0 16px rgba(255, 43, 63, .7)); animation: bootPulse 2s ease-in-out infinite; }
.boot-logo svg { width: 100%; height: 100%; }
@keyframes bootPulse { 50% { opacity: .55; transform: scale(.96); } }
.boot-title { margin: 0; font-family: var(--display); font-weight: 900; font-size: clamp(1.4rem, 4vw, 2.1rem); letter-spacing: .34em; color: var(--txt); text-shadow: 0 0 22px rgba(95, 227, 255, .55); }
.boot-sub { margin: 6px 0 22px; font-family: var(--mono); font-size: .68rem; letter-spacing: .28em; color: var(--muted); }
.boot-log { min-height: 108px; margin: 0 0 16px; text-align: left; font-family: var(--mono); font-size: .72rem; line-height: 1.75; color: var(--cyan); opacity: .9; white-space: pre-wrap; }
.boot-bar { height: 2px; background: rgba(95, 227, 255, .14); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--cyan)); box-shadow: 0 0 12px var(--cyan); }
.boot-skip { margin-top: 18px; background: none; border: 0; color: var(--muted); font-family: var(--mono); font-size: .66rem; letter-spacing: .2em; }
.boot-skip:hover { color: var(--cyan); }

/* ---------- Header ---------- */
.top {
  position: relative; z-index: 1500;
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 10, 18, .97), rgba(6, 10, 18, .78));
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--red) 22%, var(--cyan) 60%, transparent);
  opacity: .75;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  color: var(--red);
  border: 1px solid rgba(255, 43, 63, .55);
  background: radial-gradient(circle at 50% 40%, rgba(255, 43, 63, .2), transparent 70%);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 0 8px rgba(255, 43, 63, .45));
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { min-width: 0; flex: 0 0 auto; }
.brand-text p { margin: 2px 0 0; font-family: var(--mono); font-size: .58rem; letter-spacing: .22em; color: var(--muted); white-space: nowrap; }

.glitch {
  position: relative;
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(.95rem, 1.55vw, 1.34rem);
  letter-spacing: .2em;
  color: #eafaff;
  text-shadow: 0 0 18px rgba(95, 227, 255, .35);
  white-space: nowrap;
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: .55;
}
.glitch::before { color: var(--red); animation: glitchA 6s infinite steps(1); }
.glitch::after { color: var(--cyan); animation: glitchB 6s infinite steps(1); }
@keyframes glitchA {
  0%, 92%, 100% { transform: none; clip-path: none; }
  93% { transform: translate(-2px, -1px); clip-path: inset(0 0 62% 0); }
  95% { transform: translate(2px, 1px); clip-path: inset(44% 0 22% 0); }
  97% { transform: translate(-1px, 0); clip-path: inset(74% 0 4% 0); }
}
@keyframes glitchB {
  0%, 90%, 100% { transform: none; clip-path: none; }
  91% { transform: translate(2px, 1px); clip-path: inset(18% 0 48% 0); }
  94% { transform: translate(-2px, -1px); clip-path: inset(66% 0 12% 0); }
  98% { transform: translate(1px, 0); clip-path: inset(6% 0 80% 0); }
}

.scope { display: flex; border: 1px solid var(--line-2); background: rgba(5, 9, 16, .7); }
.scope-btn {
  position: relative;
  padding: 7px 13px;
  border: 0; background: none;
  color: var(--muted);
  font-family: var(--display);
  font-size: .62rem; font-weight: 600; letter-spacing: .16em;
  transition: color .2s, background .2s;
}
.scope-btn + .scope-btn { border-left: 1px solid var(--line); }
.scope-btn:hover { color: var(--txt); }
.scope-btn.is-on {
  color: #0a0f18;
  background: linear-gradient(180deg, var(--red-2), var(--red));
  box-shadow: 0 0 14px rgba(255, 43, 63, .55);
}

.search {
  display: flex; align-items: center; gap: 9px;
  min-width: 0;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: rgba(5, 9, 16, .72);
  transition: border-color .2s, box-shadow .2s;
}
.search svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--cyan); opacity: .8; }
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: 0;
  color: var(--txt);
  font-family: var(--mono); font-size: .8rem; letter-spacing: .06em;
  caret-color: var(--red);
}
.search input::placeholder { color: rgba(125, 147, 171, .8); }
.search:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(95, 227, 255, .25), 0 0 20px rgba(95, 227, 255, .12); }
.search kbd { flex: 0 0 auto; opacity: .6; }

.sys { display: flex; align-items: center; gap: 12px; }
.sys-led { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; color: var(--cyan); white-space: nowrap; }
.sys-led i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink 1.6s infinite; }
.clock { font-family: var(--mono); font-size: .82rem; letter-spacing: .1em; color: var(--amber); }
.emerg {
  padding: 6px 11px;
  border: 1px solid rgba(255, 43, 63, .6);
  background: rgba(255, 43, 63, .08);
  color: var(--red-2);
  font-family: var(--display); font-size: .6rem; font-weight: 700; letter-spacing: .14em;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: .2s;
}
.emerg:hover { background: var(--red); color: #fff; box-shadow: 0 0 16px rgba(255, 43, 63, .6); }

@keyframes blink { 50% { opacity: .12; } }

/* ---------- Layout ---------- */
.grid {
  position: relative; z-index: 10;
  flex: 1;
  display: grid;
  grid-template-columns: 306px minmax(0, 1fr) 344px;
  gap: 10px;
  padding: 10px;
  min-height: 0;
}
.rail { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }

/* ---------- Paneles ---------- */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(9, 15, 26, .94), rgba(6, 10, 18, .92));
  border: 1px solid var(--line);
  clip-path: var(--chamfer);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .6);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 15px; height: 15px; pointer-events: none; z-index: 2;
}
.panel::before { top: -1px; left: -1px; border-top: 1px solid var(--line-2); border-left: 1px solid var(--line-2); }
.panel::after { right: -1px; bottom: -1px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px dashed rgba(110, 210, 255, .18);
  flex: 0 0 auto;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--display); font-size: .64rem; font-weight: 700;
  letter-spacing: .22em; color: #a8dced;
  display: flex; align-items: center; gap: 8px;
}
.panel-head h2::before { content: ""; width: 5px; height: 5px; background: var(--red); box-shadow: 0 0 8px var(--red); }
.count { font-family: var(--mono); font-size: .72rem; color: var(--amber); letter-spacing: .04em; }
.mini {
  border: 1px solid var(--line); background: none; color: var(--muted);
  font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; padding: 3px 7px;
}
.mini:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- Filtros ---------- */
.filters { flex: 0 0 auto; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 9px 10px 11px; }
.chip {
  display: flex; align-items: center; gap: 7px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(110, 210, 255, .12);
  background: rgba(8, 14, 24, .6);
  color: var(--muted);
  font-size: .74rem; font-weight: 500; letter-spacing: .02em;
  text-align: left;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
  transition: opacity .2s, border-color .2s, background .2s, color .2s;
}
.chip .dot { width: 6px; height: 6px; flex: 0 0 auto; background: var(--c); box-shadow: 0 0 7px var(--c); }
.chip .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip b { margin-left: auto; flex: 0 0 auto; font-family: var(--mono); font-size: .66rem; font-weight: 400; color: var(--c); opacity: .8; }
.chip[aria-pressed="false"] { opacity: .3; filter: saturate(.3); }
.chip[aria-pressed="true"] {
  color: var(--txt);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, transparent), rgba(8, 14, 24, .5));
}
.chip:hover { border-color: color-mix(in srgb, var(--c) 70%, transparent); }
.chip:focus-visible { outline: 1px solid var(--c); outline-offset: 1px; }

/* ---------- Lista ---------- */
.list-panel { flex: 1 1 auto; }
.scanstate {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; color: var(--muted);
  padding: 2px 6px; border: 1px solid var(--line);
}
.scanstate.busy { color: var(--amber); border-color: rgba(255, 200, 87, .5); animation: blink 1s infinite; }
.scanstate.ok { color: #6dffc0; border-color: rgba(109, 255, 192, .4); }

.lista { flex: 1 1 auto; list-style: none; margin: 0; padding: 5px; overflow: auto; overscroll-behavior: contain; }
.lista li { margin: 0; animation: fadeUp .25s both; }
.row {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  width: 100%;
  padding: 7px 8px 7px 4px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  color: var(--txt);
  text-align: left;
  transition: background .16s, border-color .16s;
}
.row::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 0; height: 1px;
  background: linear-gradient(90deg, rgba(110, 210, 255, .09), transparent);
}
.row:hover, .row.hot { background: linear-gradient(90deg, rgba(95, 227, 255, .08), transparent 80%); border-left-color: var(--cyan); }
.row.is-sel { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 20%, transparent), transparent 85%); border-left-color: var(--c); }
.row .idx { font-family: var(--mono); font-size: .62rem; color: rgba(125, 147, 171, .7); text-align: right; }
.row .name { display: block; font-size: .82rem; font-weight: 600; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { display: block; margin-top: 2px; font-family: var(--mono); font-size: .6rem; letter-spacing: .05em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row .side em { font-style: normal; font-family: var(--mono); font-size: .6rem; color: var(--c); }
.row .catdot { width: 5px; height: 5px; background: var(--c); box-shadow: 0 0 7px var(--c); }
.row.flash { animation: flash .6s; }
@keyframes flash { 0% { background: rgba(95, 227, 255, .35); } 100% { background: transparent; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } }

.vacio { margin: 0; padding: 28px 14px; text-align: center; font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; color: var(--muted); }
.panel-foot { display: flex; gap: 6px; padding: 8px; border-top: 1px dashed rgba(110, 210, 255, .18); }
.btn {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  background: rgba(95, 227, 255, .06);
  color: var(--cyan);
  font-family: var(--display); font-size: .58rem; font-weight: 600; letter-spacing: .14em;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  transition: .18s;
}
.btn:hover { background: var(--cyan); color: #051018; box-shadow: 0 0 18px rgba(95, 227, 255, .45); }
.btn.ghost { border-color: var(--line); color: var(--muted); background: none; }
.btn.ghost:hover { color: var(--txt); border-color: var(--line-2); background: rgba(95, 227, 255, .06); box-shadow: none; }

/* ---------- Escenario / mapa ---------- */
.stage {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  background: #04070c;
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
#mapa { position: absolute; inset: 0; background: #04070c; }
#mapa .leaflet-tile-pane {
  filter: grayscale(.82) brightness(.66) contrast(1.4) sepia(.58) hue-rotate(151deg) saturate(2.7);
  transition: filter .35s ease;
}
/* La imagen satelital se oscurece más de cerca para que el HUD siga legible */
body[data-nivel="region"] #mapa .leaflet-tile-pane { filter: grayscale(.75) brightness(.78) contrast(1.3) sepia(.55) hue-rotate(150deg) saturate(2.6); }
body[data-nivel="calle"] #mapa .leaflet-tile-pane { filter: grayscale(.85) brightness(.58) contrast(1.45) sepia(.6) hue-rotate(152deg) saturate(2.8); }
#mapa .leaflet-control-attribution {
  background: rgba(4, 8, 14, .78) !important;
  color: rgba(125, 147, 171, .8) !important;
  font-family: var(--mono); font-size: 9px;
  padding: 2px 6px;
}
#mapa .leaflet-control-attribution a { color: rgba(95, 227, 255, .75) !important; }
#mapa .leaflet-popup-content-wrapper, #mapa .leaflet-popup-tip { background: rgba(6, 10, 18, .96); color: var(--txt); border-radius: 0; border: 1px solid var(--line-2); }

.fx-map { position: absolute; inset: 0; pointer-events: none; z-index: 500; }
.fx-grid {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(95, 227, 255, .07) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(95, 227, 255, .07) 0 1px, transparent 1px 64px);
  mask-image: radial-gradient(ellipse at 50% 50%, #000 15%, transparent 76%);
  opacity: .8;
}
.fx-sweep {
  position: absolute; left: 50%; top: 50%;
  width: 150vmax; height: 150vmax;
  margin: calc(-75vmax) 0 0 calc(-75vmax);
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(95, 227, 255, 0) 0deg, rgba(95, 227, 255, .18) 10deg, rgba(95, 227, 255, .03) 34deg, transparent 52deg);
  mask-image: radial-gradient(circle, #000 8%, rgba(0, 0, 0, .55) 42%, transparent 70%);
  animation: sweep 16s linear infinite;
  opacity: .55;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.fx-reticle { position: absolute; left: 50%; top: 50%; width: 160px; height: 160px; transform: translate(-50%, -50%); opacity: .3; }
.fx-reticle i { position: absolute; background: rgba(95, 227, 255, .55); }
.fx-reticle i:nth-child(1) { left: 50%; top: 0; width: 1px; height: 34px; transform: translateX(-50%); }
.fx-reticle i:nth-child(2) { left: 50%; bottom: 0; width: 1px; height: 34px; transform: translateX(-50%); }
.fx-reticle i:nth-child(3) {
  inset: 45px; border: 1px solid rgba(95, 227, 255, .35); border-radius: 50%;
  background: none;
}

.fx-corner { position: absolute; width: 26px; height: 26px; border: 1px solid rgba(95, 227, 255, .6); }
.fx-corner.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.fx-corner.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.fx-corner.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.fx-corner.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.fx-tag { position: absolute; font-family: var(--mono); font-size: 8.5px; letter-spacing: .16em; color: rgba(168, 220, 237, .72); text-shadow: 0 0 6px rgba(0, 0, 0, .9); }
.fx-tag.tl { top: 14px; left: 44px; }
.fx-tag.tr { top: 14px; right: 44px; }
.fx-tag.bl { bottom: 14px; left: 44px; }
.fx-tag.br { bottom: 14px; right: 44px; }

.map-badge {
  position: absolute; top: 40px; left: 12px; z-index: 600;
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 43, 63, .4);
  background: rgba(4, 8, 14, .82);
  color: var(--red-2);
  font-family: var(--mono); font-size: .58rem; letter-spacing: .16em;
}
.map-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: blink 1.4s infinite; }

.map-tools { position: absolute; right: 12px; bottom: 40px; z-index: 700; display: flex; flex-direction: column; gap: 6px; }
.map-tools button {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  background: rgba(4, 8, 14, .85);
  color: var(--cyan);
  font-family: var(--mono); font-size: 1.1rem; line-height: 1;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: .18s;
}
.map-tools button:hover { background: rgba(95, 227, 255, .16); box-shadow: 0 0 16px rgba(95, 227, 255, .28); }
.map-tools svg { width: 18px; height: 18px; }

/* ---------- Marcadores ---------- */
.marker-wrap { background: none; border: 0; }
.mark {
  position: relative;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  color: var(--c);
  transition: transform .16s ease;
}
.mark-halo {
  position: absolute; inset: 1px;
  border-radius: 50%;
  border: 1px solid var(--c);
  opacity: .35;
  animation: markPulse 3.2s ease-out infinite;
}
.mark-hex {
  position: relative;
  width: 23px; height: 23px;
  display: grid; place-items: center;
  background: rgba(4, 8, 14, .92);
  color: var(--c);
  border: 1px solid var(--c);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 45%, transparent);
}
.mark-hex svg { width: 12px; height: 12px; }
.mark-tag {
  position: absolute; left: 50%; top: 31px;
  transform: translateX(-50%);
  padding: 2px 6px;
  background: rgba(3, 7, 12, .94);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  color: var(--c);
  font-family: var(--mono); font-size: 9px; letter-spacing: .05em;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 6;
}
.mark:hover .mark-tag, .mark.hot .mark-tag { opacity: 1; }
.mark:hover, .mark.hot { transform: scale(1.3); z-index: 8; }
.mark:hover .mark-halo, .mark.hot .mark-halo { opacity: .8; animation-duration: 1.2s; }
@keyframes markPulse { 0% { transform: scale(.7); opacity: .55; } 70% { opacity: 0; } 100% { transform: scale(1.9); opacity: 0; } }

/* Racimos de nodos */
.cluster-wrap { background: none; border: 0; }
.cluster { position: relative; width: 46px; height: 46px; display: grid; place-items: center; color: var(--cyan); transition: transform .16s; }
.cluster:hover { transform: scale(1.08); }
.cluster-halo, .cluster-ring { position: absolute; inset: 2px; border-radius: 50%; border: 1px solid rgba(95, 227, 255, .5); animation: markPulse 3.4s ease-out infinite; }
.cluster-hex {
  position: relative;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  background: rgba(4, 10, 18, .94);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--mono); font-size: .68rem;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  box-shadow: 0 0 14px rgba(95, 227, 255, .35), inset 0 0 12px rgba(95, 227, 255, .18);
}
.cluster-tag {
  position: absolute; left: 50%; top: 47px; transform: translateX(-50%);
  padding: 2px 6px;
  background: rgba(3, 7, 12, .94);
  border: 1px solid rgba(95, 227, 255, .4);
  color: var(--cyan);
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .08em;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.cluster:hover .cluster-tag { opacity: 1; }

/* Bloqueo de objetivo */
.lock-wrap { background: none; border: 0; }
.lock { position: absolute; inset: 0; color: var(--c); }
.lock-ring { position: absolute; inset: 32px; border: 1px dashed var(--c); border-radius: 50%; opacity: .65; animation: spinSlow 9s linear infinite; }
.lock-ring.d2 { inset: 20px; border-style: solid; opacity: .22; animation-direction: reverse; animation-duration: 15s; }
.lock-corner { position: absolute; width: 24px; height: 24px; border: 2px solid var(--c); filter: drop-shadow(0 0 5px var(--c)); }
.lock-corner.a { top: 16px; left: 16px; border-right: 0; border-bottom: 0; }
.lock-corner.b { top: 16px; right: 16px; border-left: 0; border-bottom: 0; }
.lock-corner.c { bottom: 16px; left: 16px; border-right: 0; border-top: 0; }
.lock-corner.d { bottom: 16px; right: 16px; border-left: 0; border-top: 0; }
.lock-ping {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--c);
  box-shadow: 0 0 18px var(--c), 0 0 40px color-mix(in srgb, var(--c) 60%, transparent);
  animation: lockPing 2.2s ease-out infinite;
}
.lock-label {
  position: absolute; left: 50%; bottom: 4px;
  transform: translateX(-50%);
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  background: rgba(3, 7, 12, .94);
  color: var(--c);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em;
  white-space: nowrap;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }
@keyframes lockPing { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 55%, transparent); } 70% { box-shadow: 0 0 0 26px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Enlaces de telaraña */
.web-line { stroke-dasharray: 3 7; animation: webDash 2.4s linear infinite; }
@keyframes webDash { to { stroke-dashoffset: -40; } }

/* Usuario */
.user-wrap { background: none; border: 0; }
.user-dot { position: relative; width: 26px; height: 26px; display: grid; place-items: center; }
.user-dot::before, .user-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--cyan); animation: userPulse 2.4s ease-out infinite;
}
.user-dot::after { animation-delay: 1.2s; }
.user-dot span { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
@keyframes userPulse { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }

/* ---------- Detalle ---------- */
.detail { flex: 1 1 auto; overflow: auto; }
.detail-idle { padding: 26px 18px; text-align: center; }
.idle-reticle { width: 120px; height: 120px; margin: 4px auto 14px; color: var(--cyan); opacity: .55; }
.idle-reticle svg { width: 100%; height: 100%; animation: spinSlow 26s linear infinite; }
.detail-idle h2 { margin: 0 0 6px; font-family: var(--display); font-size: .78rem; letter-spacing: .26em; color: var(--cyan); }
.detail-idle p { margin: 0 0 18px; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 0 16px; background: var(--line); border: 1px solid var(--line); text-align: left; }
.stats div { padding: 8px 10px; background: rgba(6, 10, 18, .95); }
.stats dt { font-family: var(--mono); font-size: .56rem; letter-spacing: .14em; color: var(--muted); }
.stats dd { margin: 3px 0 0; font-family: var(--mono); font-size: .74rem; color: var(--cyan); }
.hint { font-family: var(--mono); font-size: .6rem !important; color: var(--muted); }
.idle-quick { margin-top: 22px; padding-top: 14px; border-top: 1px dashed rgba(110, 210, 255, .18); text-align: left; }
.idle-quick .kicker { margin: 0 0 8px; font-family: var(--mono); font-size: .56rem; letter-spacing: .18em; color: var(--muted); }
.idle-quick button {
  width: 100%; margin-bottom: 4px; padding: 7px 9px;
  border: 1px solid var(--line); background: rgba(95, 227, 255, .04);
  color: #b9d3e2; font-size: .72rem; text-align: left; letter-spacing: .03em;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  transition: .16s;
}
.idle-quick button::before { content: "▸ "; color: var(--cyan); }
.idle-quick button:hover { color: var(--cyan); border-color: var(--cyan); background: rgba(95, 227, 255, .1); padding-left: 12px; }

.det-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-bottom: 1px dashed rgba(110, 210, 255, .18); }
.det-kicker { font-family: var(--display); font-size: .58rem; font-weight: 700; letter-spacing: .2em; color: var(--c, var(--cyan)); display: flex; align-items: center; gap: 7px; }
.det-kicker::before { content: ""; width: 5px; height: 5px; background: var(--c, var(--cyan)); box-shadow: 0 0 8px var(--c, var(--cyan)); animation: blink 1.6s infinite; }
.det-close { width: 24px; height: 24px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: .7rem; line-height: 1; }
.det-close:hover { color: var(--red); border-color: var(--red); }
.det-body { padding: 14px 14px 18px; }
.det-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  color: var(--c);
  font-family: var(--mono); font-size: .6rem; letter-spacing: .1em;
  margin-bottom: 9px;
}
.det-cat svg { width: 12px; height: 12px; }
.det-title { margin: 0; font-family: var(--display); font-size: 1.02rem; font-weight: 800; line-height: 1.25; letter-spacing: .04em; color: #f1fbff; text-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.det-sub { margin: 5px 0 14px; font-family: var(--mono); font-size: .64rem; letter-spacing: .08em; color: var(--c); }
.det-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 0 12px; background: var(--line); border: 1px solid var(--line); }
.det-grid div { padding: 7px 9px; background: rgba(6, 10, 18, .95); }
.det-grid .wide { grid-column: 1 / -1; }
.det-grid dt { font-family: var(--mono); font-size: .53rem; letter-spacing: .14em; color: var(--muted); }
.det-grid dd { margin: 3px 0 0; font-family: var(--mono); font-size: .68rem; color: var(--txt); word-break: break-word; }
.det-desc { margin: 0 0 14px; font-size: .82rem; line-height: 1.55; color: #b9d3e2; }
.det-signal { display: flex; align-items: flex-end; gap: 2px; height: 22px; margin-bottom: 14px; }
.det-signal i { flex: 1; background: var(--c); opacity: .75; animation: signal 1.8s ease-in-out infinite; }
.det-signal i:nth-child(3n) { animation-delay: .25s; }
.det-signal i:nth-child(3n+1) { animation-delay: .5s; }
.det-signal span { margin-left: 8px; font-family: var(--mono); font-size: .56rem; color: var(--muted); white-space: nowrap; }
@keyframes signal { 50% { opacity: .28; } }
.det-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.det-actions a, .det-actions button {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 6px;
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: rgba(8, 14, 24, .7);
  color: var(--c);
  font-family: var(--display); font-size: .55rem; font-weight: 600; letter-spacing: .1em;
  text-decoration: none;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  transition: .18s;
}
.det-actions a:hover, .det-actions button:hover { background: var(--c); color: #041018; box-shadow: 0 0 16px color-mix(in srgb, var(--c) 55%, transparent); }
.det-actions .wide { grid-column: 1 / -1; }

/* ---------- Footer ---------- */
.bottom {
  position: relative; z-index: 1500;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 42px;
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, rgba(6, 10, 18, .98), rgba(6, 10, 18, .8));
}
.bottom::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan) 34%, var(--red) 70%, transparent);
  opacity: .55;
}
.ticker { overflow: hidden; white-space: nowrap; }
.ticker span {
  display: inline-block;
  padding-left: 100%;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; color: rgba(125, 147, 171, .9);
  animation: marquee 38s linear infinite;
}
@keyframes marquee { to { transform: translateX(-100%); } }
.quick { display: flex; gap: 4px; }
.quick a {
  display: flex; align-items: baseline; gap: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 43, 63, .25);
  color: var(--red-2);
  font-family: var(--mono); font-size: .68rem;
  text-decoration: none;
}
.quick a small { font-size: .48rem; letter-spacing: .1em; color: var(--muted); }
.quick a:hover { background: rgba(255, 43, 63, .14); border-color: var(--red); }
.keys { display: flex; gap: 12px; font-family: var(--mono); font-size: .55rem; letter-spacing: .1em; color: var(--muted); }
.keys kbd { margin-right: 3px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 3500;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(2, 4, 8, .78);
  backdrop-filter: blur(4px);
  animation: fadeIn .18s;
}
.modal[hidden] { display: none; }
.modal-card { width: min(440px, 94vw); background: rgba(7, 12, 21, .98); animation: rise .22s ease; }
.emerg-list { list-style: none; margin: 0; padding: 10px; display: grid; gap: 6px; }
.emerg-list a {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-decoration: none;
  background: rgba(255, 43, 63, .04);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  transition: .18s;
}
.emerg-list a:hover { border-color: var(--red); background: rgba(255, 43, 63, .12); }
.emerg-list b { font-family: var(--display); font-size: 1.1rem; color: var(--red); min-width: 58px; letter-spacing: .06em; }
.emerg-list span { font-size: .78rem; color: var(--txt); }
.nota { margin: 0; padding: 0 14px 14px; font-size: .7rem; line-height: 1.5; color: var(--muted); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 60px; z-index: 3600;
  transform: translate(-50%, 14px);
  padding: 8px 16px;
  border: 1px solid var(--cyan);
  background: rgba(4, 9, 16, .96);
  color: var(--cyan);
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em;
  opacity: 0; pointer-events: none;
  transition: .24s;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Botones móviles de panel ---------- */
.panel-toggle, .drawer-close { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .grid { grid-template-columns: 280px minmax(0, 1fr) 320px; }
  .brand-text p { display: none; }
  .keys { display: none; }
}

@media (max-width: 1180px) {
  .top { grid-template-columns: auto auto minmax(180px, 1fr) auto; }
  .sys-led, .clock { display: none; }
}

@media (max-width: 1080px) {
  .grid { grid-template-columns: 280px minmax(0, 1fr); }
  .rail.right {
    position: fixed; z-index: 1450;
    top: 70px; right: 10px; bottom: 54px;
    width: min(360px, calc(100vw - 20px));
    transform: translateX(calc(100% + 24px));
    transition: transform .28s ease;
    pointer-events: none;
  }
  .rail.right.is-open { transform: none; pointer-events: auto; }
  .detail { box-shadow: -12px 0 40px rgba(0, 0, 0, .6); }
  body:has(.rail.right.is-open) .map-tools { right: 382px; }
  body:has(.rail.right.is-open) #panel-toggle { display: none; }
}

@media (max-width: 900px) {
  .top { grid-template-columns: 1fr auto; grid-template-areas: "brand sys" "scope scope" "search search"; }
  .brand { grid-area: brand; }
  .sys { grid-area: sys; }
  .scope { grid-area: scope; justify-self: stretch; }
  .search { grid-area: search; }
  .brand-text p { display: block; }
  .scope-btn { flex: 1; }

  .grid { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
  /* Hojas opacas: el mapa no debe transparentarse detrás del texto */
  .rail .panel { background: linear-gradient(180deg, #090f1a, #060a12); }
  .rail.left {
    position: fixed; z-index: 1450;
    left: 8px; right: 8px; bottom: 52px;
    max-height: 62dvh;
    transform: translateY(calc(100% + 72px));
    transition: transform .28s ease;
    pointer-events: none;
  }
  .rail.left.is-open { transform: none; pointer-events: auto; }

  /* La ficha también entra desde abajo: en vertical, un panel lateral taparía todo */
  .rail.right {
    top: auto; left: 8px; right: 8px; bottom: 52px;
    width: auto; max-height: 56dvh;
    transform: translateY(calc(100% + 72px));
    filter: drop-shadow(0 -10px 26px rgba(0, 0, 0, .6));
  }
  .rail.right.is-open { transform: none; }
  body:has(.rail.right.is-open) .map-tools { right: 12px; }
  body:has(.rail.right.is-open) #panel-toggle { display: flex; }

  .drawer-close {
    display: flex;
    position: absolute; top: -34px; right: 2px; z-index: 5;
    align-items: center; gap: 5px;
    padding: 6px 11px;
    border: 1px solid var(--line-2);
    background: rgba(4, 8, 14, .94);
    color: var(--cyan);
    font-family: var(--display); font-size: .56rem; font-weight: 600; letter-spacing: .14em;
    clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  }
  .drawer-close:active { background: rgba(95, 227, 255, .18); }

  .panel-toggle {
    display: flex; align-items: center; gap: 6px;
    position: absolute; left: 12px; bottom: 40px; z-index: 720;
    padding: 8px 12px;
    border: 1px solid var(--line-2);
    background: rgba(4, 8, 14, .9);
    color: var(--cyan);
    font-family: var(--display); font-size: .58rem; letter-spacing: .14em;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  }
  .map-badge { top: 34px; left: 10px; }
  .fx-tag.bl { display: none; }
  .bottom { grid-template-columns: 1fr auto; height: 44px; padding: 0 10px; }
  .quick { display: none; }
  .toast { bottom: 56px; }
}

@media (max-width: 560px) {
  .brand-mark { width: 34px; height: 34px; }
  .brand-mark svg { width: 21px; height: 21px; }
  .glitch { font-size: .86rem; letter-spacing: .14em; }
  .brand-text p { font-size: .5rem; letter-spacing: .14em; }
  .scope-btn { padding: 6px 9px; font-size: .55rem; }
  .search { padding: 6px 9px; }
  .search input { font-size: .74rem; }
  .search kbd { display: none; }
  .emerg { padding: 5px 8px; font-size: .52rem; }
  .chips { grid-template-columns: 1fr 1fr; }
  .keys { display: none; }
  .fx-corner { width: 18px; height: 18px; }
}

@media (max-height: 720px) {
  .detail-idle { padding: 16px 12px; }
  .idle-reticle { width: 80px; height: 80px; }
  .chips { padding: 7px 8px 8px; gap: 5px; }
  .chip { padding: 5px 7px; font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ticker span { padding-left: 0; }
}

/* ---------- Impresión / sin JS ---------- */
noscript { padding: 20px; }
