/* ═══════════════════════════════════════════════════════
   Basic Statistics — Sidebar (st-)
   ═══════════════════════════════════════════════════════ */

/* Icon override for fill-based SVG */
.rsb-icon[data-tab="stats"] svg { fill: none; stroke: currentColor; }
.rsb-icon[data-tab="stats"] svg rect { fill: currentColor; stroke: none; }

.st-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.07rem;
}

/* ── Header (matches seasonality sn-v-header style) ── */
.st-header {
  padding: 14px 8px 0;
  flex-shrink: 0;
}
.st-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.st-header .sn-dash-open-btn {
  margin: 10px 0 8px;
}
.st-title {
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: -.01em;
  color: var(--text-bright);
}
.st-title span { color: var(--blue); }

/* ── Glass container (Soft Glass style) ── */
.st-glass-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}
.st-glass {
  background: var(--hover-subtle);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

/* ── Timeframe tabs ── */
.st-tf-tabs {
  display: flex;
  gap: 4px;
}
.st-tf-tab {
  flex: 1;
  padding: 7px 0;
  border-radius: var(--radius-md);
  border: none;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all var(--ease);
}
.st-tf-tab:hover { color: var(--text); }
.st-tf-tab.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
}

/* ── Lookback selector ── */
.st-lookback-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.st-lookback-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex-shrink: 0;
}
.st-lookback-opts {
  display: flex;
  gap: 3px;
  flex: 1;
}
.st-lb-btn {
  flex: 1;
  padding: 3px 0;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all var(--ease);
}
.st-lb-btn:hover { color: var(--text); }
.st-lb-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
}
/* ── Compute statistics row (textual sentence + dropdowns, lives inside AI box) ── */
.st-ai-wrap .st-compute-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 6px;
  font-family: var(--font-ui);
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
  padding: 14px 18px;
  background: rgba(255,255,255,.025);
  border-bottom: 1px solid var(--border);
}
.st-compute-text {
  color: var(--text);
}
.st-compute-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(255,255,255,.06);
  color: var(--text-bright, var(--text));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  padding: 3px 22px 3px 9px;
  font-family: var(--font-ui);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' fill='none' stroke='white' stroke-opacity='0.85' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.st-compute-select:hover {
  background-color: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.18);
}
.st-compute-select:focus {
  outline: none;
  background-color: rgba(255,255,255,.1);
  border-color: var(--blue, rgba(255,255,255,.25));
}
.st-compute-select option {
  background: var(--card, #181a23);
  color: var(--text);
  font-weight: 500;
}
/* ── Compute row inside the Statistics Dashboard modal AI Analyst panel ── */
#stmActionBox:empty {
  display: none;
}
/* When action box hosts the compute row, break out of the 3-col grid layout */
.stm-action-box.stm-actionbox-compute {
  display: block !important;
  grid-template-columns: none !important;
  padding: 14px 18px !important;
  background: rgba(255,255,255,.025) !important;
}
.stm-actionbox-compute .st-compute-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 6px;
  font-family: var(--font-ui);
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── Open Statistics Dashboard button (uses .sn-dash-open-btn from seasonality.css) ── */

/* ── Sidebar volatility chart ── */
.st-vol-chart-glass { padding: 10px 10px 0; overflow: hidden; }
.st-vol-chart-glass .st-section-title { margin-bottom: 4px; }
.st-vol-chart-wrap {
  position: relative;
  height: 110px;
  margin: 0 -10px;
}
.st-vol-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Sidebar AI Insights wrapper ── */
.st-ai-wrap {
  background: var(--card); border-radius: var(--radius-md);
  border: 1px solid var(--border); overflow: hidden; margin-bottom: 10px;
}
.st-ai-wrap .stm-ai-header { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.st-ai-content { padding: 14px 0 4px; }
.st-ai-content .stm-ins-chapter { padding: 0 18px; margin-bottom: 18px; }
.st-ai-content .stm-ins-chapter:last-child { margin-bottom: 0; }
.st-ai-content .stm-ins-chapter-title {
  padding: 0 0 8px;
  margin-bottom: 14px;
}
.st-ai-content .stm-ins-section {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--border);
}
.st-ai-content .stm-ins-section:last-child {
  padding-bottom: 4px;
  border-bottom: none;
}
.st-ai-wrap .stm-reveal { animation: none; opacity: 1; transform: none; }

/* ── Section title ── */
.st-section-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -12px -14px 10px;
  padding: 10px 14px;
  background: var(--divider-soft);
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid var(--surface-raised);
}

/* ── Expand button ── */
.st-expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--ease);
  flex-shrink: 0;
  padding: 0;
  border-radius: 4px;
}
.st-expand-btn:hover {
  color: var(--blue);
  background: var(--blue-dim);
}

/* ── Stat rows ── */
.st-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--divider-soft);
}
.st-stat-row:last-child { border-bottom: none; }

.st-lbl {
  font-size: .87rem;
  color: var(--text-dim);
  font-weight: 500;
}
.st-vals {
  display: flex;
  gap: 14px;
}
.st-val {
  font-family: var(--font-ui);
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-bright);
}
.st-val.dim { color: var(--text-dim); }
.st-val.up { color: var(--green); }
.st-val.down { color: var(--red); }

/* ── Key-Value row (legacy, used in modal) ── */
.st-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

/* ── Direction bar ── */
.st-dir-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  gap: 3px;
  margin: 6px 0 8px;
}
.st-dir-bull {
  background: var(--green);
  border-radius: 5px 0 0 5px;
}
.st-dir-bear {
  background: var(--red);
  border-radius: 0 5px 5px 0;
}
.st-dir-labels {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.st-dir-labels .up { color: var(--green); }
.st-dir-labels .down { color: var(--red); }

/* ── Streak badge ── */
.st-streak {
  text-align: center;
  font-size: .85rem;
  font-weight: 600;
  color: var(--green);
  margin-top: 8px;
  padding: 6px;
  background: var(--green-subtle);
  border-radius: var(--radius-md);
}
.st-streak.bear {
  color: var(--red);
  background: var(--red-subtle);
}

/* ── Extremes controls row (lookback + unit toggle) ── */
.st-ext-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.st-ext-controls .st-lookback-opts { flex: 1; }
.st-ext-controls .st-unit-toggle { margin-bottom: 0; }

/* ── Unit toggle ($ / %) ── */
.st-unit-toggle {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.st-unit-btn {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ease);
}
.st-unit-btn:hover { color: var(--text); }
.st-unit-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
}

