/* ════════════════════════════════════════════════════════════════
 * QRIL Chart Terminal — Signal UFO System (Carousel + Active Monitor)
 *
 /* v3 — 1:1 asset skin. The UFO card and the Active Signal Monitor now
  * use the ORIGINAL PNG graphics as fixed visual frames; only dynamic
  * signal data (screenshots + labels) is layered on top through percentage
  * positioned slots. No CSS redraw of the frame, no re-rendered static text.
  *
  * Assets (both 1448×1086, so all slot geometry is a percentage of the card):
  *   /static/assets/signal-ufo/signal-ufo-frame.png
  *   /static/assets/signal-ufo/active-signal-ufo-monitor.png
  */

:root {
  --ufo-accent: var(--chart-cyan, #39c5cf);
  --ufo-accent-dim: rgba(57, 197, 207, 0.16);
  --ufo-accent-glow: rgba(57, 197, 207, 0.35);
  /* ── Resizable panel sizes (px) — driven by the splitter JS, persisted to localStorage ── */
  --qrl-carousel-h: 160px;   /* Signal UFO carousel height */
  --qrl-monitor-h: 360px;    /* Active Signal UFO monitor height — increased 2026-09-11 to match the Quant Signal Radar sibling panel (3:2 vorlage-header.png aspect ratio). */
  --qrl-market-h: 220px;     /* Market Status panel height          */
  --qrl-sidebar-w: 348px;    /* right sidebar width                 */
}

/* ── Splitter (resizable handles — same pattern as the AI terminal #qrl-ai-splitter) ── */
.ufo-splitter {
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
  touch-action: none;
  background: transparent;
  transition: background 0.15s ease;
}
.ufo-splitter-h {
  height: 7px;
  width: 100%;
  cursor: row-resize;
}
.ufo-splitter-v {
  width: 7px;
  height: 100%;
  cursor: col-resize;
}
.ufo-splitter::before {
  content: "";
  position: absolute;
  background: var(--border, #30363d);
  transition: background 0.15s ease;
}
.ufo-splitter-h::before { left: 0; right: 0; top: 50%; height: 1px; margin-top: -0.5px; }
.ufo-splitter-v::before { top: 0; bottom: 0; left: 50%; width: 1px; margin-left: -0.5px; }
.ufo-splitter:hover::before,
.ufo-splitter.dragging::before {
  background: var(--ufo-accent, #39c5cf);
}
.ufo-split-grip {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--border, #30363d);
  background: var(--bg2, #161b22);
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.ufo-splitter-h .ufo-split-grip { width: 34px; height: 7px; }
.ufo-splitter-v .ufo-split-grip { width: 7px; height: 34px; }
.ufo-splitter:hover .ufo-split-grip,
.ufo-splitter.dragging .ufo-split-grip { opacity: 1; }
html.ufo-dragging * { cursor: col-resize !important; user-select: none !important; -webkit-user-select: none !important; }
html.ufo-dragging-h * { cursor: row-resize !important; user-select: none !important; -webkit-user-select: none !important; }

/* ── Signal UFO Carousel Bar ───────────────────────────────────── */
.ufo-carousel-bar {
  flex: 0 0 var(--qrl-carousel-h, 160px);
  display: flex;
  align-items: stretch;
  gap: 0;
  background: rgba(10, 15, 22, 0.22);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); /* translucent — QRIL bg shows through */
  border-bottom: 1px solid var(--border, #30363d);
  padding: 8px 10px;
  min-height: 100px;
  max-height: 460px;
  box-sizing: border-box;
  overflow: hidden;
}

.ufo-carousel-nav {
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text2, #8b949e);
  cursor: pointer;
  font-size: 20px;
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}
.ufo-carousel-nav:hover {
  color: var(--ufo-accent);
}
.ufo-carousel-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.ufo-carousel-track {
  flex: 1 1 auto;                 /* full bar width — active UFO is centered, "middle" = bar center */
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 6px 8px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  scrollbar-width: none;   /* no visible left/right scrollbar — drag the UFOs to scroll */
  scrollbar-color: transparent transparent;
}
.ufo-carousel-track.dragging,
.ufo-carousel-track.dragging .signal-ufo { cursor: grabbing; }

/* collapsed empty spacer (kept for DOM/JS compat; carries zero width) */
.ufo-carousel-free {
  flex: 0 0 0;
  min-width: 0;
}
/* trailing spacer (JS-sized) so the active UFO can center with room to its right */
.ufo-carousel-tail-spacer {
  flex: 0 0 auto;
  min-width: 0;
  pointer-events: none;
}
.ufo-carousel-track::-webkit-scrollbar {
  display: none;   /* hide the Chrome/Safari scrollbar — drag the UFOs to scroll */
}
.ufo-carousel-track::-webkit-scrollbar-thumb {
  display: none;
}

.ufo-carousel-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2, #8b949e);
  font-size: 12px;
  letter-spacing: 1px;
}

/* ── Signal UFO Card (1:1 original asset) ──────────────────────── */
.signal-ufo {
  flex: 0 0 auto;
  position: relative;
  /* Height-driven: the card scales with the resizable carousel panel.
   * bar padding (8+8) + track padding (4+8) = 28px of vertical chrome. */
  height: calc(var(--qrl-carousel-h, 160px) - 28px);
  min-height: 60px;
  aspect-ratio: 1448 / 1086;
  cursor: grab;
  user-select: none;
  isolation: isolate;
  container-type: inline-size;   /* cqw units scale the text overlay with the card */
  transition: transform 0.18s, filter 0.18s;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.signal-ufo:hover {
  transform: translateY(-2px);
}
.signal-ufo.active {
  z-index: 5;
  filter: drop-shadow(0 0 14px var(--ufo-accent-glow));
}

/* New incoming signal UFO flies in from the far-right "unfilled" side — just
 * past the Active Signal UFO monitor — into the center of the strip. The strip
 * itself is already scrolled to its final centered layout (instant jump, no
 * glide), so this is one clean horizontal flight with no double-animation. The
 * travel distance is set from JS via --ufo-fly-from (≈ one full track width,
 * so the UFO starts fully out of view). Class is dropped on animationend. */
.signal-ufo.ufo-incoming {
  animation: ufo-fly-in 2000ms cubic-bezier(0.16, 0.9, 0.3, 1) both;
}
@keyframes ufo-fly-in {
  from { opacity: 0; transform: translateX(var(--ufo-fly-from, 40vw)); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Header-integrated overrides (carousel sits inside the 220px header) ── */
.header-center .signal-ufo {
  /* Gentler growth (110px at default 220 → 260px at max 520) so the UFO cards
   * stay clearly smaller than the Active Signal UFO monitor at every header
   * height. The monitor column (.header-right) widens with the header too. */
  height: calc(var(--qril-header-main-h, 220px) * 0.5);
  min-height: 80px;
}
.header-center .signal-ufo .ufo-meta-setup { font-size: 7px; }
.header-center .signal-ufo .ufo-meta-dir { font-size: 7px; }
.header-center .signal-ufo .ufo-card-meta { padding: 1px 3px; }
.header-center .ufo-carousel-track {
  padding: 2px 0 6px;
  gap: 8px;
}
.header-center .ufo-carousel-empty {
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* The original UFO frame PNG — the design, never redrawn. */
.signal-ufo-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

/* ── Slot geometry (percent of the 1448×1086 asset, measured from the PNG) ──
 * Single full-screen slot — the new Signal UFO device has ONE large screen,
 * no timeframe sub-slots. The screenshot fills the dark screen interior,
 * inset so the metallic frame + viewfinder corner brackets stay visible. */
.signal-ufo .ufo-main-slot {
  position: absolute;
  left: 9.1%;
  top: 13.4%;
  width: 81.7%;
  height: 41.8%;
  overflow: hidden;
  border-radius: 2px;
  background: var(--bg, #0d1117);
  z-index: 2;
}

/* Screenshot fills the single screen slot without distortion */
.signal-ufo .ufo-main-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Quiet placeholder / loading state (only when the image is missing) */
.signal-ufo .ufo-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(139, 148, 158, 0.45);
  font-size: 7px;
  letter-spacing: 0.5px;
  text-align: center;
  box-sizing: border-box;
  background: repeating-linear-gradient(
    -45deg,
    rgba(57, 197, 207, 0.035) 0 6px,
    transparent 6px 12px
  );
}

/* Dynamic meta strip (setup + direction) over the screen's top edge.
 * Static frame text ("SIGNAL UFO", "QRIL") is NOT re-rendered. */
.signal-ufo .ufo-card-meta {
  position: absolute;
  left: 9.1%;
  top: 13.4%;
  width: 81.7%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 4px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(4, 10, 16, 0.88), rgba(4, 10, 16, 0.0));
  pointer-events: none;
}
.signal-ufo .ufo-meta-setup {
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text, #e6edf3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.signal-ufo .ufo-meta-dir {
  flex: 0 0 auto;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.signal-ufo .ufo-meta-dir.long { color: var(--green, #3fb950); }
.signal-ufo .ufo-meta-dir.short { color: var(--red, #f85149); }
.signal-ufo .ufo-meta-dir.neutral { color: var(--text2, #8b949e); }

/* ── Display toggle (⋮) + text overlay (Text ↔ Chart screenshot) ── */
.signal-ufo .ufo-toggle {
  position: absolute;
  top: 3px;
  right: 4px;
  z-index: 6;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 16, 0.72);
  border: 1px solid rgba(57, 197, 207, 0.35);
  border-radius: 4px;
  color: var(--text2, #8b949e);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.signal-ufo .ufo-toggle:hover {
  color: var(--ufo-accent, #39c5cf);
  border-color: var(--ufo-accent, #39c5cf);
}

.signal-ufo .ufo-text-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 1cqw;
  padding: 1.5cqw 2cqw;
  box-sizing: border-box;
  /* CRT-TV-Static / analoges Fernsehrauschen hinter dem Signaltext (Unbenannt 125).
   * Layer-Reihenfolge (unten→oben):
   *  1) dunkler Deckel (Lesbarkeit)        — reduziert .86 → .78 damit das
   *                                          kräftigere Rauschen durchschimmert
   *  2) CRT-Static-Multilayer-Pattern       — zwei repeating-radial-gradients
   *                                          + zwei repeating-linear-gradients
   *                                          erzeugen ein feines schwarz-grau-
   *                                          weißes Punktraster, das sich per
   *                                          @keyframes ufo-crt-static in 8
   *                                          Mikro-Schritten verschiebt.
   *  3) ::before-Pseudo (siehe unten)        — feiner, animierter Noise-Overlay
   *                                          mit mix-blend-mode: screen für
   *                                          den klassischen CRT-Glow.
   * Gilt GLOBAL für jede Signal-UFO-Card, weil buildTextOverlay(vm) in
   * signal-ufo.js für jede Card aufgerufen wird.
   * Kräftiger: Alphas ~+100–120% gegenüber v1, ::before-Overlay .55 → .80. */
  background:
    /* Layer 2a — feine helle Pixelpunkte (scanline-ähnlich, horizontal) */
    repeating-linear-gradient(0deg,
      rgba(220, 232, 244, 0.10) 0 1px,
      transparent 1px 3px),
    /* Layer 2b — gröbere dunkle Pixelpunkte (CRT-Pixel-Rauschen) */
    repeating-radial-gradient(circle at 17% 23%,
      rgba(255, 255, 255, 0.14) 0 1px,
      transparent 1px 4px),
    repeating-radial-gradient(circle at 71% 64%,
      rgba(0, 0, 0, 0.32) 0 1px,
      transparent 1px 5px),
    repeating-radial-gradient(circle at 38% 81%,
      rgba(255, 255, 255, 0.10) 0 1px,
      transparent 1px 6px),
    /* Layer 1 — dunkler Deckel (Lesbarkeit) */
    linear-gradient(180deg, rgba(4, 10, 16, 0.78), rgba(4, 10, 16, 0.78));
  background-size:
    3px 3px,
    5px 5px,
    7px 7px,
    9px 9px,
    100% 100%;
  background-position:
    0 0,
    0 0,
    2px 1px,
    1px 3px,
    0 0;
  overflow: hidden;
  isolation: isolate;
  animation: ufo-crt-static 1.6s steps(8, end) infinite;
}

/* Zusätzliche CRT-Static-Schicht via ::before — feiner bewegter Noise,
 * liegt zwischen Hintergrund-Pattern und Text-Inhalt. */
.signal-ufo .ufo-text-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Subtile grain-Schicht: viele kleine helle Punkte + dunkle Punkte */
  background:
    repeating-radial-gradient(circle at 12% 18%,
      rgba(255, 255, 255, 0.12) 0 0.6px,
      transparent 0.6px 3px),
    repeating-radial-gradient(circle at 88% 47%,
      rgba(255, 255, 255, 0.10) 0 0.6px,
      transparent 0.6px 3px),
    repeating-radial-gradient(circle at 55% 82%,
      rgba(255, 255, 255, 0.08) 0 0.6px,
      transparent 0.6px 4px);
  background-size: 3px 3px, 4px 4px, 5px 5px;
  mix-blend-mode: screen;
  opacity: 0.80;
  animation: ufo-crt-static-grain 1.1s steps(6, end) infinite;
}

/* Sicherstellen, dass der Text-Inhalt ÜBER dem ::before-Noise sitzt */
.signal-ufo .ufo-text-overlay > * {
  position: relative;
  z-index: 1;
}

/* CRT-Static-Animation — zwei leicht unterschiedliche Tempi,
 * damit das Rauschen organisch und nicht synchron wirkt. */
@keyframes ufo-crt-static {
  0%   { background-position: 0 0,    0 0,   2px 1px, 1px 3px, 0 0; }
  12%  { background-position: 0 -3px, 1px 0, 0   2px, 3px 1px, 0 0; }
  25%  { background-position: 0 -2px, 0 2px, 3px 0,   0   4px, 0 0; }
  37%  { background-position: 0 -4px, 2px 1px, 1px 3px, 2px 0, 0 0; }
  50%  { background-position: 0 -1px, 0 3px, 2px 2px, 4px 2px, 0 0; }
  62%  { background-position: 0 -5px, 1px 1px, 0   1px, 1px 1px, 0 0; }
  75%  { background-position: 0 -2px, 3px 2px, 1px 4px, 0   3px, 0 0; }
  87%  { background-position: 0 -3px, 2px 0,   3px 1px, 3px 4px, 0 0; }
  100% { background-position: 0 0,    0 0,   2px 1px, 1px 3px, 0 0; }
}
@keyframes ufo-crt-static-grain {
  0%   { background-position: 0 0,    0 0,    0 0;    opacity: 0.80; }
  16%  { background-position: 1px 0,  0 1px,  2px 0;  opacity: 0.74; }
  33%  { background-position: 0 1px,  2px 0,  0 1px;  opacity: 0.84; }
  50%  { background-position: 2px 0,  1px 2px, 1px 1px; opacity: 0.78; }
  66%  { background-position: 0 2px,  0 0,    3px 0;  opacity: 0.86; }
  83%  { background-position: 1px 1px, 2px 1px, 0 2px;  opacity: 0.76; }
  100% { background-position: 0 0,    0 0,    0 0;    opacity: 0.80; }
}
.signal-ufo.ufo-mode-text .ufo-text-overlay { display: flex; }
.signal-ufo.ufo-mode-text .ufo-main-slot img { display: none; }
.signal-ufo.ufo-mode-text .ufo-main-slot .ufo-ph { display: none; }
.signal-ufo.ufo-mode-text .ufo-card-meta { display: none; }

/* 1 ─ asset · timeframe · setup: one row, full width */
.signal-ufo .uft-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 1.4cqw;
  width: 100%;
  line-height: 1.05;
}
.signal-ufo .uft-sym,
.signal-ufo .uft-tf,
.signal-ufo .uft-setup {
  font-size: 6.5cqw;
  font-weight: 800;
  letter-spacing: 0.15cqw;
  text-transform: uppercase;
  color: var(--text, #e6edf3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signal-ufo .uft-sym { text-align: left; }
.signal-ufo .uft-tf { text-align: center; color: var(--text2, #8b949e); }
.signal-ufo .uft-setup { text-align: left; min-width: 0; }

/* 2 ─ direction: dominant, centered */
.signal-ufo .uft-dirline {
  font-size: 11cqw;
  font-weight: 900;
  letter-spacing: 0.3cqw;
  line-height: 0.95;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.signal-ufo .uft-dirline.long { color: var(--green, #3fb950); }
.signal-ufo .uft-dirline.short { color: var(--red, #f85149); }
.signal-ufo .uft-dirline.neutral { color: var(--text2, #8b949e); }

/* 3 ─ price · time — one line, no labels, separated (price left / time right) */
.signal-ufo .uft-entry {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1cqw;
  flex-wrap: nowrap;
  white-space: nowrap;
  width: 100%;
}
.signal-ufo .uft-entry .v {
  font-size: 6.5cqw;
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  color: var(--text, #e6edf3);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signal-ufo .uft-entry .v.time { color: var(--text2, #8b949e); }

/* ── Active Signal UFO Monitor (1:1 original asset) ────────────── */
/* The UFO monitor shares the header-right row with the Quant Signal Radar.
 * The ROW HEIGHT is fixed (= header band / resizable panel); both
 * children take their width from their own aspect-ratio so they grow/shrink
 * in lockstep. The monitor's PNG is 1448×1086 (≈4:3); inner image uses
 * object-fit:cover so the asset stays pixel-exact inside its 4:3 box. */
.ufo-monitor {
  flex: 0 1 auto;
  height: 100%;
  min-width: 0;
  align-self: stretch;
  aspect-ratio: 1448 / 1086;  /* active-signal-ufo-monitor.png is 1448×1086 */
  padding: 4px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ufo-monitor-empty {
  color: var(--text2, #8b949e);
  font-size: 11px;
  text-align: center;
  padding: 18px 0;
  letter-spacing: 1px;
}

/* The stage is sized by JS (fitMonitorStage) to the largest 1402:1122 box
 * that fits the monitor — real container sizing, never transform:scale(). */
.ufo-monitor-stage {
  position: relative;
  aspect-ratio: 1448 / 1086;   /* CSS fallback before/without JS */
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  isolation: isolate;
}
.ufo-monitor-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}

/* CRT screen area — content is masked inside the curved monitor glass.
 * The real glass sits at ~11.5%–88.5% × 17.5%–78.5% of the monitor PNG. */
.ufo-monitor-screen {
  position: absolute;
  left: 11.5%;
  top: 17.5%;
  width: 77%;
  height: 61%;
  overflow: hidden;
  border-radius: 3.5% / 3%;
  z-index: 2;
  box-sizing: border-box;
  isolation: isolate;
}

/* Main screenshot fills the CRT glass. */
.ufo-monitor-shot {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg, #0d1117);
}
.ufo-monitor-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ufo-monitor-shot .ufo-ph { font-size: 10px; }

/* Dynamic metadata overlay (readable over the chart screenshot). */
.ufo-monitor-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 9px;
  box-sizing: border-box;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 10, 16, 0.82) 0%, rgba(4, 10, 16, 0.0) 26%, rgba(4, 10, 16, 0.0) 62%, rgba(4, 10, 16, 0.82) 100%);
}
.ufo-monitor-ref {
  font-size: 9px;
  color: var(--text2, #8b949e);
  letter-spacing: 0.5px;
}
.ufo-monitor-bottom {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ufo-monitor-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ufo-monitor-meta .mm {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text, #e6edf3);
}
.ufo-monitor-meta .mm.accent { color: var(--ufo-accent); }
.ufo-monitor-meta .mm.active, .ufo-monitor-meta .mm.winner { color: var(--green, #3fb950); }
.ufo-monitor-meta .mm.pending { color: var(--yellow, #d29922); }
.ufo-monitor-meta .mm.failed, .ufo-monitor-meta .mm.expired { color: var(--red, #f85149); }
.ufo-monitor-confluence {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.ufo-monitor-confluence .cc {
  font-size: 8px;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border: 1px solid rgba(57, 197, 207, 0.45);
  border-radius: 9px;
  color: var(--ufo-accent);
  background: rgba(4, 10, 16, 0.55);
}

/* NOTE: scanlines + glass glare are already baked into the monitor PNG,
 * so no CRT effect is layered here (avoids double-rendering). */

.ufo-monitor-setup {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ufo-accent);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ufo-monitor-dir {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  flex: 0 0 auto;
}
.ufo-monitor-dir.long { color: var(--green, #3fb950); }
.ufo-monitor-dir.short { color: var(--red, #f85149); }
.ufo-monitor-dir.neutral { color: var(--text2, #8b949e); }

.ufo-monitor-kv {
  margin-top: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 10px;
  font-size: 10px;
}
.ufo-monitor-kv .ufo-kv {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(57, 197, 207, 0.16);
  padding: 1px 0;
}
.ufo-kv .k { color: var(--text2, #8b949e); text-transform: uppercase; font-size: 8px; letter-spacing: 0.5px; }
.ufo-kv .v { color: var(--text, #e6edf3); font-family: var(--font-mono, monospace); font-size: 9px; }
.ufo-kv .v.long { color: var(--green, #3fb950); }
.ufo-kv .v.short { color: var(--red, #f85149); }
.ufo-kv .v.accent { color: var(--ufo-accent); }

.ufo-monitor-conf {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 3px;
}
.ufo-monitor-conf .star { color: var(--ufo-accent); font-size: 10px; }
.ufo-monitor-conf .star.off { color: var(--text2, #8b949e); opacity: 0.4; }

.ufo-monitor-preview {
  margin-top: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(57, 197, 207, 0.22);
  border-radius: 2px;
  background: var(--bg, #0d1117);
}
.ufo-monitor-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ufo-monitor-preview .ufo-ph { font-size: 9px; }

/* 4 ─ signal id on the lower "QRIL" plate (outside the CRT glass).
 * Measured plate recess: x 420–980 / y 910–1010 of the 1448×1086 asset. */
.ufo-monitor-idplate {
  position: absolute;
  left: 29.0%;
  top: 83.8%;
  width: 38.7%;
  height: 9.2%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--monitor-scale, 1) * 2px);
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(4, 10, 16, 0.92);
  border-radius: calc(var(--monitor-scale, 1) * 6px);
}
.ufo-monitor-idplate .umo-id-lbl {
  font-size: calc(var(--monitor-scale, 1) * 24px);
  font-weight: 700;
  letter-spacing: calc(var(--monitor-scale, 1) * 3px);
  color: var(--ufo-accent, #39c5cf);
  text-transform: uppercase;
  line-height: 1;
}
.ufo-monitor-idplate .umo-id {
  font-size: calc(var(--monitor-scale, 1) * 40px);
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  letter-spacing: calc(var(--monitor-scale, 1) * 1px);
  color: var(--text, #e6edf3);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Right panel tabs (Queue | Watchlist | Trading) ────────────── */
.right-panel-tabs.rp-tabs-3 { display: flex; width: 100%; }
.right-panel-tabs.rp-tabs-3 .rp-tab {
  flex: 1;
  padding: 4px 2px;
  font-size: 9px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  word-break: break-word;
}

/* ── UFO Command Queue ─────────────────────────────────────────── */
.ufo-queue {
  padding: 0;
}
.ufo-queue-head {
  display: flex;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border, #30363d);
  font-size: 10px;
  color: var(--text2, #8b949e);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ufo-queue-head span:nth-child(1) { width: 20px; }
.ufo-queue-head span:nth-child(2) { flex: 1; }
.ufo-queue-head span:nth-child(3) { width: 48px; text-align: right; }
.ufo-queue-head span:nth-child(4) { width: 62px; text-align: right; }
.ufo-queue-head span:nth-child(5) { width: 46px; }
.ufo-queue-row {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.4);
  font-size: 11px;
  cursor: pointer;
}
.ufo-queue-row:hover { background: rgba(201, 205, 211, 0.06); }
.ufo-queue-row .uq-idx { width: 20px; color: var(--text2, #8b949e); }
.ufo-queue-row .uq-setup { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text, #e6edf3); }
.ufo-queue-row .uq-tf { width: 48px; text-align: right; color: var(--text2, #8b949e); }
.ufo-queue-row .uq-status { width: 62px; text-align: right; font-weight: 700; letter-spacing: 0.5px; }
.uq-status.active { color: var(--green, #3fb950); }
.uq-status.pending { color: var(--yellow, #d29922); }
.uq-status.expired { color: var(--red, #f85149); }
.uq-status.winner { color: var(--green, #3fb950); }
.uq-status.failed { color: var(--red, #f85149); }
.ufo-queue-row.selected { background: rgba(57, 197, 207, 0.18); box-shadow: inset 2px 0 0 var(--ufo-accent, #39c5cf); }
.ufo-queue-row .uq-actions { flex: 0 0 auto; display: flex; gap: 3px; margin-left: 2px; }
.ufo-queue-row .uq-action { background: rgba(57, 197, 207, 0.10); border: 1px solid rgba(57, 197, 207, 0.35); color: var(--ufo-accent, #39c5cf); border-radius: 3px; padding: 1px 4px; font-size: 11px; line-height: 1; cursor: pointer; }
.ufo-queue-row .uq-action:hover { background: rgba(57, 197, 207, 0.25); border-color: rgba(57, 197, 207, 0.7); }
.ufo-queue-empty {
  padding: 14px;
  color: var(--text2, #8b949e);
  font-size: 11px;
  text-align: center;
}

/* ── Market Status (world map) ─────────────────────────────────── */
.market-status {
  flex: 0 0 var(--qrl-market-h, 190px);
  min-height: 120px;
  max-height: 560px;
  border-top: 1px solid var(--border, #30363d);
  background: var(--bg2, #161b22);
  padding: 8px 12px 10px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
}
.market-status-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text2, #8b949e);
  margin-bottom: 6px;
}
.market-map {
  position: relative;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  overflow: hidden;
  background: #0a1a2a;   /* dark navy — world map sits on it, not #111 */
  height: 110px;
}
.market-map svg { display: block; width: 100%; height: 100%; }

.market-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.market-cell {
  border: 1px solid var(--border, #30363d);
  border-radius: 5px;
  padding: 6px 8px;
  background: var(--bg, #0d1117);
}
.market-cell .mc-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text2, #8b949e);
}
.market-cell .mc-time {
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--text, #e6edf3);
  margin-top: 2px;
}
.market-cell .mc-open {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-top: 2px;
}
.market-cell .mc-open.open { color: var(--green, #3fb950); }
.market-cell .mc-open.closed { color: var(--red, #f85149); }
.market-cell .mc-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.market-cell .mc-dot.open { background: var(--green, #3fb950); }
.market-cell .mc-dot.closed { background: var(--red, #f85149); }

/* (UFOs are height-driven now — no fixed-width responsive override needed.) */

/* Collapsed right panel: hide the non-essential permanent sections too */
.right-panel.collapsed .ufo-monitor,
.right-panel.collapsed .market-status { display: none; }

/* ════════════════════════════════════════════════════════════════
 * Global Signal UFO Header — 2-zone header layout shared by EVERY page
 * (injected globally by signal_ufo_header_middleware.py; the DOM structure
 * is built by signal-ufo-header.js). Mirrors the Chart Terminal's inline
 * header rules so all pages look identical.
 * ════════════════════════════════════════════════════════════════ */
.logo-bar { flex-shrink: 0; }
.header-left { flex: 1 1 auto; align-self: stretch; min-width: 0; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 8px; }
.header-title { flex: 0 0 auto; min-width: 0; display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.header-title .logo { font-size: 18px; letter-spacing: 3px; font-weight: 800; white-space: nowrap; flex: 0 0 auto; }
.header-title .logo-sub { color: var(--text2, #8b949e); font-weight: 400; font-size: 18px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.header-title-row { flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 16px; position: relative; }
.header-center { flex: 1 1 auto; width: 100%; min-width: 0; display: flex; align-items: center; overflow: hidden; position: relative; }
.header-ufo-wrap { display: flex; align-items: center; width: 100%; height: 100%; overflow: hidden; }
/* The UFO monitor shares the header-right row with the Quant Signal Radar.
 * Die Breite der GESAMTEN rechten Kopfspalte ist resizable
 * (#ufo-split-right, Ziehen an der linken Kante): --qril-header-right-w.
 * Weil beide Geraete hoehengetrieben sind (aspect-ratio), koppelt
 * signal-ufo.js beim Ziehen die Kopfbandhoehe mit — sonst wuerde eine
 * breitere Spalte nur Leerraum erzeugen statt groessere Boxen. */
.header-right { flex: 0 0 var(--qril-header-right-w, 636px); align-self: stretch; min-width: 0; display: flex; flex-direction: row; align-items: stretch; gap: 8px; padding: 6px 0; }

/* Kopfband-Medien ein/aus — EIN Knopf oben rechts in der Ecke des .logo-bar.
 * Blenden .header-center (Signal-UFO-Carousel) und .header-right (Quant Signal
 * Radar) zusammen aus und fahren das Band dabei ein (Höhe setzt signal-ufo.js
 * über --qril-header-main-h = 96px). Position: rechts neben dem Radar-Zahnrad,
 * das am oberen Rand der rechten Kopfspalte sitzt (~35px vor der Bandkante). */
.qrl-hdr-media {
  position: absolute; top: 14px; right: 28px; z-index: 9;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 24px; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border, #30363d);
  background: rgba(23, 27, 32, 0.92); color: var(--text2, #8b949e);
  transition: color .15s, border-color .15s, background .15s;
}
.qrl-hdr-media:hover { color: #dbe6f2; border-color: rgba(57, 197, 207, 0.55); background: #1b2027; }
.qrl-hdr-media[aria-pressed="true"] { color: rgba(57, 197, 207, 0.8); border-color: rgba(57, 197, 207, 0.35); }
.qrl-hdr-media .qhm-media-off { display: none; }
.qril-media-off .header-center,
.qril-media-off .header-right,
.qril-media-off #ufo-split-right,
.qril-media-off #ufo-split-header { display: none !important; }
/* Sidebar-Kopfzeile fährt mit, sonst steht ihr Mond-Block 124px unter der Bandkante. */
.qril-media-off .nav-sidebar-header { height: var(--qril-header-main-h) !important; min-height: var(--qril-header-main-h) !important; }
.header-right > .ufo-splitter-v, .logo-bar > .ufo-splitter-v { align-self: stretch; margin: 4px 0; }
.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
/* Kopfzeilen-Buttons am ZENTRIERTEN Suchfeld ausrichten (Auftrag 2026-11-01):
 * signal-ufo.js setzt `left` aus dem echten Rechteck des Suchfelds und diese
 * Klasse. Ohne Suchfeld bleibt die alte Flusslage (direkt hinter dem Titel). */
.header-title-row .header-actions.qrl-actions-at-search {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 26;
  /* Absolut gesetzte Boxen rechnen mit "shrink-to-fit" gegen den Platz rechts vom
   * `left` — das quetscht die Pills (gemessen: ACTIVITY CENTER 105 → 69 px).
   * max-content hält die Zeile auf Inhaltsbreite. */
  width: max-content;
  max-width: none;
}

/* ── EINGEKLAPPTES Band: Suche rechts, die vier Buttons rechtsbündig LINKS davon ──
 * Auftrag 2026-11-01. Diese Regeln sind die CSS-Fallbacks zu alignHeaderActions()
 * (signal-ufo.js): identische Geometrie, aber sie greifen auch dann, wenn das
 * Skript auf der Seite nicht läuft oder vorher aussteigt. Anker ist die RECHTE
 * Kante der Titelzeile (im eingeklappten Band = volle Bandbreite):
 *   Suche   57 px vor der Bandkante  (Platz für #qrl-header-media-toggle)
 *   Buttons 16 px links davon        (rechtsbündig an der Suche)
 *   Titel   bekommt den Rest, Unterzeile mit Ellipsis
 * `right` statt `left` hält die rechte Kante fest, auch wenn ein Badge den Button
 * verbreitert. Nur auf Seiten MIT Suchfeld (:has), sonst würden die Buttons ohne
 * Gegenstück nach rechts geschoben. */
.qril-media-off .header-title-row:has(.header-search-float) .search-btn.header-search-float {
  left: auto;
  right: 57px;
}
.qril-media-off .header-title-row:has(.header-search-float) .header-actions {
  position: absolute;
  top: 50%;
  left: auto;
  right: 413px;
  transform: translateY(-50%);
  width: max-content;
  max-width: none;
  z-index: 26;
}
.qril-media-off .header-title-row:has(.header-search-float) .header-title {
  max-width: calc(100% - 976px);
}
/* Enge Zeile: alignHeaderActions() setzt qrl-actions-tight, wenn Titel + Pills +
 * Suche nicht mehr nebeneinander passen (gemessen 2026-11-01, eingeklappt:
 * ab ~1400 px). Dann tragen die Pills nur noch ihr Symbol mit aria-label/title —
 * die Beschriftungen kosten zusammen ~330 px und schoben die Zeile sonst in die
 * Sidebar. Klickflaeche und Ziele bleiben unveraendert. */
.header-actions.qrl-actions-tight .qrl-ls-ind-label,
.header-actions.qrl-actions-tight .qrl-ha-label,
.header-actions.qrl-actions-tight .qrl-nb-label { display: none; }
.header-actions.qrl-actions-tight .qrl-ls-indicator,
.header-actions.qrl-actions-tight .qrl-ha-btn,
.header-actions.qrl-actions-tight .qrl-nb-btn { padding: 0 8px; }
.header-actions .search-btn { display: flex; align-items: center; gap: 6px; background: var(--bg, #0d1117); border: 1px solid var(--border, #30363d); color: var(--text2, #8b949e); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.search-btn-kbd { border: 1px solid var(--border, #30363d); border-radius: 3px; padding: 0 4px; font-size: 10px; }
.header-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.header-dot.ok { background: var(--green, #3fb950); }
.header-dot.warn { background: var(--orange, #d29922); }
.header-dot.err { background: var(--red, #f85149); }
.header-status { font-size: 12px; color: var(--text2, #8b949e); white-space: nowrap; }
.header-freshness { font-size: 11px; color: var(--text2, #8b949e); white-space: nowrap; opacity: 0.85; }
.header-clock { font-size: 12px; color: var(--text2, #8b949e); white-space: nowrap; opacity: 0.9; font-variant-numeric: tabular-nums; }

/* ── Uhr/Datum: NUR im eingeklappten Band, dann UNTER dem Titel (2026-11-01) ──
 * Ausgeklappt (Signal-UFO-Carousel + Radar sichtbar) gibt es keine Uhr — die
 * Zeile gehört dann den Buttons. Eingeklappt (Medien aus, `html.qril-media-off`,
 * Band 96 px) wandert die Uhr in den Slot direkt unter der Titelzeile.
 * EIN Element (#hdr-clock), kein zweiter Ticker: signal-ufo.js verschiebt den
 * vorhandenen Knoten, header-clock.js tickt weiter über die id. */
.header-clock { display: none; }
/* Die "zweite Zeile" der Identitaetszone traegt Uhr (nur eingeklappt) UND die
 * seiten-eigenen Status-Anzeigen (z.B. „Worker · offline", Connector-Chips):
 *   ausgeklappt → Chips links unter dem Titel, ueber dem Signal-UFO-Carousel
 *   eingeklappt → Uhr links, Chips rechtsbuendig daneben
 * Leer ist der Slot 0 px hoch (alle Kinder display:none) und stoert nicht. */
.header-clock-sub {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 0 2px;
  line-height: 1.2;
  min-height: 0;
}
.header-page-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.qril-media-off .header-clock-sub {
  /* 59 px = 57 px Suche-Abstand + 2 px: die Chips enden buendig mit der Suche. */
  justify-content: space-between;
  padding: 2px 59px 0 2px;
}
.qril-media-off .header-clock { display: inline-block; }
.qril-media-off .header-clock-sub .header-clock { font-size: 12px; opacity: 0.85; }
.qril-media-off .header-page-status { justify-content: flex-end; margin-left: auto; }

/* Header-floating search trigger ("Search Ctrl+K") — identical to Chart Terminal */
.header-title-row .search-btn.header-search-float {
  position: absolute;
  top: 50%;
  right: calc(50% - 73px);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: 340px;
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  color: var(--text2, #8b949e);
  cursor: pointer;
  z-index: 25;
}
.header-title-row .search-btn.header-search-float:hover {
  border-color: var(--accent, #C9CDD3);
  color: var(--text, #e6edf3);
}
.header-title-row .search-btn.header-search-float .search-btn-kbd { margin-left: auto; }

