:root {
  --bg: #04060c; --bg2: #070b13; --surface: #0b1018; --surface2: #0e1622;
  --text: #eaf6ff; --muted: #7d96a3; --dim: #4f6b78;
  --cyan: #22d3ee; --cyan-soft: rgba(34,211,238,.10); --border: rgba(34,211,238,.16);
  --green: #34d399; --red: #fb7185; --amber: #eab308; --purple: #9b6bff; --vader: #e23b3b;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --disp: "Syne", system-ui, sans-serif; --body: "Space Grotesk", system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--body);
  overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; position: relative; }
.hud-line { position: fixed; top: 0; left: 24px; right: 24px; height: 1px; background: linear-gradient(90deg, transparent, rgba(34,211,238,.8), transparent); }

/* LOGIN */
.login-card { width: 100%; max-width: 340px; text-align: center; }
.brand { font-family: var(--mono); font-weight: 700; font-size: 26px; letter-spacing: .04em; line-height: 1.15; }
.brand span { display: block; font-size: 13px; color: var(--dim); letter-spacing: .34em; margin-top: 4px; }
.login-card .sub { color: var(--muted); font-size: 12px; margin: 14px 0 26px; letter-spacing: .04em; }
#pw { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 15px 16px; border-radius: 12px; font: inherit; font-size: 16px; outline: none; text-align: center; letter-spacing: .1em; }
#pw:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
#loginBtn { width: 100%; margin-top: 12px; background: var(--cyan); color: #04141a; font-weight: 700;
  font-family: var(--mono); letter-spacing: .08em; border: none; padding: 15px; border-radius: 12px; font-size: 15px; cursor: pointer; }
#loginBtn:active { transform: scale(.98); }
.err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-foot { position: absolute; bottom: 26px; font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: .2em; }

