/* Oficina Nexus v2 — «muelle vertical» (cerrado) y anillo (abierto). Solo se anima transform/opacity. */
@font-face { font-family: "Montserrat"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/montserrat-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #0B1118; --floor: #121C28; --slab: #1B2A3A; --edge: #2A3D52; --text: #EAF0F7; --text2: #8FA3B8;
  --st-work: #4D8DFF; --st-wait: #5C7188; --st-done: #2FD08A; --st-need: #FFC247; --st-err: #FF5D5D;
  --ink-on-need: #0B1118;
  --f-head: "Montserrat", "Segoe UI", system-ui, sans-serif; --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --tab-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --pad: 16px; --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 600 15px/1.35 var(--f-head); }
body { overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-weight: 500; }

/* Iconos: máscaras de los SVG locales, coloreadas con currentColor / --c */
.ico { display: inline-block; width: 18px; height: 18px; flex: none; background: var(--c, currentColor);
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.i-gear { --ico: url("../icons/gear.svg"); } .i-pause { --ico: url("../icons/pause.svg"); } .i-check { --ico: url("../icons/check.svg"); }
.i-cross { --ico: url("../icons/cross.svg"); } .i-hand { --ico: url("../icons/hand.svg"); } .i-warn { --ico: url("../icons/warn.svg"); }
.i-back { --ico: url("../icons/back.svg"); } .i-office { --ico: url("../icons/office.svg"); } .i-list { --ico: url("../icons/list.svg"); } .i-pulse { --ico: url("../icons/pulse.svg"); }

/* ---------- Pantalla de acceso ---------- */
.login { height: 100%; display: grid; place-content: center; gap: 18px; padding: calc(var(--pad) + var(--safe-t)) var(--pad) var(--pad); max-width: 420px; margin: 0 auto; }
.login > * { width: 100%; }
.login form { display: grid; gap: 14px; }
.login .brand { display: flex; align-items: center; gap: 14px; }
.login .brand-mark { width: 56px; height: 56px; background: var(--slab) url("../icons/mark.svg") center / 70% no-repeat; border: 1px solid var(--edge); border-radius: 14px; }
.login h1 { margin: 0; font-weight: 800; font-size: 26px; letter-spacing: -0.01em; }
.login p { margin: 0; color: var(--text2); }
.login label { display: grid; gap: 6px; font-size: 13px; color: var(--text2); }
.login input { min-height: 52px; border-radius: 12px; border: 1px solid var(--edge); background: var(--floor); color: var(--text); padding: 0 14px; font: 500 20px var(--f-mono); }
.login input.code { letter-spacing: 0.4em; text-align: center; font-size: 26px; }
.btn { min-height: 52px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 800; text-align: center; padding: 0 18px; display: flex; align-items: center; justify-content: center; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--edge); }
.msg { min-height: 20px; font-size: 14px; color: var(--st-err); margin: 0; }
.msg.info { color: var(--text2); }

/* ---------- Estructura ---------- */
.shell { height: 100%; display: flex; flex-direction: column; }
.shell > * { flex: none; }
.shell > main { flex: 1 1 0; }
.top { display: flex; align-items: stretch; padding-top: var(--safe-t); background: var(--bg); border-bottom: 1px solid var(--edge); }
.statusline { flex: 1; min-height: 52px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 6px var(--pad); font-size: 13px; }
.statusline .age { font-family: var(--f-mono); font-weight: 500; color: var(--text2); }
.statusline .need { font-weight: 800; font-size: 14px; }
.statusline .need.has { color: var(--st-need); }
.statusline .dot { color: var(--edge); }
.logout { min-width: 64px; min-height: 52px; padding: 0 var(--pad); color: var(--text2); font-size: 13px; display: flex; align-items: center; }
.banner { display: flex; align-items: center; gap: 8px; padding: 8px var(--pad); font-size: 13px; border-bottom: 1px solid var(--edge); }
.banner.ambar { background: #3A2E10; color: #FFD98A; }
.banner.gris, .banner.ayer { background: var(--floor); color: var(--text2); }
.banner.offline { background: var(--floor); color: var(--text2); }
main { position: relative; min-height: 0; overflow: hidden; background: var(--floor); }
.tab { height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tab[hidden] { display: none; }
.tabbar { display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--bg); border-top: 1px solid var(--edge); }
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text2); font-size: 12px; min-height: 48px; }
.tabbar button[aria-selected="true"] { color: var(--text); font-weight: 800; }
.tabbar button[aria-selected="true"]::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px; background: var(--text); border-radius: 0 0 3px 3px; }
.tabbar .count { position: absolute; top: 4px; left: calc(50% + 10px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--st-need); color: var(--ink-on-need); font: 500 11px/18px var(--f-mono); text-align: center; }

