/* ════════════════════════════════════════════════════════════════
 * QRL QRIL Signal Radar — kompakter HEADER-Radar (v6 "Terminal-Matrix").
 *
 * Aufbau (Auftrag 2026-10-03):
 *   Layer A: die Geraete-HUELLE. shell-wide.png = breite Huelle (3:1) mit
 *            Rahmen, Titelplatte und QRIL-Plakette. Das Rahmen-Artwork ist
 *            geliefert und wird nicht nachgezeichnet.
 *   Layer B: .qr-overlay darueber mit
 *              1. .qr-vtoggle     Ansichts-Toggle QRIL SIGNAL RADAR | ... UFO
 *              2. .qr-mx-scroll   SIGNAL-MATRIX
 *                 Strategie-Zeilen (links, sticky) x Instrument-Baender oben,
 *                 darin ALLE 43 Timeframes je Instrument (links -> rechts).
 *
 * Beides scrollt: die Matrix in BEIDE Richtungen (eigener Scroll-Container mit
 * sticky Kopfzeilen + sticky Strategie-Spalte).
 *
 * Die Matrix-Geometrie setzt quant-radar-header.js als CSS-Variablen auf .qr-mx
 * (--qr-cw/-rh/-lw/-hi/-h1/-h2/-dot). Die Werte hier sind nur der Rueckfall
 * fuer den Fall, dass das Skript noch nicht gelaufen ist.
 * ════════════════════════════════════════════════════════════════ */

.qr-shell {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 3 / 1;             /* shell-wide: 3072x1024 (breite Huelle) */
  background: url("/static/assets/quant-radar/shell-wide.webp") center / 100% 100% no-repeat;
  border-radius: 6px;
  overflow: hidden;
  isolation: isolate;
  container-type: size;
}

/* Display-Inneres der Huelle (am PNG gemessen): Titelband endet bei ~13%,
   Display x 3%..97%, y 15%..88%; QRIL-Plakette beginnt bei 89%. */