/* ── Extreme bars ── */
.st-extreme-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 0 3px;
}
.st-extreme-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
}
.st-extreme-row:hover { background: var(--surface-raised); }
.st-extreme-date {
  font-size: .87rem;
  color: var(--text-dim);
}
.st-extreme-val {
  font-family: var(--font-ui);
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-bright);
}

/* ── Typical Range controls ── */
.tr-controls {
  border: 1px solid var(--purple-med);
}
.tr-controls .st-section-title {
  background: var(--purple-dim);
  border-bottom-color: var(--purple-dim);
  color: var(--purple);
}
.tr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}
.tr-row + .tr-row {
  border-top: 1px solid var(--divider-soft);
}
.tr-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-dim);
}
.tr-btn-group {
  display: flex;
  gap: 3px;
}
.tr-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
}
.tr-btn:hover { color: var(--text); }
.tr-btn.active {
  background: var(--purple);
  color: #fff;
}
.tr-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--surface-border-hi);
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.tr-toggle.on {
  background: var(--purple);
}
.tr-toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
}
.tr-toggle.on .tr-toggle-knob {
  transform: translateX(16px);
}
.tr-info {
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0 0;
  font-style: italic;
}

/* ── Probability Cone — collapsible header ── */
.pc-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pc-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pc-expand-btn {
  background: none;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ease);
}
.pc-expand-btn:hover { color: var(--text); border-color: var(--surface-border-strong); }
.pc-expand-btn svg { transition: transform .2s ease; }
.pc-expand-btn.expanded svg { transform: rotate(180deg); }
.pc-settings {
  margin-top: 8px;
  border-top: 1px solid var(--divider-soft);
  padding-top: 4px;
}
.pc-select {
  background: var(--hover-subtle);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .82rem;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--ease);
}
.pc-select:focus { border-color: var(--blue-focus); }
.pc-select option { background: var(--panel); color: var(--text); }
.pc-layer-row { margin-top: 2px; }
.pc-layer-row .tr-label { font-size: .82rem; opacity: .7; }
.pc-explanation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--divider-soft);
  font-family: var(--font-ui);
  font-size: .82rem;
  line-height: 1.45;
  color: rgba(255,255,255,.35);
}

/* ═══════════════════════════════════════════════════════
   Stats Detail Modal (stm-) — Enterprise Edition
   ═══════════════════════════════════════════════════════ */
.stm-overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  z-index: 200; display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(var(--overlay-blur));
}
.stm-overlay.open { display: flex; animation: optFadeIn .2s ease; }

.stm-panel {
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  background: var(--panel);
  border: none;
  border-radius: 0;
  display: flex; flex-direction: row;
  box-shadow: var(--overlay-shadow);
  overflow: hidden;
  animation: optSlideIn .2s ease;
  font-family: var(--font-ui);
}

/* ── Left nav sidebar ── */
.stm-left-nav {
  width: 56px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 6px;
  background: var(--surface-veil);
  border-right: 1px solid var(--border);
}
.stm-nav-btn {
  padding: 10px 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: .62rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
  text-align: center;
  letter-spacing: .03em;
  text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.stm-nav-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; flex-shrink: 0; }
.stm-nav-btn:hover { color: var(--text); background: var(--divider-soft); }
.stm-nav-btn.active {
  background: var(--blue-dim);
  color: var(--blue);
}

/* ── Right content area ── */
.stm-right-content {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}

.stm-header {
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--surface-veil) 0%, transparent 100%);
}
.stm-header-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  gap: 16px;
}
.stm-header h3 {
  font-family: var(--font-ui);
  font-size: 1.2rem; font-weight: 700;
  color: var(--text-bright); white-space: nowrap;
  margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.stm-header h3::before {
  content: '';
  display: inline-block;
  width: 3px; height: 18px;
  background: var(--blue);
  border-radius: 2px;
}
.stm-header-controls {
  display: flex; align-items: center; gap: 14px;
  margin-left: auto;
}
.stm-nav-tf {
  display: flex; gap: 2px;
  background: var(--surface-raised);
  border-radius: 10px;
  padding: 3px;
}
.stm-tf-btn {
  padding: 5px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  min-width: 28px;
  text-align: center;
}
.stm-tf-btn:hover { color: var(--text); background: var(--surface-raised); }
.stm-tf-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.stm-lookback-row {
  display: flex; align-items: center; gap: 6px;
}
.stm-lookback-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
.stm-nav-lb {
  display: flex; gap: 3px;
}
.stm-nav-lb .stm-lb-btn {
  padding: 4px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  text-align: center;
}
.stm-nav-lb .stm-lb-btn:hover { color: var(--text); background: var(--surface-border); }
.stm-nav-lb .stm-lb-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-color);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ── Two-column main layout (metrics + insight) ── */
.stm-main {
  flex: 1; display: flex; overflow: hidden;
}
.stm-metric-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.stm-insight-area {
  width: 440px; min-width: 380px; max-width: 480px;
  display: flex; flex-direction: column;
  background: var(--card);
  flex-shrink: 0;
  overflow: hidden;
}

