/* El Ojo de Tláloc — interfaz de trabajo: barra lateral y mapa como cámara satelital con HUD
   (imagen en gris, malla translúcida, retícula, scanlines y viñeta). Source Sans en la interfaz
   y monoespaciada del sistema sólo en el HUD. */

:root {
  --papel: #14171a;
  --blanco: #1b1f23;
  --linea: #2b3136;
  --linea2: #3d454c;
  --tinta: #e7e9eb;
  --tinta2: #a3abb1;
  --tinta3: #6f787f;
  --acento: #2c7a99;
  --acento-osc: #3b8fb0;
  --acento-txt: #78bfdc;
  --alerta: #e8845a;
  --ok: #5cb58a;
  --fuente: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --izq: 340px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --hud: #eef7f4;
  --hud-tenue: rgba(238,247,244,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color-scheme: dark;
  display: flex; background: var(--papel); color: var(--tinta);
  font: 14px/1.45 var(--fuente); overflow: hidden;
}
a { color: var(--acento-txt); }
[hidden] { display: none !important; }
small { color: var(--tinta3); font-weight: 400; }
button, input, select { font-family: inherit; }

/* ---------- barra lateral ---------- */
#izq {
  flex: none; width: var(--izq); height: 100%; overflow-y: auto; padding: 18px 20px 24px;
  background: var(--blanco); border-right: 1px solid var(--linea);
  scrollbar-width: thin;
}
#izq section { padding: 18px 0; border-top: 1px solid var(--linea); }
.marca { display: flex; gap: 12px; align-items: center; padding-bottom: 16px; }
.ojo { width: 64px; height: 64px; flex: none; display: block; filter: brightness(1.45) saturate(1.1); }
h1 { margin: 0; font-size: 20px; line-height: 1.15; font-weight: 700; }
.marca p { margin: 2px 0 0; font-size: 12.5px; color: var(--tinta2); }
h2 { margin: 0 0 11px; font-size: 14px; font-weight: 700; }
h3 { margin: 0; font-size: 22px; font-weight: 700; }
.etq { display: block; font-size: 12px; font-weight: 600; color: var(--tinta2); }
.nota { margin: 8px 0 0; font-size: 12.5px; color: var(--tinta2); line-height: 1.45; }
.alerta { color: var(--alerta); font-style: normal; }
.bloque { margin-top: 14px; }

/* ---------- formularios ---------- */
.cuadricula { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cuadricula .ancho { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--tinta2); }
label > input, label > select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 8px; font-size: 13.5px; font-weight: 400;
  background: var(--blanco); color: var(--tinta); border: 1px solid var(--linea2); border-radius: 5px;
}
label > input:focus, label > select:focus, button:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.check { display: flex; gap: 8px; margin-top: 12px; font-weight: 400; cursor: pointer; color: var(--tinta); font-size: 13px; }
.check input { display: inline-block; width: 16px; height: 16px; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--acento); }

.boton {
  display: block; width: 100%; margin-top: 14px; padding: 10px 12px; cursor: pointer;
  background: var(--acento); color: #fff; border: 0; border-radius: 5px; font-size: 14px; font-weight: 600;
}
.boton:hover { background: var(--acento-osc); }
.boton:disabled { background: var(--linea2); cursor: progress; }
.boton.claro { background: transparent; color: var(--acento-txt); border: 1px solid var(--linea2); }
.boton.claro:hover { background: var(--papel); }