/* ---------- Oficina: núcleo + carril + puestos ---------- */
.office { position: relative; padding: 14px var(--pad) 28px; }
.core { position: relative; z-index: 2; display: grid; justify-items: center; gap: 6px; padding: 16px 0 12px; margin: 0 auto 6px; width: 100%; max-width: 260px;
  background: var(--slab); border: 1px solid var(--edge); border-radius: 20px; }
.core .logo { width: 150px; height: 64px; background: var(--text); -webkit-mask: url("../img/nexus-logo.svg") center / contain no-repeat; mask: url("../img/nexus-logo.svg") center / contain no-repeat; }
.core .cap { font: 500 11px var(--f-mono); letter-spacing: 0.14em; color: var(--text2); text-transform: uppercase; }
.lane { position: absolute; left: 50%; top: 142px; bottom: 24px; width: 2px; margin-left: -1px; background: var(--edge); overflow: hidden; border-radius: 1px; }
.lane::after { content: ""; position: absolute; left: 0; right: 0; top: -44px; bottom: 0; opacity: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 30px, var(--st-work) 30px 38px, transparent 38px 44px); }
.office[data-flow="1"] .lane::after { opacity: 0.9; animation: flow 1.4s linear infinite; }
@keyframes flow { to { transform: translateY(44px); } }

.stations { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(100px, auto); column-gap: 24px; margin-top: 4px; position: relative; padding-top: 30px; }
.stn { --c: var(--st-wait); position: relative; display: grid; grid-template-rows: auto auto auto; justify-items: start; align-content: start; gap: 6px;
  padding: 0 12px 12px; min-height: 48px; background: var(--slab); border: 1px solid var(--edge); border-radius: 16px 16px 16px 6px; margin-bottom: 16px;
  grid-column: 1; grid-row: var(--k) / span 2; align-self: start; }
.stn:nth-child(even) { grid-column: 2; border-radius: 16px 16px 6px 16px; }
.stn .spr { width: 72%; height: auto; aspect-ratio: 1; margin: -26px auto -8px; justify-self: center; pointer-events: none; transition: opacity 0.3s; }
.stn .nm { font-weight: 800; font-size: 14px; line-height: 1.15; }
.stn .grp { font: 500 10.5px var(--f-mono); letter-spacing: 0.08em; color: var(--text2); text-transform: uppercase; }
.stn .head { display: grid; gap: 1px; }
.stn .stub { position: absolute; top: 58%; width: 12px; height: 2px; background: var(--c); opacity: 0.8; }
.stn:nth-child(odd) .stub { right: -13px; } .stn:nth-child(even) .stub { left: -13px; }
.stn .pkt { position: absolute; top: calc(58% - 3px); width: 8px; height: 8px; border-radius: 2px; background: var(--st-work); opacity: 0; }
.stn:nth-child(odd) .pkt { right: -13px; } .stn:nth-child(even) .pkt { left: -13px; }
.stn .cnt { position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--st-need); color: var(--ink-on-need); font: 500 13px/24px var(--f-mono); text-align: center; }
.stn .beacon { position: absolute; inset: -5px; border: 3px solid var(--st-need); border-radius: 20px 20px 20px 9px; pointer-events: none; opacity: 0; }