/* ── AI Analyst Header — aligned with .rpt-ai-header (gold standard) ── */
.stm-ai-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-bottom: 1px solid rgba(167,139,250,.22);
  flex-shrink: 0;
  background:
    linear-gradient(135deg, rgba(88,28,135,.45) 0%, rgba(109,40,217,.28) 45%, rgba(30,64,175,.18) 100%),
    radial-gradient(120% 140% at 0% 0%, rgba(196,181,253,.15), transparent 60%);
  position: relative;
}
.stm-ai-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,.6), transparent);
}
.stm-ai-stars { width: 28px; height: 28px; flex-shrink: 0; fill: #f3e8ff; }
.stm-ai-stars .stm-star-big {
  fill: #f3e8ff; transform-origin: center; transform-box: fill-box;
  animation: stmPulseStar 5s ease-in-out infinite;
}
.stm-ai-stars .stm-star-small {
  fill: #f3e8ff; transform-origin: center; transform-box: fill-box;
  animation: stmPulseStar 5s ease-in-out infinite .5s;
}
@keyframes stmPulseStar {
  0%,100% { transform: rotate(-18deg) scale(1); filter: drop-shadow(0 0 4px rgba(216,180,254,.8)); }
  50%     { transform: rotate(18deg) scale(1.35); filter: drop-shadow(0 0 10px rgba(216,180,254,1)); }
}
.stm-ai-text { display: flex; flex-direction: column; gap: 2px; }
.stm-ai-title {
  font-family: var(--font-ui); font-size: .92rem; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase;
  background: linear-gradient(135deg, #d8b4fe, #a78bfa 40%, #7dd3fc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  white-space: nowrap;
  line-height: 1.15;
}
.stm-ai-sub {
  font-family: var(--font-ui); font-size: .82rem;
  color: rgba(216,180,254,.75); font-weight: 400; white-space: nowrap;
  letter-spacing: .02em;
}

/* ── Action Box (3 KPI) ── */
.stm-action-box {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-veil);
}
.stm-action-item { text-align: center; padding: 8px 4px; background: var(--surface-veil); border-radius: var(--radius-sm); }
.stm-action-label { font-family: var(--font-ui); font-size: .6rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 3px; }
.stm-action-value { font-family: var(--font-ui); font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.stm-action-sub { font-family: var(--font-ui); font-size: .82rem; color: var(--text-muted); margin-top: 1px; }

/* ── Insight Scroll Area ── */
.stm-insight-scroll { flex: 1; overflow-y: auto; padding: 0; }
.stm-insight-scroll::-webkit-scrollbar { width: 5px; }
.stm-insight-scroll::-webkit-scrollbar-track { background: transparent; }
.stm-insight-scroll::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }

/* ── Numbered Sections ── */
.stm-ins-section { padding: 16px 18px 20px; border-bottom: 1px solid var(--border); }
.stm-ins-section:last-child { border-bottom: none; }
.stm-ins-section-header { margin-bottom: 14px; }
.stm-ins-title-row { display: flex; align-items: baseline; gap: 8px; }
.stm-ins-num {
  font-family: var(--font-ui); font-size: 1.4rem; font-weight: 700;
  color: var(--text-bright); line-height: 1.15; letter-spacing: -.01em;
}
.stm-ins-title {
  font-family: var(--font-ui); font-size: 1.4rem; font-weight: 700;
  color: var(--text-bright); line-height: 1.15; letter-spacing: -.01em;
}
.stm-ins-subtitle { font-family: var(--font-ui); font-size: .82rem; font-weight: 500; color: var(--text-muted); margin-top: 4px; }

/* ── Prose ── */
.stm-ins-prose { font-family: var(--font-ui); font-size: .93rem; line-height: 1.65; color: var(--text); margin-bottom: 10px; }
.stm-ins-prose:last-child { margin-bottom: 0; }
.stm-ins-prose strong { color: var(--text-bright); }
.stm-ins-prose .hl-green { color: var(--green); font-weight: 600; }
.stm-ins-prose .hl-red { color: var(--red); font-weight: 600; }
.stm-ins-prose .hl-amber { color: var(--amber); font-weight: 600; }
.stm-ins-prose .hl-blue { color: var(--blue); font-weight: 600; }
.stm-ins-prose .hl-white { color: var(--text-bright); font-weight: 600; }
.stm-ins-prose .hl { color: var(--text-bright); }
.stm-ins-prose .num { font-family: var(--font-ui); font-weight: 700; }

/* ── Widget inline ── */
.stm-ins-widget {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 14px;
}
.stm-ins-widget-title {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted); margin-bottom: 10px;
}

/* ── NOW marker ── */
.stm-now-marker {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px; font-size: .82rem; font-weight: 700;
  background: var(--blue-dim); border: 1px solid var(--blue-strong); color: var(--blue);
}
.stm-now-marker::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue); animation: stmNowPulse 1.5s ease-in-out infinite;
}
@keyframes stmNowPulse { 0%,100%{opacity:.5;transform:scale(.8)} 50%{opacity:1;transform:scale(1.2)} }

/* ── Streak badge ── */
.stm-streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700;
}
.stm-streak-badge.bull { background: var(--green-dim); color: var(--green); }
.stm-streak-badge.bear { background: var(--red-dim); color: var(--red); }

/* ── Metric grid ── */
.stm-ins-metrics {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 2px; margin-bottom: 10px;
}
.stm-ins-metric { padding: 5px 6px; background: var(--surface-veil); border-radius: 4px; text-align: center; }
.stm-ins-metric-label { font-family: var(--font-ui); font-size: .6rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 2px; }
.stm-ins-metric-val { font-family: var(--font-ui); font-size: .82rem; font-weight: 700; }

/* ── Distribution bell curve ── */
.stm-ins-bell-wrap { position: relative; height: 62px; margin-bottom: 2px; }
.stm-ins-bell-svg { width: 100%; height: 62px; display: block; overflow: visible; }
.stm-ins-bell-labels {
  display: flex; justify-content: space-between; font-size: .82rem;
  color: var(--text-muted); margin-bottom: 8px; position: relative;
}
.stm-ins-bell-mu {
  position: absolute; transform: translateX(-50%);
  color: var(--text-bright); font-weight: 700;
}

/* ── Insight summary table ── */
.stm-ins-summary { margin-top: 16px; }
.stm-ins-summary-title {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); margin-bottom: 8px;
}
.stm-ins-summary-tbl {
  width: 100%; border-collapse: collapse;
  font-size: .82rem;
}
.stm-ins-summary-tbl td { padding: 7px 4px; border-bottom: 1px solid var(--divider-soft); }
.stm-ins-summary-tbl td:first-child { padding-left: 0; }
.stm-ins-summary-tbl td:last-child { padding-right: 0; }
.stm-ins-tbl-lbl {
  font-family: var(--font-ui); font-weight: 600;
  color: var(--text-muted); width: 38%;
}
.stm-ins-tbl-val {
  font-family: var(--font-ui); font-weight: 700;
  color: var(--text-bright); text-align: right; width: 32%;
}
.stm-ins-tbl-sub {
  font-family: var(--font-ui); font-size: .82rem;
  color: var(--text-dim); text-align: right; width: 30%;
}
.stm-ins-tbl-sep td {
  border-bottom: 1px solid var(--surface-border) !important;
  padding: 0 !important; height: 1px;
}