.segmentos { display: flex; border: 1px solid var(--linea2); border-radius: 5px; overflow: hidden; }
.segmentos button {
  flex: 1; padding: 7px 4px; background: var(--blanco); color: var(--tinta2); border: 0; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.segmentos button + button { border-left: 1px solid var(--linea2); }
.segmentos button:hover { background: var(--papel); }
.segmentos button.on { background: var(--acento); color: #fff; }
.segmentos.pequeno button { padding: 6px 2px; font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chips button {
  padding: 3px 9px; background: var(--blanco); color: var(--tinta2); border: 1px solid var(--linea2);
  border-radius: 12px; font-size: 12.5px; cursor: pointer;
}
.chips button:hover { border-color: var(--acento); }
.chips button.on { background: var(--acento); border-color: var(--acento); color: #fff; }

.vars { list-style: none; margin: 12px 0 0; padding: 0; }
.vars li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 7px 9px; cursor: pointer; border-radius: 5px; color: var(--tinta);
}
.vars li:hover { background: var(--papel); }
.vars li.on { background: #21323b; font-weight: 600; color: var(--acento-txt); }
.vars li .u { font-size: 12px; font-weight: 400; color: var(--tinta3); }
.vars li .n { display: none; }

/* ---------- resumen, leyenda ---------- */
.resumen { margin-top: 16px; padding: 12px 14px; background: var(--papel); border-radius: 6px; }
.resumen .gran { font-size: 30px; font-weight: 700; line-height: 1.1; }
.resumen .gran small { font-size: 13px; margin-left: 5px; }
.rango { position: relative; height: 14px; margin: 8px 0 3px; }
.rango::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 2px; background: var(--linea2); }
.rango i { position: absolute; top: 3px; height: 8px; background: var(--acento-txt); opacity: .4; border-radius: 4px; }
.rango b { position: absolute; top: 1px; width: 3px; height: 12px; background: var(--tinta); border-radius: 1px; }
.rango-etq { display: flex; justify-content: space-between; font-size: 12px; color: var(--tinta2); }
.filas { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.filas dt { color: var(--tinta2); }
.filas dd { margin: 0; text-align: right; }

.asim { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--alerta); border-radius: 6px; }
.asim .fuente { font-weight: 700; color: var(--alerta); font-size: 13px; }
.asim .filas { margin-top: 6px; }

.leyenda { margin-top: 18px; }
.ley-tit { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.ley-tit .etq { color: var(--tinta); }
.ley-tit span:last-child { color: var(--tinta3); white-space: nowrap; }
.barra-color { display: flex; height: 11px; border-radius: 2px; overflow: hidden; border: 1px solid var(--linea2); }
.barra-color i { flex: 1; }
.ticks { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11.5px; color: var(--tinta2); }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.cats div { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.cats i { width: 16px; height: 11px; flex: none; border-radius: 2px; }
.cats i.na { background: repeating-linear-gradient(135deg, var(--linea2) 0 2px, transparent 2px 5px); border: 1px solid var(--linea2); }

/* ---------- exposición ---------- */
.expo { margin-top: 12px; }
.expo .cargando { margin: 0; font-size: 12.5px; color: var(--tinta2); }
.expo table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.expo th { text-align: left; font-size: 12px; font-weight: 600; color: var(--tinta2); padding: 0 0 5px; }
.expo td { padding: 6px 0; border-top: 1px solid var(--linea); vertical-align: top; }
.expo td:last-child, .expo th:last-child { text-align: right; }
.expo tr.pick { cursor: pointer; }
.expo tr.pick:hover td { background: var(--papel); }
.expo .desg { color: var(--tinta2); font-size: 12px; display: block; }
.cifras { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; margin-top: 10px; }
.cifras b { display: block; font-size: 22px; line-height: 1.1; }
.cifras span { font-size: 12px; color: var(--tinta2); line-height: 1.3; display: block; }

/* ---------- procedencia ---------- */
.procedencia ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 12.5px; color: var(--tinta2); }
.procedencia li { padding-left: 10px; border-left: 3px solid var(--ok); }
.procedencia li b { color: var(--ok); }
.procedencia li.sint { border-color: var(--alerta); }
.procedencia li.sint b { color: var(--alerta); }
.procedencia li.pend { border-color: var(--linea2); }
.procedencia li.pend b { color: var(--tinta3); }

/* ---------- mapa ---------- */
#centro { position: relative; flex: 1; min-width: 0; height: 100%; }
#mapa { position: absolute; inset: 0 0 84px 0; background: #16191b; }
.leaflet-container { font-family: var(--fuente); background: #16191b; outline: none; }
.leaflet-tile-pane .tiles { filter: grayscale(1) invert(1) brightness(.78) contrast(.92); }
.leaflet-tile-pane .satelite { filter: grayscale(1) contrast(1.3) brightness(.8); }
.leaflet-hexes-pane { opacity: .56; }
.leaflet-bar { border: 1px solid var(--hud-tenue) !important; border-radius: 0 !important; box-shadow: none !important; }
.leaflet-bar a { color: var(--hud) !important; background: rgba(8,12,14,.6) !important; border-bottom-color: var(--hud-tenue) !important; border-radius: 0 !important; }
.leaflet-bar a:hover { background: rgba(8,12,14,.85) !important; }
.leaflet-top.leaflet-left .leaflet-control-zoom { margin: 22px 0 0 22px; }
.leaflet-bottom.leaflet-left .leaflet-control-scale { margin: 0 0 22px 24px; }
.leaflet-control-scale-line {
  background: none; border-color: var(--hud); color: var(--hud); text-shadow: 0 0 3px #000;
  font: 500 10px/1.3 var(--mono); letter-spacing: .06em;
}
.tip.leaflet-tooltip {
  background: rgba(8,12,14,.86); color: var(--hud); border: 1px solid var(--hud-tenue);
  border-radius: 0; box-shadow: none; padding: 4px 8px; font: 11.5px/1.4 var(--mono); letter-spacing: .03em;
}
.tip.leaflet-tooltip::before { display: none; }
.tip .mar { color: var(--tinta3); }

.hud-etq {
  white-space: nowrap; width: auto !important; height: auto !important; padding: 3px 6px;
  font: 600 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: #0b0f11; background: var(--hud);
}
.fijado { animation: fija .6s linear 1; }
@keyframes fija { 0%, 35% { opacity: 0; } 18%, 55%, 100% { opacity: 1; } }

#hud { position: absolute; z-index: 450; inset: 0 0 84px 0; overflow: hidden; pointer-events: none; color: var(--hud); }
#centro:has(#der:not([hidden])) #hud { right: 384px; }
.hud-ruido, .hud-scan, .hud-vin { position: absolute; inset: 0; }
.hud-scan { background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); }
.hud-vin { background: radial-gradient(ellipse 72% 68% at 50% 50%, transparent 58%, rgba(4,7,9,.62) 100%); }
.hud-ruido {
  inset: -60px; opacity: .07; animation: grano .6s steps(3) infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes grano { 0% { transform: translate(0, 0); } 33% { transform: translate(-23px, 17px); } 66% { transform: translate(19px, -29px); } }
.hud-esq { position: absolute; width: 26px; height: 26px; border: 0 solid var(--hud); opacity: .85; }
.hud-esq.ai { top: 10px; left: 10px; border-width: 2px 0 0 2px; }
.hud-esq.ad { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.hud-esq.bi { bottom: 10px; left: 10px; border-width: 0 0 2px 2px; }
.hud-esq.bd { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }
.hud-mira { position: absolute; left: 50%; top: 50%; width: 88px; height: 88px; margin: -44px 0 0 -44px; opacity: .7; }
.hud-mira::before, .hud-mira::after { content: ""; position: absolute; filter: drop-shadow(0 0 1px #000); }
.hud-mira::before { left: 0; right: 0; top: 50%; height: 1px; background: linear-gradient(90deg, var(--hud) 0 36%, transparent 36% 64%, var(--hud) 64%); }
.hud-mira::after { top: 0; bottom: 0; left: 50%; width: 1px; background: linear-gradient(180deg, var(--hud) 0 36%, transparent 36% 64%, var(--hud) 64%); }
.hud-mira i { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1px 0 0 -1px; background: var(--hud); }
.hud-txt {
  position: absolute; display: flex; flex-direction: column; gap: 2px;
  font: 500 11px/1.35 var(--mono); letter-spacing: .07em; text-transform: uppercase;
  text-shadow: 0 0 2px #000, 0 1px 1px rgba(0,0,0,.8); font-variant-numeric: tabular-nums;
}
.hud-txt b { font-weight: 700; }
.hud-ai { top: 22px; left: 66px; }
.hud-ad { top: 22px; right: 24px; text-align: right; }
.hud-bi { bottom: 50px; left: 24px; }
.hud-vivo::before { content: "● "; color: #ff5b4e; animation: late 1.6s steps(2, jump-none) infinite; }
@keyframes late { 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) {
  .hud-ruido, .hud-vivo::before, .fijado { animation: none; }
}

#progreso { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1200; overflow: hidden; }
#progreso::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--acento); animation: corre 1.1s linear infinite; }
@keyframes corre { from { left: -30%; } to { left: 100%; } }

/* ---------- celda ---------- */
#der {
  position: absolute; z-index: 800; top: 12px; right: 12px; bottom: 96px; width: 360px; overflow-y: auto;
  padding: 16px 18px; background: var(--blanco); border: 1px solid var(--linea2); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5); scrollbar-width: thin;
}
#der section { padding: 14px 0 4px; }
#der section + section { border-top: 1px solid var(--linea); margin-top: 12px; }
.cerrar { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--tinta2); font-size: 26px; line-height: 1; cursor: pointer; }
.cerrar:hover { color: var(--alerta); }
.geo { margin: 4px 0 0; font-size: 12.5px; color: var(--tinta2); }
.geo b { color: var(--tinta); font-weight: 600; }
.geo .mar { color: var(--acento-txt); }
.abanico { margin-top: 12px; }
.abanico svg { display: block; width: 100%; height: auto; overflow: visible; }
.abanico text { font: 400 10.5px var(--fuente); fill: var(--tinta3); }
.abanico .vacio { padding: 24px 10px; text-align: center; color: var(--tinta2); border: 1px dashed var(--linea2); border-radius: 6px; font-size: 13px; }

.obra { display: grid; gap: 11px; }
.obra-fila .cab { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: 13px; }
.obra-fila .cab span:first-child { font-weight: 600; }
.obra-fila .cab span:last-child { font-size: 12px; color: var(--tinta2); }
.dias { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.dias i { height: 15px; display: block; border-radius: 1px; }
.dias i.hoy { outline: 2px solid var(--tinta); outline-offset: 1px; }
.dias i.sin { background: repeating-linear-gradient(135deg, var(--linea2) 0 2px, transparent 2px 5px); }

/* ---------- tiempo ---------- */
#tiempo {
  position: absolute; z-index: 800; left: 0; right: 0; bottom: 0; height: 84px;
  display: grid; grid-template-columns: 36px 160px 1fr; gap: 14px; align-items: center; padding: 8px 20px 8px 16px;
  background: var(--blanco); border-top: 1px solid var(--linea);
}
.play { width: 36px; height: 36px; border: 1px solid var(--linea2); background: var(--blanco); color: var(--tinta); cursor: pointer; padding: 0; display: grid; place-content: center; border-radius: 50%; }
.play svg { width: 14px; height: 14px; fill: currentColor; }
.play:hover { border-color: var(--acento-osc); color: var(--acento-txt); }
.tl-info { display: grid; gap: 1px; line-height: 1.2; }
.tl-info strong { font-size: 22px; font-weight: 700; }
.tl-valor { font-size: 12px; color: var(--tinta2); }
.barras { display: flex; align-items: flex-end; gap: 4px; height: 64px; min-width: 0; }
.barra { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; position: relative; }
.barra .col { background: #34444d; transition: height .25s; min-height: 2px; border-radius: 2px 2px 0 0; }
.barra:hover .col { background: #4d6572; }
.barra.on .col { background: var(--acento-osc); }
.barra .d { margin-top: 3px; font-size: 11px; line-height: 1.1; text-align: center; color: var(--tinta3); white-space: nowrap; }
.barra.on .d { color: var(--tinta); font-weight: 600; }
.barra .v { display: none; }

#pie { position: absolute; z-index: 850; right: 12px; bottom: 96px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#pie-txt {
  max-width: 460px; padding: 9px 12px; background: var(--blanco); border: 1px solid var(--linea2); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5); font-size: 12.5px; color: var(--tinta2); line-height: 1.45;
}
#b-pie {
  width: 24px; height: 24px; padding: 0; background: var(--blanco); color: var(--tinta2); border: 1px solid var(--linea2);
  border-radius: 50%; font: italic 700 13px/1 Georgia, "Times New Roman", serif; cursor: pointer; opacity: .85;
}
#b-pie:hover { color: var(--tinta); opacity: 1; }
#aviso {
  position: fixed; z-index: 1300; top: 14px; left: 50%; transform: translateX(-50%);
  max-width: min(560px, 90vw); padding: 10px 16px; background: var(--blanco); color: var(--tinta);
  border: 1px solid var(--alerta); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.5); font-size: 13px;
}

/* ---------- estrecho ---------- */
@media (max-width: 900px) {
  body { flex-direction: column; overflow: auto; }
  #izq { width: 100%; height: auto; max-height: 48vh; border-right: 0; border-bottom: 1px solid var(--linea); }
  #centro { flex: none; height: 100vh; }
  #der { left: 8px; right: 8px; width: auto; top: auto; bottom: 96px; max-height: 55%; }
  #tiempo { grid-template-columns: 36px 1fr; height: auto; }
  .barras { grid-column: 1 / -1; }
}