/* APP shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(14px); padding-top: max(14px, env(safe-area-inset-top)); background: rgba(4,6,12,.9);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.tb-l { display: flex; align-items: center; gap: 12px; }
.logo { font-family: var(--mono); font-weight: 700; font-size: 16px; letter-spacing: .05em; }
.pulse { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--green); }
.pulse i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--cyan); width: 38px; height: 38px;
  border-radius: 11px; font-size: 18px; cursor: pointer; }
.icon-btn:active { transform: rotate(90deg); }

main { padding: 16px 14px 96px; max-width: 520px; margin: 0 auto; }
.kicker { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--dim); text-transform: uppercase; margin: 18px 4px 9px; }
.kicker:first-child { margin-top: 4px; }

/* cards */
.card { background: var(--surface); border: 1px solid rgba(255,255,255,.07); border-radius: 14px; padding: 14px 15px; }
.glow { border-color: var(--border); background: linear-gradient(180deg, var(--cyan-soft), rgba(34,211,238,.02)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stat .l { font-size: 11px; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 22px; margin-top: 3px; }
.big .v { font-size: 32px; color: var(--cyan); text-shadow: 0 0 16px rgba(34,211,238,.45); }
.row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; background: rgba(255,255,255,.02); border-radius: 11px; }
.row + .row { margin-top: 7px; }
.accent { width: 3px; align-self: stretch; min-height: 22px; border-radius: 3px; }
.row .emo { font-size: 16px; }
.row .nm { flex: 1; font-size: 13.5px; font-weight: 600; }
.row .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; font-family: var(--mono); margin-top: 2px; }
.tagstat { font-family: var(--mono); font-size: 8px; letter-spacing: .12em; display: inline-flex; align-items: center; gap: 4px; }
.tagstat i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.on2 { color: var(--green); } .on2 i { background: var(--green); box-shadow: 0 0 6px var(--green); }
.off2 { color: var(--dim); } .off2 i { background: #34465a; }
.money-pos { color: var(--green); } .money-neg { color: var(--red); }
.vader-q { font-size: 12px; color: #c9d8df; border-left: 2px solid var(--vader); padding-left: 9px; margin-top: 10px; font-style: italic; }

.btn { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--cyan); font-family: var(--mono);
  font-size: 12px; letter-spacing: .06em; padding: 11px; border-radius: 10px; cursor: pointer; }
.btn:active { transform: scale(.98); background: var(--cyan-soft); }
.btn.danger { color: var(--red); border-color: rgba(251,113,133,.3); }
.btn.solid { background: var(--cyan); color: #04141a; font-weight: 700; border: none; }

/* chart */
.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 16px; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 8px; justify-content: center; }
.legend span i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* chat */
.chat-log { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; max-height: 46vh; overflow-y: auto; }
.bub { padding: 10px 13px; border-radius: 13px; font-size: 14px; line-height: 1.45; max-width: 86%; }
.bub.me { align-self: flex-end; background: var(--cyan); color: #04141a; border-bottom-right-radius: 4px; }
.bub.ai { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-in { display: flex; gap: 8px; }
.chat-in input { flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 13px 14px; border-radius: 12px; font: inherit; outline: none; }
.chat-in input:focus { border-color: var(--cyan); }
.chat-in button { background: var(--cyan); color: #04141a; border: none; border-radius: 12px; width: 50px; font-size: 18px; font-weight: 700; }

/* tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; align-items: center;
  background: rgba(7,11,19,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--border);
  padding: 9px 4px max(11px, env(safe-area-inset-bottom)); z-index: 10; }
.tab { background: none; border: none; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--mono); font-size: 8.5px; cursor: pointer; padding: 4px 8px; }
.tab span { font-size: 18px; filter: grayscale(.6); transition: filter .2s; }
.tab.on { color: var(--cyan); }
.tab.on span { filter: none; transform: translateY(-1px); }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 11px 18px; border-radius: 999px; font-size: 13px; z-index: 30; opacity: 0; transition: opacity .3s; }
.toast.show { opacity: 1; }
.loading { text-align: center; color: var(--dim); font-family: var(--mono); font-size: 12px; padding: 40px 0; }

/* ============================================================
   ICONOS FUTURISTAS (SVG holográfico) + HERO 3D
   icons.js emite <svg class="ic"> con hijos .ic-node / .ic-scanline /
   .ic-ring / .ic-flow / .ic-eye. El color lo da el contenedor (currentColor).
   ============================================================ */
.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.2em;
  flex: none; overflow: visible; color: inherit; }
.ic-node { transform-box: fill-box; transform-origin: center; }

/* nodo de dato vivo: pulso */
.ic-pulse { transform-box: fill-box; transform-origin: center; animation: ic-pulse 1.7s ease-in-out infinite; }
@keyframes ic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; transform: scale(1.55); } }

/* línea de escaneo "leyendo datos" */
.ic-scanline { transform-box: fill-box; transform-origin: center; animation: ic-scan 2.4s ease-in-out infinite; }
@keyframes ic-scan { 0%, 100% { opacity: .3; transform: translateY(-1.3px); } 50% { opacity: 1; transform: translateY(1.3px); } }

/* anillo orbital: oculto en reposo, se revela girando en estado activo/fetch */
.ic-ring { transform-box: fill-box; transform-origin: center; }
@keyframes ic-spin { to { transform: rotate(360deg); } }

/* flujo de datos por líneas punteadas */
.ic-flow { animation: ic-flow 1.3s linear infinite; }
@keyframes ic-flow { to { stroke-dashoffset: -8; } }

/* ojo centinela VADER: parpadeo irregular */
.ic-eye { transform-box: fill-box; transform-origin: center; animation: ic-eye 3s steps(1, end) infinite; }
@keyframes ic-eye { 0%, 17%, 21%, 69%, 73%, 100% { opacity: 1; } 19%, 71% { opacity: .2; } }

@media (prefers-reduced-motion: reduce) {
  .ic-pulse, .ic-scanline, .ic-flow, .ic-eye, .ic-ring { animation: none !important; }
}

/* tamaños por contexto */
.kicker .ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; color: var(--cyan); opacity: .85; }
.stat .l .ic { width: 15px; height: 15px; vertical-align: -2.5px; margin-right: 5px; color: var(--cyan); opacity: .92; }
.row .emo .ic { width: 19px; height: 19px; vertical-align: middle; }
.btn .ic, .chat-in button .ic { width: 15px; height: 15px; vertical-align: -2.5px; margin-right: 5px; }
.chat-in button .ic { margin: 0; width: 18px; height: 18px; }
.icon-btn .ic { width: 19px; height: 19px; vertical-align: -4px; }
.logo .ic { width: 17px; height: 17px; vertical-align: -3px; margin-right: 4px; }
.login-foot .ic { width: 12px; height: 12px; vertical-align: -2px; margin-right: 4px; }
.brand-mark { display: inline-block; color: var(--cyan); margin-bottom: 12px; filter: drop-shadow(0 0 12px rgba(34,211,238,.6)); }
.brand-mark .ic { width: 46px; height: 46px; }