/* ── Regime bar ── */
.stm-ins-regime-bar { position: relative; height: 24px; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.stm-ins-regime-zone { position: absolute; top: 0; height: 100%; }
.stm-ins-regime-needle { position: absolute; top: -3px; width: 3px; height: 30px; background: #fff; border-radius: 2px; z-index: 5; transition: left .5s ease; }
.stm-ins-regime-labels { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-muted); }

/* ── Direction bar ── */
.stm-ins-dir-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.stm-ins-dir-bull { background: var(--green); }
.stm-ins-dir-bear { background: var(--red); }
.stm-ins-dir-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: .82rem; font-weight: 600; }
.stm-ins-dir-labels .up { color: var(--green); }
.stm-ins-dir-labels .down { color: var(--red); }

/* ── Glossary (collapsible) ── */
.stm-collapse-trigger {
  display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 0; user-select: none;
}
.stm-collapse-trigger:hover .stm-ins-title { color: var(--blue); }
.stm-collapse-trigger .stm-caret { font-size: .6rem; color: var(--text-muted); transition: transform .2s ease; }
.stm-collapse-trigger.open .stm-caret { transform: rotate(90deg); }
.stm-collapse-body { display: none; }
.stm-collapse-body.open { display: block; }
.stm-glossary-item { margin-bottom: 8px; }
.stm-glossary-term { font-family: var(--font-ui); font-size: .88rem; font-weight: 700; color: var(--text-bright); margin-bottom: 1px; }
.stm-glossary-desc { font-family: var(--font-ui); font-size: .84rem; color: var(--text-dim); line-height: 1.45; }

/* ── Hero status bar (between cards and chart) ── */
.stm-hero-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 14px; margin-bottom: 16px;
  background: var(--blue-dim); border: 1px solid var(--blue-dim);
  border-radius: var(--radius-sm); font-family: var(--font-ui); font-size: .82rem;
}
.stm-hero-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stm-hero-label { color: var(--text-muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stm-hero-val { font-family: var(--font-ui); font-weight: 700; font-size: .82rem; }
.stm-hero-sep { width: 1px; height: 14px; background: var(--surface-border); flex-shrink: 0; }

/* ── Extremes top table in insight sidebar ── */
.stm-ins-top-table { width: 100%; font-size: .82rem; border-collapse: collapse; margin-bottom: 10px; }
.stm-ins-top-table th { font-family: var(--font-ui); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.stm-ins-top-table td { font-family: var(--font-ui); padding: 5px 6px; border-bottom: 1px solid var(--hover-subtle); color: var(--text); }
.stm-ins-top-table tr:hover td { background: var(--hover-subtle); }
.stm-ins-top-table .up { color: var(--green); }
.stm-ins-top-table .down { color: var(--red); }

/* ── Scroll fade hint ── */
.stm-insight-scroll { position: relative; }
.stm-insight-scroll::after {
  content: ''; position: sticky; bottom: 0; left: 0; right: 0; height: 24px; display: block;
  background: linear-gradient(transparent, var(--card)); pointer-events: none;
}

/* ── Progressive reveal ── */
.stm-reveal { opacity: 0; transform: translateY(12px); animation: stmReveal 1.2s ease forwards; }
@keyframes stmReveal { to { opacity: 1; transform: translateY(0); } }

/* ── Bottom charts strip ── */
.stm-bottom-charts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 1px;
  border-top: 1px solid var(--border);
  background: var(--border);
}
.stm-bottom-chart {
  position: relative; height: 140px;
  background: var(--card);
  overflow: hidden;
  padding: 24px 6px 6px;
}
.stm-bottom-chart canvas { width: 100% !important; height: 100% !important; }
.stm-bottom-chart-label {
  position: absolute; top: 6px; left: 10px; z-index: 2;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted);
  opacity: .7;
}

/* ── Percentile gauges (COT index style) ── */
.stm-bottom-chart--pct { padding: 24px 14px 8px; }
.stm-bottom-pct-wrap { height: 100%; display: flex; align-items: center; }
.stm-pct-gauges { width: 100%; }
.stm-pct-gauge-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
}
.stm-pct-gauge-row + .stm-pct-gauge-row { border-top: 1px solid var(--divider-soft); }
.stm-pct-gauge-label {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600;
  color: var(--text-dim); width: 62px; flex-shrink: 0;
}
.stm-pct-gauge-track {
  flex: 1; height: 7px; border-radius: 4px; position: relative;
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 15%, #a3a3a3 40%, #a3a3a3 60%, #f59e0b 85%, #ef4444 100%);
}
.stm-pct-gauge-marker {
  position: absolute; top: -4px; width: 3px; height: 15px;
  border-radius: 1px; transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 6px rgba(0,0,0,.5);
}
.stm-pct-gauge-val {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 700;
  width: 28px; text-align: right; flex-shrink: 0;
}
.stm-pct-gauge-zone {
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600;
  width: 100px; text-align: right; flex-shrink: 0; text-transform: uppercase;
  letter-spacing: .03em;
}
.stm-pct-gauge-active {
  background: var(--divider-soft); border-radius: 4px;
  margin: 0 -4px; padding: 6px 4px !important;
}
.stm-pct-gauge-active .stm-pct-gauge-label { color: var(--text-bright); font-weight: 700; }
.stm-pct-gauge-active .stm-pct-gauge-marker {
  width: 4px; height: 16px; top: -5px;
  box-shadow: 0 0 8px rgba(255,255,255,.4);
}

/* ── LEGACY — keep for old insight-header if referenced ── */
.stm-insight-area .insight-header {
  font-family: var(--font-ui);
  font-size: 0.84rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--surface-raised);
}
.stm-insight-content { display: flex; flex-direction: column; gap: 12px; padding: 0 18px 18px; }

/* ── Insight dynamic label for current chart view ── */
.stm-insight-view-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  display: inline-block;
  letter-spacing: .04em;
}

.stm-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}
.stm-body::-webkit-scrollbar { width: 6px; }
.stm-body::-webkit-scrollbar-track { background: transparent; }
.stm-body::-webkit-scrollbar-thumb {
  background: var(--surface-border);
  border-radius: 3px;
}
.stm-body::-webkit-scrollbar-thumb:hover { background: var(--surface-border-strong); }