.chip { --c: var(--st-wait); display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 9px 0 6px; border-radius: 13px; border: 1.5px solid var(--c); background: var(--bg); color: var(--text); font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.chip .ico { width: 15px; height: 15px; }
[data-estado="trabajando"] { --c: var(--st-work); }
[data-estado="espera"] { --c: var(--st-wait); }
[data-estado="hecho"] { --c: var(--st-done); }
[data-estado="te_necesito"] { --c: var(--st-need); }
[data-estado="error"] { --c: var(--st-err); }
.chip.is-espera { color: var(--text2); } .chip.is-espera .ico { background: var(--text2); }
.chip.is-te_necesito { background: var(--st-need); color: var(--ink-on-need); font-weight: 800; } .chip.is-te_necesito .ico { background: var(--ink-on-need); }
.office[data-flow="1"] .stn[data-estado="trabajando"] .chip .ico { animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.office[data-flow="1"] .stn[data-estado="trabajando"] .pkt { animation: hop 1.6s linear infinite; }
.office[data-flow="1"] .stn[data-estado="trabajando"]:nth-child(even) .pkt { animation-name: hop-r; }
@keyframes hop { 0% { transform: translateX(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateX(13px); opacity: 0; } }
@keyframes hop-r { 0% { transform: translateX(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateX(-13px); opacity: 0; } }

/* TE NECESITO: baliza ámbar muy visible. Estática siempre (borde + brillo); pulso solo con movimiento permitido. */
.stn[data-estado="te_necesito"] { border-color: var(--st-need); background: #2A2616; box-shadow: 0 0 0 1px var(--st-need), 0 6px 28px -6px rgba(255, 194, 71, 0.55); }
.stn[data-estado="te_necesito"] .beacon { opacity: 0.9; animation: beacon 1.8s ease-in-out infinite; }
@keyframes beacon { 0%, 100% { transform: scale(1); opacity: 0.95; } 50% { transform: scale(1.045); opacity: 0.35; } }
.stn[data-estado="error"] { border-color: var(--st-err); }

/* Datos viejos (>60 min o de otro día): puestos apagados, sin carriles ni movimiento */
.office[data-off="1"] .stn .spr, .office[data-off="1"] .personal .spr { opacity: 0.45; filter: grayscale(1); }
.office[data-off="1"] .stn:not([data-estado="te_necesito"]):not([data-estado="error"]) .chip { color: var(--text2); border-color: var(--edge); }
.office[data-off="1"] .stn:not([data-estado="te_necesito"]):not([data-estado="error"]) .chip .ico { background: var(--text2); }
.office[data-off="1"] .stub, .office[data-off="1"] .pkt, .office[data-off="1"] .lane { display: none; }
.office[data-off="1"] .stn * { animation: none !important; }
.office[data-off="1"] .stn[data-estado="te_necesito"] .beacon { animation: none; opacity: 0.9; }

.personal { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px 12px; margin-top: 24px; padding: 8px 14px 8px 4px; background: var(--slab); border: 1px dashed var(--edge); border-radius: 16px; position: relative; }
.personal .tag { grid-column: 1 / -1; font: 500 10.5px var(--f-mono); letter-spacing: 0.14em; color: var(--text2); padding: 2px 10px 0; text-transform: uppercase; }
.personal .spr { width: 96px; height: 96px; }
.personal .nm { font-weight: 800; font-size: 14px; display: block; }
.personal .sub { color: var(--text2); font-size: 13px; }

/* ---------- Lista de pendientes y actividad ---------- */
.list { padding: 8px 0 24px; margin: 0; list-style: none; }
.sec { font: 500 11px var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text2); padding: 18px var(--pad) 8px; margin: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; width: 100%; min-height: 56px; padding: 10px var(--pad); border-bottom: 1px solid var(--edge); }
.row .who { font: 500 11px var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--st-need); grid-column: 1 / -1; }
.row .ttl { font-weight: 600; font-size: 16px; line-height: 1.3; }
.row .when { font: 500 12px var(--f-mono); color: var(--text2); white-space: nowrap; }
.row .nm { font-weight: 800; }
.row .st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); }
.row .st .ico { color: var(--c); }
.empty { padding: 40px var(--pad); color: var(--text2); text-align: center; }
.meter { margin: 6px var(--pad) 0; height: 8px; background: var(--edge); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--st-work); transform-origin: 0 50%; border-radius: 4px; }

