/* ==========================================================================
   Gemelo Digital · SEMITEC — hoja de estilos
   Paleta: noche de laboratorio #16191c, paneles #1f2428, acero #d5dbe0,
           alarma #e8251a, enlace #22c55e. Tipografía: Inter Tight + Inter.
   ========================================================================== */
:root {
  --bg: #16191c;
  --panel: #1f2428;
  --panel-2: #262c31;
  --line: #343b41;
  --ink: #eef1f3;
  --mute: #9aa6b1;
  --steel: #d5dbe0;
  --red: #e8251a;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --side: 400px;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}
h1, h2 { font-family: "Inter Tight", Inter, sans-serif; margin: 0; text-wrap: balance; }
.muted { color: var(--mute); font-size: 13px; margin: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.eyebrow { margin: 0 0 2px; font-size: 12px; color: var(--mute); }
.brand h1 { font-size: clamp(18px, 2.1vw, 24px); line-height: 1.15; }
.conn { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.source { font-size: 12px; color: var(--mute); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.source.is-demo { color: #0e1113; background: var(--warn); border-color: var(--warn); font-weight: 600; }
.status {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px;
  padding: 6px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap;
}
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--mute); }
.st-ok i { background: var(--ok); box-shadow: 0 0 0 4px rgba(34, 197, 94, .2); animation: pulse 2s infinite; }
.st-warn i { background: var(--warn); }
.st-bad { color: #fecaca; }
.st-bad i { background: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); } }

/* ---------- Distribución ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); min-height: 0; }
.viewport { position: relative; min-height: 420px; }
.stage { position: absolute; inset: 0; isolation: isolate; z-index: 0; }
.stage canvas { display: block; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }
.label-layer.is-hidden { display: none; }
.side { border-left: 1px solid var(--line); overflow: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }

/* ---------- Barra de herramientas ---------- */
.toolbar { position: absolute; left: 14px; top: 14px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 3; }
.seg { display: flex; background: rgba(31, 36, 40, .92); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; backdrop-filter: blur(6px); }
button {
  font: 600 13px Inter, sans-serif; min-height: 40px; padding: 6px 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--ink);
}
button:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--panel-2); }
button[aria-pressed="true"] { background: var(--steel); color: #0e1113; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.btn-ghost { border-color: var(--line); }
.hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); margin: 0; font-size: 12px; color: #cfd6dc; background: rgba(0, 0, 0, .45); padding: 4px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none; }
.replay-bar {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 12px; background: var(--warn); color: #0e1113; font-size: 13px;
  padding: 6px 6px 6px 14px; border-radius: 12px; white-space: nowrap;
}
.replay-bar button { background: #0e1113; color: #fff; min-height: 34px; }
.toolbar + .replay-bar { top: 70px; }

/* ---------- Etiquetas 3D ---------- */
.lbl {
  font: 600 12px Inter, sans-serif; color: #fff; background: rgba(14, 17, 19, .88); border: 1px solid rgba(255, 255, 255, .22);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap; cursor: pointer; pointer-events: auto; user-select: none;
  transition: opacity .2s;
}
.lbl b { font-weight: 600; }
.lbl .lv { display: block; font: 700 14px "Inter Tight", sans-serif; color: #fde68a; text-align: center; }
.lbl.warn .lv { color: #fecaca; }
.lbl:hover, .lbl.on { background: var(--red); border-color: var(--red); }
.lbl.occluded { opacity: 0; pointer-events: none; }

/* ---------- Tarjetas laterales ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.tile .pin { font-size: 11px; color: var(--mute); font-weight: 600; }
.tile b { display: block; font: 700 20px/1.2 "Inter Tight", sans-serif; white-space: nowrap; }
.tile b small { font-size: 12px; color: var(--mute); margin-left: 2px; }
.tile .name { font-size: 11.5px; color: var(--mute); }
.tile.is-alert { background: var(--red); border-color: var(--red); }
.tile.is-alert .pin, .tile.is-alert .name { color: #fee2e2; }
.tiles.is-replay .tile { border-color: var(--warn); }
.notice { color: var(--warn); font-size: 12.5px; margin: 8px 0 0; }
.notice:empty { display: none; }

.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--mute); margin-bottom: 10px; }
select {
  font: 15px Inter, sans-serif; min-height: 42px; padding: 8px 10px; border-radius: 9px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
}
.chart { position: relative; height: 230px; }
.replay { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 10px 0 6px; }
.replay button { border-color: var(--line); }
input[type="range"] { width: 100%; accent-color: var(--red); min-height: 32px; }

.info h2 { font-size: 18px; }
.info p { margin: 8px 0 12px; color: #d7dde2; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: 600 12px Inter, sans-serif; background: var(--steel); color: #0e1113; border-radius: 6px; padding: 2px 8px; }

.foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 20px; font-size: 12px; color: var(--mute); border-top: 1px solid var(--line); }
.noscript { padding: 20px; }

/* ---------- Responsivo ---------- */
@media (max-width: 980px) {
  html, body { height: auto; }
  body { display: block; overflow-x: clip; }
  .layout { grid-template-columns: 1fr; }
  .replay-bar { left: 12px; right: 12px; top: auto; bottom: 12px; transform: none; white-space: normal; flex-wrap: wrap; }
  .toolbar + .replay-bar { top: auto; }
  .viewport { height: 62vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .hint { display: none; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg button { padding: 6px 8px; font-size: 12px; }
  .replay-bar { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .st-ok i { animation: none; } }