/* ── Cards grid (responsive) ── */
.stm-cards-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}
.stm-cards-6 { grid-template-columns: repeat(6, 1fr); }
.stm-cards-8 { grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 14px; }
.stm-cards-8 .stm-card { padding: 8px 6px 7px; border-radius: 8px; }
.stm-cards-8 .stm-card-label { font-size: .82rem; margin-bottom: 3px; letter-spacing: .06em; }
.stm-cards-8 .stm-card-val { font-size: 1rem; }
.stm-cards-8 .stm-card-sub { font-size: .82rem; margin-top: 2px; }
.stm-cards-5 { grid-template-columns: repeat(5, 1fr); }
.stm-cards-4 { grid-template-columns: repeat(4, 1fr); }
.stm-cards-3 { grid-template-columns: repeat(3, 1fr); }
.stm-cards-2 { grid-template-columns: repeat(2, 1fr); }

.stm-card {
  background: var(--surface-veil);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  text-align: center;
  min-width: 0;
  transition: border-color .15s, background .15s;
}
.stm-card:hover {
  border-color: var(--border-hi);
  background: var(--divider-soft);
}
.stm-card-label {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stm-card-val {
  font-family: var(--font-ui);
  font-size: 1.27rem;
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.stm-card-sub {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stm-card-hint {
  font-size: .82rem;
  color: var(--text-faint);
  margin-top: 5px;
  font-style: italic;
  line-height: 1.4;
  white-space: normal;
  opacity: .8;
}

/* ── ATR row ── */
.stm-atr-row {
  font-size: 1.0rem;
  color: var(--text-dim);
  padding: 10px 16px;
  background: var(--surface-veil);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
  font-family: var(--font-ui);
  display: flex;
  align-items: center;
  gap: 8px;
}
.stm-atr-row strong {
  font-family: var(--font-ui);
  color: var(--text-bright);
  font-weight: 700;
}

/* ── Section blocks ── */
.stm-section {
  margin-bottom: 24px;
}
.stm-section-title {
  font-size: 0.89rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--surface-raised);
  display: flex;
  align-items: center;
  gap: 8px;
}
.stm-section-subtitle {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stm-section-subtitle .stm-section-badge {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-raised);
  padding: 2px 6px;
  border-radius: 3px;
}
.stm-section-title .stm-section-badge {
  font-size: .82rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: .03em;
  text-transform: none;
}

/* ── Chart switch tabs inside sections ── */
.stm-chart-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  padding: 3px;
  background: var(--hover-subtle);
  border-radius: 8px;
  border: 1px solid var(--hover-subtle);
}
.stm-chart-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  text-align: center;
}
.stm-chart-tab:hover { color: var(--text); background: var(--divider-soft); }
.stm-chart-tab.active {
  background: var(--blue-dim);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ── Chart toolbar (tabs + bins) ── */
.stm-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.stm-chart-toolbar .stm-chart-tabs {
  margin-bottom: 0;
  flex: 1;
}

/* ── Overlay button ── */
.stm-overlay-btn {
  padding: 5px 12px;
  border: 1px solid var(--blue-strong);
  border-radius: 6px;
  background: var(--blue-dim);
  color: var(--blue);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}
.stm-overlay-btn:hover { background: var(--blue-dim); }
.stm-overlay-btn.active {
  background: var(--red-dim);
  border-color: var(--red-med);
  color: var(--red);
}
.stm-overlay-btn.active:hover { background: var(--red-strong); }

/* ── Range mode switch (High-Low / Open-Close) ── */
.stm-range-mode-switch {
  display: flex; gap: 2px; margin-bottom: 16px;
  padding: 3px; background: var(--hover-subtle);
  border-radius: var(--radius-sm); border: 1px solid var(--hover-subtle);
  width: fit-content;
}
.stm-range-mode-btn {
  padding: 6px 16px; border: none; border-radius: 4px;
  background: transparent; color: var(--text-dim);
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--ease);
}
.stm-range-mode-btn:hover { background: var(--hover-subtle); color: var(--text); }
.stm-range-mode-btn.active {
  background: var(--blue-dim); color: var(--blue);
}

/* ── Section sticky header (shared between Range, Returns, Direction, Extremes) ── */
.stm-section-sticky-header,
.stm-ret-controls {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: center;
  position: sticky;
  top: -24px;
  z-index: 100;
  background: #161923;
  margin: -24px -28px 16px;
  padding: 24px 28px 14px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 14px -4px rgba(0, 0, 0, 0.6);
  isolation: isolate;
}
.stm-section-sticky-header .stm-range-mode-switch,
.stm-section-sticky-header .stm-compute-wrap { margin: 0; }
.stm-section-sticky-header .st-compute-row { flex-wrap: wrap; }
.stm-ret-control-group {
  display: flex; align-items: center; gap: 8px;
}
.stm-ret-control-label {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  color: var(--text-dim); white-space: nowrap;
}
.stm-ret-pills {
  display: flex; gap: 2px; padding: 3px;
  background: var(--hover-subtle); border-radius: var(--radius-sm);
  border: 1px solid var(--hover-subtle);
}
.stm-ret-period-btn,
.stm-ret-lb-btn {
  padding: 5px 14px; border: none; border-radius: 4px;
  background: transparent; color: var(--text-dim);
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--ease);
}
.stm-ret-period-btn:hover,
.stm-ret-lb-btn:hover { background: var(--hover-subtle); color: var(--text); }
.stm-ret-period-btn.active,
.stm-ret-lb-btn.active {
  background: var(--blue-dim); color: var(--blue);
}

/* ── Returns spinner ── */
.stm-ret-spinner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 80px 20px; color: var(--text-dim);
}
.stm-ret-spinner-ring {
  width: 36px; height: 36px; border: 3px solid var(--surface-border);
  border-top-color: var(--blue); border-radius: 50%;
  animation: stRetSpin 0.8s linear infinite;
}
@keyframes stRetSpin { to { transform: rotate(360deg); } }
.stm-ret-spinner-text {
  font-family: var(--font-ui); font-size: 0.92rem; font-weight: 500;
}

/* ── Custom period input ── */
.stm-ret-custom-wrap {
  display: flex; align-items: center; gap: 2px;
  margin-left: 4px;
}
.stm-ret-custom-input {
  width: 48px; padding: 5px 6px; border: 1px solid var(--surface-border-hi);
  border-radius: 4px; background: var(--divider-soft);
  color: var(--text); font-family: var(--font-ui); font-size: 0.85rem;
  font-weight: 600; text-align: center; outline: none;
  transition: border-color var(--ease), color var(--ease);
  -moz-appearance: textfield;
}
.stm-ret-custom-input::-webkit-outer-spin-button,
.stm-ret-custom-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stm-ret-custom-input:focus {
  border-color: var(--blue); color: var(--blue);
}
.stm-ret-custom-input::placeholder { color: var(--text-muted); font-weight: 500; }
.stm-ret-custom-label {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 600;
  color: var(--text-dim);
}

