/* ── Select2 — dark hub theme for statistics ULD picker ─────────────────────── */
.stats-uld-select-wrap .select2-container {
  width: 100% !important;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.875rem;
}
.stats-uld-select-wrap .select2-container--default .select2-selection--single {
  min-height: 48px;
  background: #070e1d;
  border: 1px solid #534434;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
}
.stats-uld-select-wrap .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #dce2f7;
  line-height: 1.4;
  padding: 0.5rem 2.25rem 0.5rem 1rem;
}
.stats-uld-select-wrap .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #d8c3ad;
}
.stats-uld-select-wrap .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
  right: 0.75rem;
}
.stats-uld-select-wrap .select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: #d8c3ad transparent transparent transparent;
}
.stats-uld-select-wrap .select2-container--default.select2-container--open .select2-selection--single {
  border-color: #ffc174;
  box-shadow: 0 0 0 1px #ffc174;
}
.stats-uld-select-wrap .select2-container--default.select2-container--focus .select2-selection--single {
  border-color: #ffc174;
}
.select2-dropdown.stats-uld-select2-dropdown {
  background: #141b2b;
  border: 1px solid #534434;
  border-radius: 0.25rem;
  z-index: 9999;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-search--dropdown {
  padding: 0.5rem;
  background: #141b2b;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-search--dropdown .select2-search__field {
  background: #070e1d;
  border: 1px solid #534434;
  color: #dce2f7;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.875rem;
  outline: none;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-search--dropdown .select2-search__field:focus {
  border-color: #ffc174;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-results__option {
  color: #dce2f7;
  padding: 0.5rem 0.75rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8125rem;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
  background: #232a3a;
  color: #ffc174;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-results__option--selected {
  background: rgba(255, 193, 116, 0.12);
  color: #ffc174;
}
.select2-dropdown.stats-uld-select2-dropdown .select2-results__message {
  color: #d8c3ad;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
}

/* ── Full-viewport 3D model ──────────────────────────────────────────────────── */
.stats-uld-model-viewer {
  display: block;
  width: 100%;
  height: 100%;
  background: #070e1d;
  --poster-color: #141b2b;
}
#stats-viewport:has(#stats-uld-model:not(.hidden)) #stats-viewport-reticle {
  opacity: 0;
}
#stats-viewport:has(#stats-uld-model:not(.hidden)) #stats-uld-model-empty {
  display: none;
}

/* 2D schematic heatmap only (hidden when 3D model is shown — stress is on-mesh) */
.stats-defect-heatmap {
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#stats-viewport:has(#stats-uld-model:not(.hidden)) .stats-defect-heatmap {
  display: none !important;
}

/* ── FEA tooltip ─────────────────────────────────────────────────────────────── */
#stats-fea-tooltip {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  min-width: 195px;
  max-width: 240px;
}
.stats-fea-tt-box {
  background: rgba(5, 10, 22, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255, 193, 116, 0.7);
  border-radius: 3px;
  padding: 10px 13px 11px;
  font-family: "JetBrains Mono", monospace;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.75),
    0 0 20px rgba(255, 160, 60, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.stats-fea-tt-type {
  color: #dce2f7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 5px;
}
.stats-fea-tt-row {
  color: #8a97b4;
  font-size: 10px;
  line-height: 1.7;
}
.stats-fea-tt-stress {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Mini colour-scale bar with live cursor inside the tooltip */
.stats-fea-tt-bar-wrap {
  margin-top: 5px;
  position: relative;
  height: 5px;
  border-radius: 3px;
  overflow: visible;
  background: linear-gradient(
    to right,
    #0000b2, #003fff, #00c8ff, #00ff91,
    #00ff00, #91ff00, #ffed00, #ff6900, #ff0000
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.stats-fea-tt-bar-cursor {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 13px;
  background: #ffffff;
  border-radius: 1px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.85);
}

/* ── FEA stress legend colorbar ──────────────────────────────────────────────── */
#stats-fea-legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 10;
  pointer-events: none;
}
.stats-fea-legend-inner {
  display: flex;
  align-items: stretch;
  gap: 7px;
  background: rgba(5, 10, 22, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 4px;
  padding: 8px 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}
.stats-fea-legend-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  padding-right: 1px;
}
.stats-fea-legend-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 7.5px;
  font-weight: 700;
  color: #8a97b4;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stats-fea-colorbar {
  width: 11px;
  height: 132px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  /* Colorbar direction: top = highest stress (red), bottom = lowest (blue) */
  background: linear-gradient(
    to top,
    #0000b2  0%,
    #003fff 12%,
    #00c8ff 25%,
    #00ff91 37%,
    #00ff00 50%,
    #91ff00 62%,
    #ffed00 75%,
    #ff6900 87%,
    #ff0000 100%
  );
}
.stats-fea-legend-title {
  margin-top: 5px;
  font-family: "JetBrains Mono", monospace;
  font-size: 7px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #5a6882;
  text-align: center;
}
@media (max-width: 768px) {
  #stats-fea-legend {
    bottom: 12px;
    left: 12px;
    transform: scale(0.85);
    transform-origin: bottom left;
  }
  .stats-fea-colorbar {
    height: 96px;
  }
}