/* tabs: icono con lift 3D al activar.
   OJO: NO poner perspective/transform/filter en .tabs (fixed) -> en WebKit móvil
   eso "despega" el position:fixed y la barra scrollea. El perspective va en el
   transform del propio icono (función perspective()), no en el contenedor. */
.tab span { font-size: inherit; filter: none; transform: none; }
.tab .ic { width: 22px; height: 22px; transition: transform .26s cubic-bezier(.2,.8,.2,1.25), filter .22s ease; }
.tab.on .ic { filter: drop-shadow(0 0 6px var(--cyan)); transform: perspective(600px) translateY(-3px) scale(1.08) rotateX(14deg); }
.tab.on .ic-ring { opacity: .55; animation: ic-spin 4s linear infinite; }
.icon-btn:active .ic-ring, .btn:active .ic-ring { opacity: .6; animation: ic-spin 1s linear infinite; }

/* HERO 3D — El Núcleo de Mando */
.hero3d { position: relative; width: 100%; height: 190px; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(120% 95% at 50% 62%, rgba(34,211,238,.08), rgba(34,211,238,.012) 58%, transparent 76%);
  margin-bottom: 12px; }
.hero3d canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.hero-ov { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: 13px 15px; }
.ho-top { display: flex; justify-content: space-between; align-items: flex-start; }
.ho-k { font-family: var(--mono); font-size: 8.5px; letter-spacing: .22em; color: var(--dim); text-transform: uppercase; }
.ho-chip { font-family: var(--mono); font-size: 8px; letter-spacing: .14em; color: var(--green); display: inline-flex; gap: 5px; align-items: center; }
.ho-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.4s infinite; }
.ho-big { font-family: var(--mono); font-weight: 700; font-size: 30px; line-height: 1; color: var(--cyan); text-shadow: 0 0 18px rgba(34,211,238,.5); margin-top: 2px; }
.ho-big small { font-size: 14px; color: var(--muted); }
.vader-row { display: flex; align-items: center; gap: 9px; }
.vader-row .vd { color: var(--vader); flex: none; filter: drop-shadow(0 0 5px rgba(226,59,59,.5)); }
.vader-row .vd .ic { width: 20px; height: 20px; }
.vader-row .vt { font-size: 12px; color: #d3e0e6; font-style: italic; }

/* PLANETA de la flota (pestaña Agentes) */
.planet3d { position: relative; width: 100%; height: 270px; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(120% 95% at 50% 52%, rgba(34,211,238,.09), rgba(34,211,238,.012) 55%, transparent 72%);
  margin-bottom: 12px; }
.planet3d canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.planet-ov { position: absolute; left: 14px; top: 12px; right: 14px; pointer-events: none; display: flex; justify-content: space-between; align-items: flex-start; }
.planet-ov .pk { font-family: var(--mono); font-size: 8.5px; letter-spacing: .22em; color: var(--dim); text-transform: uppercase; }
.planet-ov .pc { font-family: var(--mono); font-size: 8px; letter-spacing: .14em; color: var(--green); display: inline-flex; gap: 5px; align-items: center; }
.planet-ov .pc i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.4s infinite; }