/* ── Bin width control inside histogram chart (top-left) ── */
.stm-rethist-section { position: relative; }
.stm-rethist-bin {
  position: absolute;
  top: 44px; left: 12px;
  z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0;
  pointer-events: auto;
}
.stm-rethist-bin .stm-ret-control-label { font-size: 0.82rem; color: var(--text-muted); }
.stm-rethist-bin .stm-ret-custom-input {
  width: 46px; height: 22px; padding: 2px 6px;
  font-size: 0.82rem;
  background: rgba(16,18,25,0.7);
  backdrop-filter: blur(4px);
}
.stm-rethist-bin .stm-ret-custom-label { font-size: 0.82rem; color: var(--text-muted); }

/* ── Forward returns summary cards ── */
.stm-ret-fwd-summary {
  display: flex; gap: 6px; margin: 12px 0 16px; flex-wrap: wrap;
}
.stm-ret-fwd-card {
  flex: 1; min-width: 80px; padding: 10px 8px;
  background: var(--surface-veil); border: 1px solid var(--surface-raised);
  border-radius: var(--radius-sm); text-align: center;
}
.stm-ret-fwd-horizon {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stm-ret-fwd-mean {
  font-family: var(--font-ui); font-size: 1.15rem; font-weight: 700;
}
.stm-ret-fwd-sub {
  font-family: var(--font-ui); font-size: 0.82rem; color: var(--text-dim);
  margin-top: 2px;
}
.stm-ret-fwd-wr {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 600;
  margin-top: 2px;
}

/* ── Forward returns grid ── */
.stm-grid-ret-fwd { grid-template-columns: 32px 110px repeat(6, 1fr); }

/* ── Insight chapter dividers ── */
.stm-ins-chapter { margin-bottom: 20px; }
.stm-ins-chapter-title {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 700;
  color: var(--blue); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 0 6px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(77,166,255,.15);
}

/* ── LWC timeline container ── */
.stm-ret-lwc-wrap {
  width: 100%; height: 280px;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* ── Chart type toggle (line/bar) ── */
.stm-canvas-section {
  position: relative;
  background: var(--surface-veil);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.stm-chart-type-toggle {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--divider-soft); border: 1px solid var(--surface-border);
  color: var(--text-dim); cursor: pointer;
  transition: all var(--ease);
}
.stm-chart-type-toggle:hover {
  background: rgba(255,255,255, var(--hover-medium));
  color: var(--text);
}

/* ── Chart overlay toggles ── */
.stm-chart-overlays {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 14px 8px;
}
.stm-cov-label {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 500;
  color: var(--text-dim); cursor: pointer;
  transition: color var(--ease);
}
.stm-cov-label:hover { color: var(--text); }
.stm-cov-cb {
  width: 14px; height: 14px; accent-color: var(--blue);
  cursor: pointer; margin: 0;
}
.stm-cov-swatch {
  width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0;
}

/* ── Chart panes for switching ── */
.stm-chart-pane { display: none; }
.stm-chart-pane.active { display: block; }

/* ── Canvas/chart containers ── */
.stm-canvas-wrap {
  width: 100%;
  position: relative;
  background: var(--surface-veil);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius-md);
  padding: 16px 14px 12px;
  box-sizing: border-box;
}
.stm-canvas-section .stm-canvas-wrap {
  background: none;
  border: none;
  border-radius: 0;
  padding: 4px 14px 12px;
}
.stm-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.stm-canvas-tall {
  min-height: 380px;
  height: 380px;
}
.stm-chart-hist {
  height: 380px;
  position: relative;
}
.stm-chart-spark {
  height: 300px;
  position: relative;
}
.stm-chart-line {
  height: 320px;
  position: relative;
}
.stm-chart-donut {
  height: 220px;
  width: 220px;
  position: relative;
  margin: 0 auto;
}
.stm-chart-hbar {
  height: 200px;
  position: relative;
}

/* ── Box Plot (percentiles) ── */
.stm-canvas-wrap:has(.stm-boxplot) {
  display: flex;
  align-items: center;
  justify-content: center;
}
.stm-boxplot {
  padding: 8px 0;
  width: 100%;
}
.stm-bp-stats {
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.stm-bp-stat {
  font-size: 0.84rem;
  color: var(--text-faint);
}
.stm-bp-stat b {
  font-family: var(--font-ui);
  color: var(--text-muted);
  font-weight: 600;
}
.stm-bp-container {
  position: relative;
  height: 100px;
  margin: 0 40px;
}
.stm-bp-labels {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
}
.stm-bp-label {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  line-height: 1.2;
}
.stm-bp-tag {
  display: block;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.stm-bp-val {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-bright);
  font-weight: 600;
}
.stm-bp-label.median .stm-bp-val { color: var(--blue); }
.stm-bp-label.median .stm-bp-tag { color: var(--blue); }

.stm-bp-track {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  height: 48px;
}
.stm-bp-whisker {
  position: absolute;
  top: 23px;
  height: 2px;
  background: var(--surface-border-strong);
}
.stm-bp-cap {
  position: absolute;
  width: 2px;
  height: 18px;
  top: 15px;
  background: rgba(255,255,255,.3);
  transform: translateX(-50%);
}
.stm-bp-box {
  position: absolute;
  top: 7px;
  height: 34px;
  background: var(--blue-dim);
  border: 1.5px solid var(--blue-focus);
  border-radius: 4px;
}
.stm-bp-median {
  position: absolute;
  top: 3px;
  height: 42px;
  width: 2.5px;
  background: var(--blue);
  border-radius: 2px;
  transform: translateX(-50%);
}
.stm-bp-dot {
  position: absolute;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  transform: translateX(-50%);
  opacity: .5;
}
.stm-bp-current {
  position: absolute;
  top: 17px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--blue);
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: 0 0 10px var(--blue-focus);
}
.stm-bp-current-label {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-bright);
  background: rgba(77,166,255,.9);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 4;
}
.stm-bp-current-label::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid rgba(77,166,255,.9);
}
.stm-bp-kv {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.stm-bp-kv-item {
  font-size: .82rem;
}
.stm-bp-kv-item .k {
  color: var(--text-faint);
  margin-right: 6px;
}
.stm-bp-kv-item .v {
  font-family: var(--font-ui);
  color: var(--text-muted);
  font-weight: 600;
}
.stm-bp-kv-item .v.pos { color: var(--green); }
.stm-bp-kv-item .v.neg { color: var(--red); }
.stm-bp-kv-item .v.warn { color: var(--amber); }

/* ── Chart inner title (centered inside canvas section) ── */
.stm-chart-inner-title {
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .01em;
  padding: 10px 0 4px;
}

/* ── Chart description label ── */
.stm-chart-desc {
  font-size: 0.82rem;
  color: var(--text-faint);
  line-height: 1.45;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--surface-veil);
  border-left: 2px solid var(--blue);
  border-radius: 0 6px 6px 0;
}
.stm-canvas-section .stm-chart-desc {
  margin-top: 0;
  padding: 6px 14px 10px;
  background: none;
  border-left: none;
  border-radius: 0;
}