/* ---------- Hoja de detalle de un puesto ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 9, 14, 0.62); opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 78%; overflow-y: auto; z-index: 21; background: var(--slab); border: 1px solid var(--edge); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 14px var(--pad) calc(18px + var(--safe-b)); transform: translateY(105%); transition: transform 0.3s var(--ease); max-width: 640px; margin: 0 auto; }
body[data-sheet="1"] .scrim { opacity: 1; pointer-events: auto; }
body[data-sheet="1"] .sheet { transform: none; }
.sheet .grab { width: 44px; height: 4px; border-radius: 2px; background: var(--edge); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 8px; font-weight: 800; font-size: 22px; }
.sheet .meta { color: var(--text2); font-size: 14px; margin: 8px 0 4px; }
.sheet .close { min-height: 48px; min-width: 48px; position: absolute; top: 8px; right: 8px; display: grid; place-items: center; color: var(--text2); font-size: 22px; }
.sheet .pl { margin: 10px 0 0; padding: 0; list-style: none; }
.sheet .pl li { padding: 10px 0; border-top: 1px solid var(--edge); font-size: 16px; }

/* ---------- ABIERTO (Fold desplegado, tablet, escritorio): anillo alrededor del núcleo ---------- */
@media (min-width: 600px) {
  :root { --pad: 20px; }
  .office { height: 100%; padding: 0; container-type: size; max-width: 1180px; margin: 0 auto; }
  .tab#tab-oficina { overflow: hidden; }
  .core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 230px; max-width: none; padding: 20px 0 14px; margin: 0; border-radius: 26px; box-shadow: 0 0 0 10px var(--floor), 0 0 0 11px var(--edge); }
  .core .logo { width: 170px; height: 72px; }
  .lane { display: none; }
  .stations { display: block; position: absolute; inset: 0; padding: 0; margin: 0; }
  .stn { position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: clamp(116px, 15cqw, 176px); transform: translate(-50%, -50%); margin: 0 !important; gap: 4px; padding: 0 8px 9px; border-radius: 14px 14px 14px 5px !important; }
  .stn .spr { margin: -24px 0 -6px; }
  .stn .nm { font-size: 12.5px; }
  .stn .grp { font-size: 9.5px; }
  .stn .chip { font-size: 10.5px; min-height: 24px; padding: 0 7px 0 5px; }
  .stn .stub { left: 50% !important; right: auto !important; top: 46%; width: calc(hypot(var(--dx) * 1cqw, var(--dy) * 1cqh)); height: 2px; transform-origin: 0 50%; transform: rotate(atan2(calc(var(--dy) * -1cqh), calc(var(--dx) * -1cqw))); z-index: -1; opacity: 0.55; }
  .stn .pkt { left: 50% !important; right: auto !important; top: calc(46% - 4px); }
  .office[data-flow="1"] .stn[data-estado="trabajando"] .pkt { animation: fly 2.6s linear infinite !important; }
  @keyframes fly { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translate(calc(var(--dx) * -1cqw), calc(var(--dy) * -1cqh)); opacity: 0; } }
  .stn .cnt { top: 6px; right: 6px; min-width: 22px; height: 22px; font-size: 12px; line-height: 22px; }
  .stn .beacon { border-radius: 18px 18px 18px 8px; }
  .stations .stn:nth-child(1) { --x: 23; --y: 13; --dx: -27; --dy: -37; }
  .stations .stn:nth-child(2) { --x: 41; --y: 13; --dx: -9; --dy: -37; }
  .stations .stn:nth-child(3) { --x: 59; --y: 13; --dx: 9; --dy: -37; }
  .stations .stn:nth-child(4) { --x: 77; --y: 13; --dx: 27; --dy: -37; }
  .stations .stn:nth-child(5) { --x: 89.5; --y: 37; --dx: 39.5; --dy: -13; }
  .stations .stn:nth-child(6) { --x: 89.5; --y: 62; --dx: 39.5; --dy: 12; }
  .stations .stn:nth-child(7) { --x: 70; --y: 87; --dx: 20; --dy: 37; }
  .stations .stn:nth-child(8) { --x: 50; --y: 87; --dx: 0; --dy: 37; }
  .stations .stn:nth-child(9) { --x: 30; --y: 87; --dx: -20; --dy: 37; }
  .stations .stn:nth-child(10) { --x: 10.5; --y: 62; --dx: -39.5; --dy: 12; }
  .stations .stn:nth-child(11) { --x: 10.5; --y: 37; --dx: -39.5; --dy: -13; }
  .personal { position: absolute; left: 14px; bottom: 14px; width: 180px; grid-template-columns: 1fr; margin: 0; padding: 0 10px 10px; justify-items: start; gap: 2px; }
  .personal .spr { width: 64px; height: 64px; margin: -6px 0 -2px 0; }
  .personal .tag { padding: 8px 0 0; }
  .sheet { bottom: 12px; border-radius: 22px; border-bottom: 1px solid var(--edge); }
  .row { max-width: 760px; margin: 0 auto; }
  .sec { max-width: 760px; margin: 0 auto; }
  .meter { max-width: 728px; margin-left: auto; margin-right: auto; }
}

/* ---------- Movimiento ---------- */
:root[data-paused] *, :root[data-paused] *::before, :root[data-paused] *::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .stn[data-estado="te_necesito"] .beacon { opacity: 0.9; }
  .stn .pkt { display: none; }
}