.qr-overlay {
  position: absolute;
  left: 3.19%;     /* gemessen an shell-wide.png: Display x 98..2974 von 3072 */
  right: 3.19%;
  top: 17%;
  bottom: 13.6%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
  color: var(--qradar-ink, #c9d1d9);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  pointer-events: auto;
}

/* ── Kompakter Ansichts-Toggle (oberste Zeile des Panels) ────────── */
.qr-vtoggle {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 16px;
  min-width: 0;
}
.qr-vt-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  padding: 0 7px;
  margin: 0;
  border: 1px solid #222b34;
  border-radius: 2px;
  background: linear-gradient(180deg, #12181f, #0b0f14);
  color: #6b7681;
  font: 700 8px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 1.1px;
  white-space: nowrap;
  cursor: pointer;
}
.qr-vt-btn:hover { color: #b8c2cc; border-color: #38424e; }
.qr-vt-btn.is-active {
  color: #d7e2ec;
  border-color: #4a5a68;
  background: linear-gradient(180deg, #1d2731, #131a21);
  box-shadow: inset 0 0 0 1px rgba(120, 190, 220, 0.10), 0 0 6px rgba(90, 190, 220, 0.10);
}
.qr-vt-btn.is-active::before {
  content: "";
  width: 4px; height: 4px; border-radius: 50%;
  margin-right: 5px;
  background: #35d0d8;
  box-shadow: 0 0 5px rgba(53, 208, 216, 0.75);
}

/* ── Ein Geraet, zwei Ansichten ────────────────────────────────────
   .qr-view-radar = Signal-Matrix (Vorgabe)
   .qr-view-ufo   = halbe Flaeche Chart | halbe Flaeche Signal-Details */
.qr-view {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}
.qr-view-radar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.qr-view-ufo {
  display: none;
  grid-template-columns: 1fr 1fr;   /* je halbe Flaeche */
  gap: 4px;
}
.qr-shell.is-ufo .qr-view-radar { display: none; }
.qr-shell.is-ufo .qr-view-ufo { display: grid; }

.qr-ufo-chart,
.qr-ufo-details {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #1b222b;
  background: var(--qradar-recess, #0c1015);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-ufo-details {
  display: block;
  padding: 5px 7px;
  overflow: auto;
  font-size: 10px;
  line-height: 1.5;
}
.qr-ufo-chart img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.qr-view-ph {
  color: #66707d;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-align: center;
  padding: 0 6px;
}

/* Signal-Details in der UFO-Ansicht */
.qsu-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.qsu-setup { color: var(--qradar-ink, #c9d1d9); font-weight: 700; letter-spacing: 0.6px; }
.qsu-dir { font-weight: 800; letter-spacing: 1px; padding: 0 4px; border-radius: 2px; }
.qsu-dir.long { color: var(--qradar-long-glow, #39d353); background: rgba(63, 185, 80, 0.14); }
.qsu-dir.short { color: var(--qradar-short-glow, #ff6a5f); background: rgba(248, 81, 73, 0.14); }
.qsu-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; color: #8b96a3; }
.qsu-meta .accent { color: #e6b450; }
.qsu-meta .dim { color: #66707d; }
.qsu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 6px; margin-bottom: 4px; }
.qsu-grid .k { color: #66707d; font-size: 8px; letter-spacing: 1px; display: block; }
.qsu-grid .v { color: var(--qradar-ink, #c9d1d9); font-weight: 700; }
.qsu-conf { color: #e6b450; letter-spacing: 1px; margin-bottom: 3px; }
.qsu-conf .off { color: #333c47; }
.qsu-conf .lbl { color: #66707d; font-size: 8px; letter-spacing: 1px; margin-right: 4px; }
.qsu-cc { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.qsu-cc .cc {
  border: 1px solid #2a333d;
  border-radius: 2px;
  padding: 0 4px;
  color: #8b96a3;
  font-size: 9px;
}
.qsu-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid #1b222b;
  padding-top: 3px;
  margin-top: 2px;
}
.qsu-foot .id-lbl { color: #66707d; font-size: 8px; letter-spacing: 1px; }
.qsu-foot .id { color: var(--qradar-ink, #c9d1d9); font-weight: 700; }
.qsu-foot .open { margin-left: auto; color: #58a6ff; text-decoration: none; font-size: 9px; letter-spacing: 1px; }
.qsu-foot .open:hover { text-decoration: underline; }
.qsu-status.long { color: var(--qradar-long-glow, #39d353); }
.qsu-status.short { color: var(--qradar-short-glow, #ff6a5f); }

/* ── ⋯-Menue (Ansichten + Einstellungen) ─────────────────────────── */
.qr-menu {
  position: absolute;
  left: 80%;
  top: 15%;
  z-index: 9;
  min-width: 200px;
  display: none;
  padding: 3px;
  background: rgba(10, 14, 19, 0.97);
  border: 1px solid #333c47;
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.qr-menu.is-open { display: block; }
.qr-menu-item {
  padding: 4px 8px;
  color: #8b96a3;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 2px;
}
.qr-menu-item:hover { background: #1a212a; color: var(--qradar-ink, #c9d1d9); }
.qr-menu-item.is-active { color: var(--qradar-long-glow, #39d353); }
.qr-menu-item.is-active::before { content: "\2022"; margin-right: 4px; }
.qr-menu-sep { height: 1px; margin: 3px 2px; background: #2a333d; }

/* Leer-Zustand: ohne aktive Signale ist die Matrix reine Schraffur und
   liest sich als Defekt. Ein dezenter Hinweis sagt, woran es liegt. */
.qr-empty {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 3px 10px;
  border: 1px solid #2a333d;
  border-radius: 3px;
  background: rgba(10, 14, 19, 0.88);
  color: #8b96a3;
  font: 800 9px/1.5 "Inter", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 1.4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.qr-empty.is-on { opacity: 1; }
/* Ausweg-Klick: die Meldung „Auswahl ohne Signale" ist bedienbar. */
.qr-empty.is-actionable {
  pointer-events: auto;
  cursor: pointer;
  color: var(--qradar-ink, #c9d1d9);
  border-color: var(--qradar-long, #3fb950);
}
.qr-empty.is-actionable:hover { background: rgba(24, 32, 24, 0.95); }

/* ── Signal-Matrix: Scroll-Container (beide Achsen) ──────────────
   Der Container scrollt; das Gitter darin ist max-content breit/hoch.
   Nie beides in EIN Element legen (sonst scrollWidth == clientWidth und
   der horizontale Scrollbalken erscheint nie — siehe Skill-Pitfall). */
.qr-mx-scroll {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  border: 1px solid #1b222b;
  background: var(--qradar-recess, #0c1015);
  /* KEIN scrollbar-width hier: in Chrome ueberstimmt eine gesetzte
     scrollbar-width (thin/none) die ::-webkit-scrollbar-Regeln, der Balken
     faellt dann auf die native helle Leiste zurueck. Die Leiste ist 1:1 die
     des Journals (.tj-content in trading_journal.css). */
}
/* Scroll-Leiste: Haus-Standard aus tokens.css / qril_header_middleware._STYLE
   (8px, Track --color-surface-secondary, Thumb --color-border-strong).
   Hier NICHTS eigenes definieren — Gate: tests/test_ui_scrollbar_standard.py. */

.qr-mx {
  --qr-cw: 16px;     /* Timeframe-Spaltenbreite (eine Spalte = eine Zeiteinheit) */
  --qr-rh: 14px;     /* Strategie-Zeilenhoehe   */
  --qr-lw: 96px;     /* Strategie-Spalte (labels) */
  --qr-hi: 13px;     /* Instrumenten-Band       */
  --qr-h1: 12px;     /* Timeframe-Gruppenband   */
  --qr-h2: 15px;     /* Timeframe-Kopfzeile (ausgeschriebene Kuerzel) */
  --qr-dot: 7px;     /* LED-Groesse im Kasten   */
  display: inline-block;
  width: max-content;
  min-width: 100%;
  vertical-align: top;
}

/* Kopfzeilen — sticky nach oben (Instrumente / Gruppe / Timeframe) */
.qr-mx-hrow {
  position: sticky;
  display: flex;
}
.qr-mx-hrow.is-instrow { top: 0; z-index: 7; height: var(--qr-hi); }
.qr-mx-hrow.is-grprow { top: var(--qr-hi); z-index: 6; height: var(--qr-h1); }
.qr-mx-hrow.is-tfrow  { top: calc(var(--qr-hi) + var(--qr-h1)); z-index: 5; height: var(--qr-h2); }

.qr-corner {
  position: sticky;
  left: 0;
  z-index: 8;
  flex: 0 0 var(--qr-lw);
  width: var(--qr-lw);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  box-sizing: border-box;
  background: var(--qradar-panel, #141920);
  border-right: 1px solid #2a333d;
  border-bottom: 1px solid #2a333d;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #66707d;
  white-space: nowrap;
  overflow: hidden;
}
.qr-mx-hrow.is-instrow .qr-corner { background: #171e26; color: #8b96a3; }
.qr-mx-hrow.is-grprow .qr-corner { background: #1a212a; }
.qr-mx-hrow.is-tfrow .qr-corner { background: #10151b; }

/* Instrumenten-SCOPE-Chips (wie die Instrumenten-Leiste der Radar-Seite).
   Keine Spalten-Bloecke mehr: die Matrix hat genau EINE Timeframe-Achse. */
.qr-inst-chip.qr-iband {
  box-sizing: border-box;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: calc(var(--qr-hi) - 2px);
  margin: 1px 4px 1px 0;
  padding: 0 8px;
  border-radius: 3px;
  border: 1px solid #2a333d;
  background: linear-gradient(180deg, #161d25, #0f141a);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--qradar-ink-dim, #7d8892);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}
.qr-inst-chip.qr-iband:hover { color: var(--qradar-white, #f0f6fc); background: linear-gradient(180deg, #1d2630, #131a21); }
.qr-inst-chip.qr-iband.is-active {
  color: #d7e2ec;
  background: linear-gradient(180deg, #24303c, #161e26);
  box-shadow: inset 0 -2px 0 -1px rgba(53, 208, 216, 0.65);
}

.qr-gcell {
  box-sizing: border-box;      /* 1px Rand darf die Spannenbreite nicht vergroessern */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a212a;
  border-right: 1px solid #2a333d;   /* Gruppenstart muss sichtbar sein */
  border-bottom: 1px solid #2a333d;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8b96a3;
  overflow: hidden;
  white-space: nowrap;
}
/* Timeframe-Kopfzeile: EINE Spalte = EINE Zeiteinheit, ausgeschrieben
   ("1s".."30s", "1m".."55m", "1h".."12h", "D", "2D".."5D", "W", "M").
   Schriftgroesse 8px, cw 16px: 3 Zeichen ("55m") brauchen ~14px, bei
   kleinerer Spalte wuerden die Kuerzel abgeschnitten (der alte Zustand). */
.qr-tfcell {
  box-sizing: border-box;      /* sonst 1px pro Spalte -> Kopf laeuft weg */
  flex: 0 0 var(--qr-cw);
  width: var(--qr-cw);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f131a;
  border-right: 1px solid #161c23;
  border-bottom: 1px solid #2a333d;
  font-size: 8px;
  font-weight: 700;
  color: #8b96a3;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  overflow: hidden;
}
/* Erste Spalte einer Gruppe: sichtbarer Schnitt, damit sich jede Spalte
   eindeutig ihrem Gruppenband (SEC/MIN/HOUR/DAYS/WK/MO) zuordnen laesst. */
.qr-tfcell.is-gstart,
.qr-cell.is-gstart { border-left: 1px solid #2a333d; }

/* Strategie-Zeilen */
.qr-mx-row { display: flex; }
.qr-lab {
  position: sticky;
  left: 0;
  z-index: 4;
  flex: 0 0 var(--qr-lw);
  width: var(--qr-lw);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 5px;
  height: var(--qr-rh);
  padding: 0 6px;
  background: var(--qradar-panel, #141920);
  border-right: 1px solid #2a333d;
  border-bottom: 1px solid #161c23;
  font-size: 9px;
  font-weight: 600;
  color: var(--qradar-ink, #c9d1d9);
  white-space: nowrap;
  overflow: hidden;
}
.qr-lab .qr-labname { overflow: hidden; text-overflow: ellipsis; }
.qr-lab.is-placeholder { color: #66707d; }
.qr-lab.is-grouphead {
  height: var(--qr-h1);
  background: #1a212a;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #8b96a3;
  cursor: pointer;
  user-select: none;
}
.qr-lab.is-grouphead:hover { background: #222a34; color: var(--qradar-white, #f0f6fc); }
.qr-lab.is-grouphead.is-collapsed .qr-gcount { color: #66707d; }
.qr-gtri { flex: 0 0 auto; width: 8px; color: var(--qradar-metal-hi, #5c6672); font-size: 8px; line-height: 1; }
.qr-gcount {
  flex: 0 0 auto;
  margin-left: 2px;
  padding: 0 4px;
  border-radius: 7px;
  background: var(--qradar-recess, #0c1015);
  border: 1px solid #2a333d;
  font-size: 8px;
  font-weight: 700;
  color: #8b96a3;
}
/* Fuellung rechts vom Gruppenkopf — laeuft bis zum rechten Rand der Zeile */
.qr-gfill {
  flex: 1 1 auto;
  height: var(--qr-h1);
  background: #1a212a;
  border-bottom: 1px solid #161c23;
}

/* Zellen: (Strategie x Instrument x Timeframe) — quadratisch, terminal-dicht */
.qr-cell {
  flex: 0 0 var(--qr-cw);
  width: var(--qr-cw);
  height: var(--qr-rh);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, #11171e, #0a0e13);
  border-right: 1px solid #1b222b;
  border-bottom: 1px solid #1b222b;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55);
  cursor: default;
}
.qr-cell.is-clickable { cursor: pointer; }
.qr-cell.is-clickable:hover { background: #131a22; }
.qr-cell.is-placehold {
  background-image: repeating-linear-gradient(45deg, #1a2029 0 2px, #0d1218 2px 4px);
  background-color: #0d1218;
}

/* Zustand: Status-Zeichen in der Zelle (Farbe = Richtung, Buchstabe = Status,
   wie die Signal-Matrix der Radar-Seite: L/S Detected, T Triggered, W Win,
   L Loss, I Invalidated). Groesse/Schrift kommen aus der JS-Geometrie
   (--qr-dot/--qr-fs aus TIER_GEOM) — seit 2026-10-04 traegt JEDE Staffel den
   Buchstaben, deshalb ist die Marke ueberall quadratisch statt Punkt. */
.qr-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--qr-dot);
  height: var(--qr-dot);
  border-radius: 2px;
  font-size: var(--qr-fs, 7px);
  font-weight: 800;
  line-height: 1;
  color: var(--qradar-recess, #0c1015);
  opacity: 0;
}
.qr-mark.long  { opacity: 1; background: var(--qradar-long, #3fb950); box-shadow: 0 0 4px var(--qradar-long-glow, #39d353); }
.qr-mark.short { opacity: 1; background: var(--qradar-short, #f85149); box-shadow: 0 0 4px var(--qradar-short-glow, #ff6a5f); }
.qr-mark.detected { animation: qr-blink 1.5s ease-in-out infinite; }
.qr-mark.triggered { color: #fff; box-shadow: 0 0 3px rgba(255, 255, 255, 0.22); }
.qr-mark.win  { box-shadow: 0 0 5px 1px var(--qradar-long-glow, #39d353); border: 1px solid rgba(255, 255, 255, 0.4); }
.qr-mark.loss { color: #fff; box-shadow: 0 0 5px 1px var(--qradar-short-glow, #ff6a5f); border: 1px solid rgba(255, 255, 255, 0.4); }
.qr-mark.invalidated { background: #66707d; box-shadow: none; color: var(--qradar-ink, #c9d1d9); }
@keyframes qr-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .qr-mark.detected { animation: none; opacity: 0.75; }
}

/* Einstellungen: unsichtbarer Klickbereich genau auf dem eingebackenen
   Drei-Punkte-Knopf der Huelle. Am PNG gemessen (Helligkeitskarte):
   Knopf x 92.6..96.1%, y 8.8..13.7% → Klickflaeche x 92.3..96.3, y 8.3..14.3. */
.qr-gear {
  position: absolute;
  left: 92.3%;
  top: 8.3%;
  width: 4.0%;
  height: 6.0%;
  z-index: 3;
  background: transparent;
  border: 0;
  padding: 0;
  color: transparent;
  cursor: pointer;
}
.qr-gear:focus { outline: none; }
.qr-gear:hover { background: rgba(255, 255, 255, 0.05); border-radius: 3px; }

/* Tooltip: Instrument / Strategie / Timeframe / Richtung / Status
   (bleibt global am body, daher hier ohne .qr-Kontext) */
.qradar-tip {
  position: fixed;
  z-index: 9999;
  max-width: 320px;
  padding: 5px 7px;
  background: rgba(12, 16, 21, 0.97);
  border: 1px solid #333c47;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--qradar-ink, #c9d1d9);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.qradar-tip .tip-sig {
  padding: 3px 1px;
  border-bottom: 1px solid #1b222b;
}
.qradar-tip .tip-sig:last-child { border-bottom: 0; }
.qradar-tip .tip-sym { font-weight: 800; letter-spacing: 1px; color: var(--qradar-white, #f0f6fc); }
.qradar-tip .tip-strat { color: #8b96a3; }
.qradar-tip .tip-tf { color: #7d8892; }
.qradar-tip .tip-dir { font-weight: 800; letter-spacing: 1px; }
.qradar-tip .tip-dir.long { color: var(--qradar-long-glow, #39d353); }
.qradar-tip .tip-dir.short { color: var(--qradar-short-glow, #ff6a5f); }
.qradar-tip .tip-st { font-weight: 700; letter-spacing: 1px; color: #8b96a3; }
.qradar-tip .tip-st.st-detected { color: #d0a53a; }
.qradar-tip .tip-st.st-triggered { color: var(--qradar-white, #f0f6fc); }
.qradar-tip .tip-st.st-win { color: var(--qradar-long-glow, #39d353); }
.qradar-tip .tip-st.st-loss { color: var(--qradar-short-glow, #ff6a5f); }
.qradar-tip .tip-st.st-invalidated { color: #66707d; }
.qradar-tip .tip-more { color: #66707d; padding-top: 3px; }