/* ── Two-column layout (inside metric area) ── */
.stm-two-col {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: start;
}
.stm-two-col-streak {
  grid-template-columns: 1fr 1fr;
}
.stm-col {
  min-width: 0;
}

/* ── Donut chart container ── */
.stm-donut-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
}
.stm-donut-wrap canvas {
  display: block;
}

/* ── Streak analysis ── */
.stm-streak-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
}
.stm-streak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--hover-subtle);
  border: 1px solid var(--divider-soft);
  border-radius: 8px;
  transition: background .1s;
}
.stm-streak-row:hover { background: var(--hover-subtle); }
.stm-streak-lbl {
  font-size: 0.97rem;
  color: var(--text-dim);
  font-weight: 500;
}
.stm-streak-val {
  font-family: var(--font-ui);
  font-size: 1.07rem;
  font-weight: 700;
}
.stm-streak-val.up { color: var(--green); }
.stm-streak-val.down { color: var(--red); }

/* ── Percentile rows (return distribution) ── */
.stm-percentiles { display: flex; flex-direction: column; gap: 6px; }
.stm-pct-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0;
  transition: background .1s;
  border-radius: 4px;
}
.stm-pct-row:hover { background: var(--hover-subtle); }
.stm-pct-label {
  font-size: 0.9rem;
  color: var(--text-dim);
  width: 100px;
  text-align: right;
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-weight: 500;
}
.stm-pct-bar-wrap {
  flex: 1;
  height: 22px;
  background: var(--divider-soft);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.stm-pct-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .4s cubic-bezier(.25,.46,.45,.94);
  position: relative;
}
.stm-pct-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 60%, var(--surface-border) 100%);
  border-radius: 4px;
}
.stm-pct-val {
  font-family: var(--font-ui);
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--text);
  width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.stm-pct-count {
  font-family: var(--font-ui);
  font-size: 0.91rem;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Extremes year filter ── */
.stm-ext-year-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--hover-subtle);
  border: 1px solid var(--surface-raised);
  border-radius: var(--radius-md);
}
.stm-ext-filter-label {
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.stm-ext-slider-val {
  font-family: var(--font-ui);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-bright);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.stm-ext-slider-wrap {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  border-radius: 3px;
  background: var(--surface-border);
}
.stm-ext-slider {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  left: 0; right: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  pointer-events: none;
  outline: none;
}
.stm-ext-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border-radius: 2px;
}
.stm-ext-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 4px; height: 16px;
  border-radius: 2px;
  background: #fff;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  margin-top: -6px;
  position: relative;
  z-index: 2;
}
.stm-ext-slider::-moz-range-track {
  height: 4px;
  background: transparent;
  border-radius: 2px;
  border: none;
}
.stm-ext-slider::-moz-range-thumb {
  width: 4px; height: 16px;
  border-radius: 2px;
  background: #fff;
  border: none;
  cursor: pointer;
  pointer-events: auto;
}
.stm-ext-filter-count {
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: .82rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* ── Modal sub-tabs ── */
.stm-sub-tabs-wrap { margin-bottom: 20px; }
.stm-sub-tabs {
  display: flex; gap: 2px;
  padding: 3px;
  background: var(--hover-subtle);
  border-radius: 8px;
  border: 1px solid var(--hover-subtle);
}
.stm-sub-tab {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 1.0rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--ease);
}
.stm-sub-tab:hover { color: var(--text); background: var(--divider-soft); }
.stm-sub-tab.active {
  background: var(--blue-dim);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

/* ── Modal panes ── */
.stm-pane { display: none; }
.stm-pane.active { display: block; }

/* ── Grid-based data table ── */
.stm-grid-wrap {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--surface-raised);
  border-radius: 10px;
  background: var(--surface-veil);
}
.stm-grid-wrap::-webkit-scrollbar { width: 5px; }
.stm-grid-wrap::-webkit-scrollbar-track { background: transparent; }
.stm-grid-wrap::-webkit-scrollbar-thumb { background: var(--surface-border-hi); border-radius: 3px; }

.stm-grid {
  display: grid;
}
.stm-grid-8 { grid-template-columns: 46px 110px repeat(6, 1fr); }
.stm-grid-7 { grid-template-columns: 46px 110px repeat(5, 1fr); }

/* Header cells */
.stm-gh {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  padding: 10px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  text-align: right;
  cursor: pointer;
  user-select: none;
  transition: color .12s;
  white-space: nowrap;
}
.stm-gh:hover { color: var(--blue); }
.stm-gh.sort-asc::after  { content: ' \u25B2'; font-size: .82rem; color: var(--blue); }
.stm-gh.sort-desc::after { content: ' \u25BC'; font-size: .82rem; color: var(--blue); }
.stm-gh.gc { text-align: center; }
.stm-gh.gl { text-align: left; }

/* Data cells */
.stm-gd {
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 0.94rem;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--hover-subtle);
}

/* Row wrapper for hover + click */
.stm-grow {
  display: contents;
  cursor: pointer;
}
.stm-grow:hover > .stm-gd { background: var(--blue-dim); }
.stm-grow:nth-child(even) > .stm-gd { background: var(--surface-veil); }
.stm-grow:hover > .stm-gd { background: var(--blue-dim); }

