/* Bloomberg-style visible-range stats (Last · High · Average · Low) */
.bbg-range-stats {
  position: absolute;
  top: calc(8px * var(--bbg-rs-scale, 1));
  right: calc(72px * var(--bbg-rs-scale, 1));
  left: auto;
  z-index: 190;
  display: flex;
  align-items: stretch;
  gap: 0;
  pointer-events: none;
  user-select: none;
  font-family: var(--font-bloomberg, 'Bloomberg Prop Unicode N', Consolas, monospace);
  font-size: calc(9.5px * var(--bbg-rs-scale, 1));
  line-height: 1.3;
  color: #ffffff;
  opacity: 0.98;
  max-width: calc(100% - calc(80px * var(--bbg-rs-scale, 1)));
}

.bbg-range-stats[hidden] {
  display: none !important;
}

.bbg-rs-tree,
.bbg-rs-tree-branch {
  display: none !important;
}

.bbg-rs-rows {
  display: flex;
  flex-direction: column;
  gap: calc(1px * var(--bbg-rs-scale, 1));
  min-width: 0;
  background: #000000;
  border: 1px solid #6e6e6e;
  padding:
    calc(4px * var(--bbg-rs-scale, 1))
    calc(8px * var(--bbg-rs-scale, 1))
    calc(5px * var(--bbg-rs-scale, 1));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(0, 0, 0, 0.65);
}

.bbg-rs-row {
  display: grid;
  grid-template-columns:
    calc(12px * var(--bbg-rs-scale, 1))
    minmax(0, 1fr)
    auto;
  align-items: center;
  column-gap: calc(4px * var(--bbg-rs-scale, 1));
  white-space: nowrap;
  min-height: calc(14px * var(--bbg-rs-scale, 1));
}

.bbg-rs-icon {
  display: block;
  justify-self: center;
}

.bbg-rs-icon--sq {
  width: calc(5px * var(--bbg-rs-scale, 1));
  height: calc(5px * var(--bbg-rs-scale, 1));
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.bbg-rs-icon--high {
  position: relative;
  width: calc(8px * var(--bbg-rs-scale, 1));
  height: calc(8px * var(--bbg-rs-scale, 1));
}

.bbg-rs-icon--high::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: #fff;
}

.bbg-rs-icon--high::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: calc(7px * var(--bbg-rs-scale, 1));
  background: #fff;
  transform: translateX(-50%);
}

.bbg-rs-icon--avg {
  width: calc(4px * var(--bbg-rs-scale, 1));
  height: calc(4px * var(--bbg-rs-scale, 1));
  border: 1px solid #fff;
  transform: rotate(45deg);
  margin: calc(2px * var(--bbg-rs-scale, 1));
}

.bbg-rs-icon--low {
  position: relative;
  width: calc(8px * var(--bbg-rs-scale, 1));
  height: calc(8px * var(--bbg-rs-scale, 1));
}

.bbg-rs-icon--low::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: #fff;
}

.bbg-rs-icon--low::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: calc(7px * var(--bbg-rs-scale, 1));
  background: #fff;
  transform: translateX(-50%);
}

.bbg-rs-label {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.bbg-rs-val {
  color: #ffffff;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-left: calc(8px * var(--bbg-rs-scale, 1));
}

#chart-host,
.mt-cell-body,
.mtg-chart-host,
#macro-reversal-radar-chart,
[data-gortex-chart] {
  --bbg-rs-scale: 1;
}

.mt-cell-body .bbg-range-stats {
  right: calc(48px * var(--bbg-rs-scale, 1));
  max-width: calc(100% - calc(54px * var(--bbg-rs-scale, 1)));
}

/* MONITORING GRID · Cortex Data sempre visível em todas as células */
#view-acompanhamento .mt-cell-body .bbg-range-stats:not([hidden]) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 220 !important;
  pointer-events: none;
}

#term-alerts-host .mtg-chart-host .bbg-range-stats,
#mtg-grid .mtg-chart-host .bbg-range-stats,
#view-alertas.al-alerts-desk .mtg-chart-host .bbg-range-stats {
  right: calc(44px * var(--bbg-rs-scale, 1));
  max-width: calc(100% - calc(50px * var(--bbg-rs-scale, 1)));
  font-size: calc(8px * var(--bbg-rs-scale, 1));
}

#term-alerts-host .mtg-chart-host .bbg-rs-row,
#mtg-grid .mtg-chart-host .bbg-rs-row,
#view-alertas.al-alerts-desk .mtg-chart-host .bbg-rs-row {
  min-height: calc(12px * var(--bbg-rs-scale, 1));
}

body.geral-view-only .bbg-range-stats {
  font-size: calc(10px * var(--bbg-rs-scale, 1));
}

body.geral-view-only .bbg-rs-row {
  min-height: calc(15px * var(--bbg-rs-scale, 1));
}

body.view-geral-active #chart-host .bbg-range-stats:not([hidden]) {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 220 !important;
  pointer-events: none;
}