/* Column type overrides */
.stm-gd.gc {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}
.stm-gd.gl {
  text-align: left;
  color: var(--text-soft);
  font-family: var(--font-ui);
  font-size: 0.96rem;
  font-weight: 500;
}

/* Top 3 rank highlight */
.stm-grow:nth-child(-n+3) > .stm-gd.gc {
  color: var(--amber);
  font-weight: 700;
}

/* Legacy compat */
.stm-summary { display: flex; gap: 12px; margin-bottom: 20px; }
.stm-summary .stm-card { flex: 1; }
.stm-dist { margin-bottom: 20px; }
.stm-dist-title {
  font-size: 0.91rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── AI Tabs (Insights / Help) ─────────────────────────────────── */
.stm-ai-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 18px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stm-ai-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: .04em;
  transition: var(--ease);
  margin-bottom: -1px;
}
.stm-ai-tab:hover { color: var(--text); background: rgba(255,255,255,var(--hover-subtle)); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.stm-ai-tab.active { color: #fff; border-bottom-color: #fff; background: transparent; border-radius: 0; }

.stm-ai-pane { display: none; flex: 1; flex-direction: column; min-height: 0; }
.stm-ai-pane.active { display: flex; }

/* ── Help pane ─────────────────────────────────────────────────── */
.stm-help-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.stm-help-scroll::-webkit-scrollbar { width: 5px; }
.stm-help-scroll::-webkit-scrollbar-track { background: transparent; }
.stm-help-scroll::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }
.stm-help-content {
  padding: 18px;
  font-family: var(--font-ui);
  font-size: .93rem;
  line-height: 1.65;
  color: var(--text);
}
.stm-help-content .stm-help-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 10px;
  letter-spacing: -.005em;
}
.stm-help-content .stm-help-section { margin-bottom: 14px; }
.stm-help-content .stm-help-section:last-child { margin-bottom: 0; }
.stm-help-content .stm-help-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
  display: block;
}
.stm-help-content p { margin: 0 0 10px; }
.stm-help-content p:last-child { margin-bottom: 0; }
.stm-help-content strong { color: var(--text-bright); }
.stm-help-content code {
  background: var(--surface-veil);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .88rem;
  color: var(--blue);
}
.stm-help-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-veil);
  border-left: 2px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 14px;
  font-size: .9rem;
  line-height: 1.5;
}
.stm-help-tip-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.stm-help-tip-strong {
  background: linear-gradient(135deg, rgba(167,139,250,.12), rgba(125,211,252,.06));
  border-left-color: #a78bfa;
  border-left-width: 3px;
  padding: 12px 14px;
}
.stm-help-tip-strong strong {
  display: inline-block;
  color: #d8b4fe;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}

/* ── Direction trio row (3 cards aligned to hero, internal titles) ── */
.stm-direction-trio { margin-top: 12px; align-items: stretch; }
.stm-direction-card {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  text-align: left;
}
.stm-direction-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--surface-raised);
}
.stm-direction-card-head .stm-card-label {
  margin: 0;
  flex: 1;
  text-align: left;
}
.stm-direction-card-head .stm-section-badge {
  font-size: .72rem;
  font-weight: 600;
  color: var(--blue);
  background: rgba(77,166,255,.12);
  padding: 2px 6px;
  border-radius: 3px;
}
.stm-direction-card .stm-direction-donut-mini {
  position: relative;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stm-direction-card .stm-direction-donut-mini canvas {
  max-width: 100% !important;
  max-height: 100% !important;
}
.stm-direction-card .stm-streak-stats {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0;
}
.stm-direction-card .stm-streak-stats .stm-streak-row {
  padding: 6px 12px;
}
.stm-direction-card .stm-canvas-wrap.stm-chart-hbar {
  height: 150px !important;
  min-height: 0;
  padding: 8px 10px;
}

/* ── Returns KPI cards header (title + help) ──────────────────── */
.stm-ret-cards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 8px;
  gap: 8px;
}
.stm-ret-cards-title {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .01em;
}

/* ── Chart "?" help button ─────────────────────────────────────── */
.stm-chart-inner-title-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}
.stm-chart-inner-title-wrap .stm-chart-inner-title { padding: 0; }
/* When the wrap contains a section-title (left-aligned with underline), move the
   underline+spacing to the wrap so the "?" button stays vertically centered with text */
.stm-chart-inner-title-wrap:has(.stm-section-title) {
  justify-content: flex-start;
  padding: 0 0 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--surface-raised);
}
.stm-chart-inner-title-wrap .stm-section-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  flex: 1;
}
.stm-chart-help-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-border);
  background: var(--surface-veil);
  color: var(--text-muted);
  border-radius: 50%;
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: var(--ease);
}
.stm-chart-help-btn:hover {
  background: rgba(167,139,250,.18);
  border-color: rgba(167,139,250,.6);
  color: #d8b4fe;
}
.stm-chart-help-btn.active {
  background: rgba(167,139,250,.28);
  border-color: rgba(167,139,250,.8);
  color: #f3e8ff;
  box-shadow: 0 0 0 3px rgba(167,139,250,.12);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stm-insight-area { width: 340px; min-width: 300px; }
}
@media (max-width: 900px) {
  .stm-panel { flex-direction: column; }
  .stm-left-nav {
    width: auto; flex-direction: row; gap: 2px;
    padding: 8px 12px; border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .stm-main { flex-direction: column; }
  .stm-metric-area { border-right: none; border-bottom: 1px solid var(--border); }
  .stm-insight-area { width: auto; max-width: none; max-height: 40vh; min-width: auto; }
}
@media (max-width: 700px) {
  .stm-cards-5 { grid-template-columns: repeat(3, 1fr); }
  .stm-cards-4 { grid-template-columns: repeat(2, 1fr); }
  .stm-cards-3 { grid-template-columns: repeat(2, 1fr); }
  .stm-two-col { grid-template-columns: 1fr; }
  .stm-panel { width: 100vw; height: 100vh; }
  .stm-body { padding: 14px 16px; }
  .stm-chart-hist, .stm-canvas-tall { height: 280px; min-height: 280px; }
  .stm-chart-spark { height: 220px; }
  .stm-header-controls { gap: 8px; }
  .stm-header-top { padding: 10px 14px; gap: 10px; }
}

