/* ═══════════════════════════════════════════════════════
   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: var(--card); /* dark: #161923 — in light theme diventa bianco (token) */
  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;
}

/* Extreme Bars: tinta riga per direzione della barra (bull = verde, bear = rosso).
   .stm-grow è display:contents → si colorano le celle figlie, non la riga. Queste
   regole seguono lo zebra (stessa specificità) così vincono per source order. */
.stm-grow.st-ext-bull > .stm-gd { background: rgba(38,217,127,.08); }
.stm-grow.st-ext-bear > .stm-gd { background: rgba(240,80,110,.08); }
.stm-grow.st-ext-bull:hover > .stm-gd { background: rgba(38,217,127,.16); }
.stm-grow.st-ext-bear:hover > .stm-gd { background: rgba(240,80,110,.16); }
.stm-grow.st-ext-bull > .stm-gd:last-child { color: var(--green); font-weight: 600; }
.stm-grow.st-ext-bear > .stm-gd:last-child { color: var(--red); font-weight: 600; }

/* 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; }
}



/* ════════════════════════════════════════════════════════════════════
   STATISTICS · AI REPORT — workspace a capitoli (STAGE 2)
   Classi ws-* + helper (stm-ins-ref, stm-row-hl, stm-rpt*, stm-hl-flash,
   stm-yr-hero*) portate dal mockup. Viola hardcoded tokenizzato (var(--purple)
   / color-mix) per coerenza coi 3 temi.
   ════════════════════════════════════════════════════════════════════ */
:root { --ws-help-w: 430px; }
.ws-frame { display: flex; width: 100%; height: 100%; min-width: 0; }
.ws-nav {
  width: 248px; flex: 0 0 248px; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  font-family: var(--font-ui); overflow-y: auto;
}
.ws-nav-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
/* Close prominente, fisso in alto a DESTRA. Resta visibile sia con drawer
   chiuso (right:16px) sia aperto (si sposta a sinistra del drawer di --ws-help-w). */
.ws-close-btn {
  position: fixed; top: 14px; right: 16px; z-index: 100050;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px 8px 12px;
  font-family: var(--font-ui); font-size: .95rem; font-weight: 600; line-height: 1;
  color: var(--text-bright);
  background: color-mix(in srgb, var(--purple) 18%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--purple) 45%, transparent);
  border-radius: var(--radius-sm); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  transition: background var(--ease), border-color var(--ease), right .28s var(--ease);
}
.ws-close-btn:hover { background: color-mix(in srgb, var(--purple) 30%, var(--panel)); border-color: var(--purple); }
.ws-close-btn svg { flex: 0 0 15px; }
.stm-overlay.ws-help-shift .ws-close-btn { right: calc(var(--ws-help-w) + 16px); }
.ws-nav-title { font-size: 1.05rem; font-weight: 700; color: var(--text-bright); display: flex; align-items: center; gap: 8px; }
.ws-nav-sym { font-size: .85rem; color: var(--text-dim); margin-top: 2px; }
.ws-nav-search {
  margin: 10px 12px; padding: 7px 10px; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-hi); border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: .88rem; cursor: pointer; background: var(--surface-veil);
}
.ws-nav-search:hover { background: var(--hover-subtle); }
.ws-nav-search kbd {
  margin-left: auto; font-family: var(--font-ui); font-size: .74rem; font-weight: 600;
  border: 1px solid var(--border-hi); border-radius: 4px; padding: 1px 5px; color: var(--text-muted);
}
.ws-nav-body { flex: 1; padding: 6px 8px 12px; }
.ws-nav-group { margin-top: 14px; }
.ws-nav-group-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 10px 5px;
}
.ws-nav-group-label-other { color: var(--purple); }
.ws-nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 12px; border: none; background: transparent; cursor: pointer;
  border-radius: var(--radius-sm); font-family: var(--font-ui);
  font-size: .92rem; font-weight: 500; color: var(--text-dim); text-align: left;
  position: relative; transition: background var(--ease), color var(--ease);
}
.ws-nav-item:hover { background: var(--hover-subtle); color: var(--text); }
.ws-nav-item.active { color: var(--text-bright); font-weight: 600; }
.ws-nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 5px; bottom: 5px; width: 2.5px;
  background: var(--text-bright); border-radius: 2px;
}
.ws-nav-num {
  flex: 0 0 22px; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.ws-nav-item.active .ws-nav-num { color: var(--text-bright); }
.ws-nav-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.ws-nav-report-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--purple) 35%, transparent); border-radius: var(--radius-sm);
  background: linear-gradient(120deg, color-mix(in srgb, var(--purple) 10%, transparent), transparent);
  font-family: var(--font-ui); font-size: .9rem; font-weight: 600; color: var(--text-bright);
  cursor: pointer; transition: background var(--ease);
}
.ws-nav-report-btn:hover { background: color-mix(in srgb, var(--purple) 16%, transparent); }
.ws-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-scroll { flex: 1; overflow-y: auto; }
.ws-page { max-width: 1280px; margin: 0 auto; padding: 22px 26px 40px; }
.ws-report { max-width: 1020px; margin: 0 auto; }
.ws-view-label {
  display: flex; align-items: center; gap: 9px; margin: 32px 0 10px;
  font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
.ws-view-label::before { content: ""; width: 14px; height: 1.5px; background: currentColor; opacity: .55; }
.ws-view-help {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-hi);
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-family: var(--font-ui); font-size: .72rem; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--ease), color var(--ease);
}
.ws-view-help:hover { background: var(--hover-medium); color: var(--text-bright); }
.ws-ov-head { padding: 6px 0 4px; }
.ws-ov-titlerow { display: flex; align-items: center; gap: 11px; }
.ws-ov-title { font-size: 1.7rem; font-weight: 700; color: var(--text-bright); line-height: 1.15; letter-spacing: .01em; }
.ws-ov-sub { font-size: 1.05rem; color: var(--text-dim); margin-top: 9px; max-width: 760px; line-height: 1.5; }
.ws-intro { max-width: 780px; margin-top: 6px; }
.ws-intro .stm-ins-prose { font-size: .98rem; line-height: 1.6; margin-bottom: 10px; }
.ws-intro kbd {
  font-family: var(--font-ui); font-size: .76rem; font-weight: 600; vertical-align: 1px;
  border: 1px solid var(--border-hi); border-radius: 4px; padding: 1px 5px; color: var(--text-muted);
}
.ws-tool-head { margin-bottom: 14px; }
.ws-tool-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ws-tool-ico { font-size: 1.15rem; opacity: .8; }
.ws-tool-title { font-size: 1.1rem; font-weight: 600; color: var(--text-dim); line-height: 1.15; letter-spacing: .01em; }
.ws-tool-cat {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border-hi); border-radius: 999px; padding: 1px 9px;
}
.ws-tool-hot {
  font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  color: var(--purple); background: color-mix(in srgb, var(--purple) 14%, transparent); border-radius: 999px; padding: 1px 8px;
}
.ws-tool-question { font-size: 1.55rem; font-weight: 700; color: var(--text-bright); line-height: 1.25; margin-top: 8px; max-width: 900px; }
.ws-tool-sample { font-size: .9rem; font-weight: 500; color: var(--text-dim); margin-top: 7px; }
.ws-tool-sample b { color: var(--text); font-weight: 600; }
.ws-ai-note { margin: 18px 0 24px; }
.ws-ai-note .stm-ins-prose { margin: 0 0 11px; font-size: .98rem; line-height: 1.6; }
.ws-ai-note .stm-ins-prose:last-child { margin-bottom: 0; }
.ws-ai-note .stm-ins-metrics { margin-bottom: 12px; }
.ws-fig { margin-bottom: 8px; }
.ws-fig-cap { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: 8px 2px 0; text-align: center; }
.ws-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 12px; }
.ws-ctrl-group { display: flex; align-items: center; gap: 7px; }
.ws-ctrl-label { font-size: .84rem; font-weight: 600; color: var(--text-dim); }
.ws-deep { margin-top: 30px; border-top: 1px solid var(--border); padding-top: 16px; }
.ws-deep-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 12px;
}
.ws-deep-title::before { content: ""; width: 16px; height: 1.5px; background: currentColor; opacity: .55; }
.ws-dd-label {
  font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--purple); margin: 14px 0 5px;
}
.ws-dd-label:first-of-type { margin-top: 0; }
.ws-deep .stm-ins-prose { max-width: 900px; }
.ws-deep-links { margin-top: 16px; }
.ws-deep-links a {
  display: inline-block; font-size: .9rem; font-weight: 600; color: var(--purple);
  cursor: pointer; margin-right: 18px; text-decoration: none;
}
.ws-deep-links a:hover { text-decoration: underline; }
.ws-chip {
  display: inline-block; margin-left: 8px; padding: 2px 9px;
  border-radius: 999px; font-size: .82rem; font-weight: 700;
  letter-spacing: .03em; vertical-align: 1px; white-space: nowrap;
}
.ws-stub {
  margin-top: 8px; padding: 26px; text-align: center;
  border: 1px dashed var(--border-hi); border-radius: var(--radius-md); color: var(--text-dim);
  font-size: .95rem;
}
.ws-palette-overlay {
  display: none; position: fixed; inset: 0; z-index: 100000;
  background: rgba(0,0,0,.35); backdrop-filter: blur(2px);
}
.ws-palette-overlay.open { display: block; }
.ws-palette {
  width: 560px; max-width: 92vw; margin: 12vh auto 0;
  background: var(--panel); border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg); box-shadow: var(--overlay-shadow); overflow: hidden;
  font-family: var(--font-ui);
}
.ws-palette input {
  width: 100%; padding: 14px 16px; border: none; outline: none;
  background: transparent; color: var(--text-bright);
  font-family: var(--font-ui); font-size: 1rem; border-bottom: 1px solid var(--border);
}
.ws-palette-results { max-height: 320px; overflow-y: auto; padding: 6px; }
.ws-palette-item {
  display: flex; align-items: baseline; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); cursor: pointer;
}
.ws-palette-item:hover, .ws-palette-item.sel { background: color-mix(in srgb, var(--purple) 12%, transparent); }
.ws-palette-item .nm { font-size: .95rem; font-weight: 700; color: var(--text-bright); white-space: nowrap; }
.ws-palette-item .qq { font-size: .85rem; color: var(--text-dim); }
.ws-palette-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: .9rem; }
.stm-ins-ref {
  color: var(--purple); font-weight: 600; cursor: pointer;
  border-bottom: 1px dashed color-mix(in srgb, var(--purple) 65%, transparent);
  border-radius: 3px; padding: 0 2px; margin: 0 -2px;
  transition: background var(--ease), color var(--ease);
}
:root:not([data-theme="light"]) .stm-ins-ref { color: var(--purple); }
.stm-ins-ref:hover { background: color-mix(in srgb, var(--purple) 16%, transparent); border-bottom-style: solid; }
.stm-hl-flash { animation: sectionFlash 1.4s ease-out 1; border-radius: var(--radius-md); }
.stm-grow.stm-row-hl { background: color-mix(in srgb, var(--purple) 18%, transparent) !important; }
.stm-rpt-yearpanel {
  margin: 12px 0 0; padding: 0 16px;
  max-height: 0; overflow: hidden; opacity: 0;
  border-radius: var(--radius-md);
  background: var(--surface-veil);
  border: 1px solid transparent;
  transition: max-height .35s var(--ease), opacity .25s var(--ease), padding .35s var(--ease), border-color .25s var(--ease);
}
.stm-rpt-yearpanel.open { max-height: 1100px; opacity: 1; padding: 16px; border-color: color-mix(in srgb, var(--purple) 30%, transparent); }
.stm-rpt-yearpanel-close {
  float: right; width: 26px; height: 26px; font-size: 1.2rem; line-height: 1;
  border-radius: var(--radius-sm); border: none; background: transparent;
  color: var(--text-dim); cursor: pointer;
}
.stm-rpt-yearpanel-close:hover { background: var(--hover-medium); color: var(--text-bright); }
.stm-yr-hero { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 4px; }
.stm-yr-hero-year { font-size: 2rem; font-weight: 700; color: var(--text-bright); }
.stm-yr-hero-ret { font-size: 1.5rem; font-weight: 700; }
.stm-yr-hero-rank { font-size: .9rem; color: var(--text-dim); margin-bottom: 8px; }
.ws-leg-label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); margin: 12px 0 5px;
}
.ws-leg-label::before { content: ""; width: 14px; height: 1.5px; background: currentColor; opacity: .55; }
.stm-rpt { font-family: var(--font-ui); max-width: 1080px; margin: 0 auto; }
.stm-rpt-chapter { padding: 24px 0 28px; border-bottom: 1px solid var(--border); }
.stm-rpt-chapter:last-child { border-bottom: none; }
.stm-rpt-chapter-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.stm-rpt-chapter-num { font-size: 1.5rem; font-weight: 700; color: var(--purple); line-height: 1.1; }
.stm-rpt-chapter-title { font-size: 1.4rem; font-weight: 700; color: var(--text-bright); line-height: 1.15; }
.stm-rpt-chapter-sub { font-size: .85rem; font-weight: 500; color: var(--text-muted); margin: 0 0 16px; }
.stm-rpt-leg { margin: 14px 0; }
.stm-rpt-leg-label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 6px;
}
.stm-rpt-leg-label::before { content: ""; width: 14px; height: 1.5px; background: currentColor; opacity: .55; }
.stm-rpt-leg-today .stm-rpt-leg-label { color: var(--purple); }
.stm-rpt-leg-today {
  border-left: 2px solid color-mix(in srgb, var(--purple) 45%, transparent);
  padding: 4px 0 4px 14px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--purple) 6%, transparent), transparent 60%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.stm-rpt-verdict {
  margin: 20px 0; padding: 16px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(120deg, color-mix(in srgb, var(--purple) 10%, transparent), color-mix(in srgb, var(--purple) 3%, transparent) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--purple) 28%, transparent);
}
.stm-rpt-verdict-label {
  display: flex; align-items: center; gap: 8px;
  font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--purple); margin-bottom: 9px;
}
.stm-rpt-verdict-label svg { width: 16px; height: 16px; }
.stm-rpt-verdict-label svg path { fill: var(--purple); }
.stm-rpt-verdict .stm-ins-prose { font-size: 1rem; margin: 0 0 8px; }
.stm-rpt-verdict .stm-ins-prose:last-child { margin-bottom: 0; }
.stm-rpt-fig { margin: 16px 0 4px; }
.stm-rpt-fig-cap { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin: 8px 2px 2px; text-align: center; }
.ws-substrip {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 10px 4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.ws-substrip-sym { font-size: .92rem; font-weight: 700; color: var(--text-bright); }
.ws-substrip-sym span { color: var(--text-dim); font-weight: 500; margin-left: 6px; }
.ws-chap { scroll-margin-top: 64px; padding: 26px 0 30px; border-bottom: 1px solid var(--border); }
.ws-chap:last-child { border-bottom: none; }
.ws-chap-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.ws-chap-num {
  flex: 0 0 auto; font-size: 1.35rem; font-weight: 700; line-height: 1;
  color: var(--text-muted); font-variant-numeric: tabular-nums; padding-top: 3px;
}
.ws-chap-head-main { min-width: 0; }
.ws-chap-titlerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ws-chap-title { font-size: 1.35rem; font-weight: 700; color: var(--text-bright); line-height: 1.15; }
.ws-chap-q { font-size: 1.02rem; font-weight: 500; color: var(--text-dim); margin-top: 5px; max-width: 880px; line-height: 1.4; }
.ws-chap-intro .ws-chap-title { font-size: 1.55rem; }
.ws-chart-card {
  margin: 18px 0 6px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-veil); overflow: hidden;
}
.ws-chart-card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 14px; border-bottom: 1px solid var(--border);
}
.ws-chart-card-title { font-size: .82rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.ws-chart-card-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ws-chart-expand-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border: 1px solid var(--border-hi); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600; transition: background var(--ease), color var(--ease);
}
.ws-chart-expand-btn:hover { background: var(--hover-subtle); color: var(--text-bright); }
.ws-chart-expand-btn svg { width: 14px; height: 14px; }
.ws-chart-body { padding: 14px; }
.ws-chart-body .ws-fig-cap { margin-top: 12px; }
.ws-chart-body .stm-canvas-wrap.stm-chart-hist { height: 260px; }
.ws-chart-body .stm-ret-lwc-wrap { height: 260px; }
.ws-chart-card-head .stm-ret-custom-input { width: 64px; }
.ws-chart-modal {
  display: none; position: fixed; inset: 0; z-index: 100001;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
}
.ws-chart-modal.open { display: flex; }
.ws-chart-modal-inner {
  margin: auto; width: min(1240px, 94vw); height: min(86vh, 860px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg); box-shadow: var(--overlay-shadow); overflow: hidden;
}
.ws-chart-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.ws-chart-modal-title { font-size: 1rem; font-weight: 700; color: var(--text-bright); }
.ws-chart-modal-close {
  margin-left: auto; width: 30px; height: 30px; font-size: 1.3rem; line-height: 1;
  border: none; background: transparent; color: var(--text-dim);
  border-radius: var(--radius-sm); cursor: pointer;
}
.ws-chart-modal-close:hover { background: var(--hover-medium); color: var(--text-bright); }
.ws-chart-modal-body { flex: 1; min-height: 0; padding: 16px; display: flex; overflow: auto; }
.ws-chart-modal-body > * { flex: 1; min-width: 0; }
.ws-help-btn { margin-left: 8px; vertical-align: middle; }
.stm-overlay.ws-help-shift .stm-panel { padding-right: var(--ws-help-w); }
.ws-help-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: var(--ws-help-w); z-index: 100003;
  background: var(--panel); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.18);
  display: flex; flex-direction: column; font-family: var(--font-ui);
  transform: translateX(100%); transition: transform .28s var(--ease);
}
.ws-help-drawer.open { transform: translateX(0); }
.ws-help-head { display: flex; align-items: flex-start; gap: 11px; padding: 16px 16px 14px; border-bottom: 1px solid var(--border); }
.ws-help-head-text { min-width: 0; flex: 1; }
.ws-help-title { font-size: 1.08rem; font-weight: 700; color: var(--text-bright); line-height: 1.2; }
.ws-help-sub { font-size: .85rem; color: var(--text-dim); margin-top: 3px; line-height: 1.35; }
.ws-help-close { flex: 0 0 auto; width: 28px; height: 28px; font-size: 1.3rem; line-height: 1; border: none; background: transparent; color: var(--text-dim); border-radius: var(--radius-sm); cursor: pointer; }
.ws-help-close:hover { background: var(--hover-medium); color: var(--text-bright); }
.ws-help-body { flex: 1; overflow-y: auto; padding: 18px 18px 30px; }
.ws-help-section { margin-bottom: 18px; }
.ws-help-section:last-child { margin-bottom: 0; }
.ws-help-label { display: block; font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--purple); margin-bottom: 6px; }
.ws-help-body .stm-ins-prose { font-size: .96rem; line-height: 1.58; color: var(--text); }
.ws-help-collapse {
  position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 52px; border: 1px solid var(--border); border-right: none;
  border-radius: 9px 0 0 9px; background: var(--panel); color: var(--text-dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; line-height: 1; box-shadow: -4px 0 12px rgba(0,0,0,.12);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease), color var(--ease), background var(--ease);
}
.ws-help-collapse:hover { color: var(--text-bright); background: var(--hover-medium); }
body.ws-scrolled .ws-help-drawer.open .ws-help-collapse { opacity: 1; pointer-events: auto; }
.ws-help-reopen {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 100002;
  width: 26px; height: 56px; border: 1px solid var(--border); border-right: none;
  border-radius: 10px 0 0 10px; background: var(--panel); color: var(--text-dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; line-height: 1; box-shadow: -4px 0 12px rgba(0,0,0,.14);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease), color var(--ease), background var(--ease);
}
.ws-help-reopen:hover { color: var(--text-bright); background: var(--hover-medium); }
body.ws-help-closed .ws-help-reopen { opacity: 1; pointer-events: auto; }
.ws-deep-extra { margin-top: 6px; }
.ws-deep-links-lbl { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-right: 4px; }
.ws-yr-cards { margin-top: 10px; }
.ws-yr-narrative { margin-top: 6px; }
.ws-chap .stm-insight-content .stm-section:first-child { margin-top: 4px; }
.ws-yr-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.ws-yr-cta-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 1px solid color-mix(in srgb, var(--purple) 35%, transparent); border-radius: var(--radius-md);
  background: linear-gradient(120deg, color-mix(in srgb, var(--purple) 10%, transparent), transparent);
  font-family: var(--font-ui); font-size: .92rem; font-weight: 600; color: var(--text-bright);
  cursor: pointer; transition: background var(--ease);
}
.ws-yr-cta-btn:hover { background: color-mix(in srgb, var(--purple) 16%, transparent); }
.ws-yr-cta-btn svg { width: 16px; height: 16px; opacity: .85; flex: 0 0 16px; }
.ws-yr-modal .ws-chart-modal-inner { width: min(1180px, 95vw); height: min(88vh, 900px); }
.ws-yr-modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; display: block; }
.ws-yr-modal-body .yr-root { width: 100%; }
.ws-range-ctrls {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 12px 16px;
  background: var(--card);                 /* più chiaro del fondo: header evidente */
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.55);
}
.ws-range-ctrls .stm-range-mode-switch { margin: 0; }
.ws-range-ctrls .stm-compute-wrap { margin: 0; }
.ws-range-ctrls .st-compute-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 6px;
  font-family: var(--font-ui); font-size: .92rem; color: var(--text); line-height: 1.5;
}
.ws-range-main { margin-bottom: 6px; }
.ws-range-main .stm-canvas-wrap.stm-chart-hist { height: 360px; }
.ws-range-main .stm-chart-inner-title-wrap { padding: 12px 14px 0; }
.ws-range-deep { padding: 0; }
.ws-range-deep .stm-ins-section { padding: 18px 0 20px; }
.ws-range-deep .stm-ins-section:first-child { padding-top: 4px; }
.ws-range-deep .stm-ins-num { display: none; }
.ws-bp-howto { margin-top: 14px; font-size: .9rem; line-height: 1.55; color: var(--text-dim); }
.ws-bp-howto b { color: var(--text); font-weight: 600; }
.ws-range-boxplot-top { margin: 4px 0 22px; }
.ws-range-boxplot-top .ws-leg-label { margin-top: 0; }
.ws-donut-wrap { position: relative; width: 150px; height: 150px; margin: 4px auto 0; }
.ws-donut-wrap canvas { display: block; }
.ws-donut-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.ws-donut-pct { font-family: var(--font-ui); font-size: 1.85rem; font-weight: 700; line-height: 1; }
.ws-donut-pct.bull { color: var(--green); }
.ws-donut-pct.bear { color: var(--red); }
.ws-donut-side { font-size: .72rem; font-weight: 700; letter-spacing: .14em; color: var(--text-dim); margin-top: 4px; }
.ws-donut-tip { text-align: center; font-size: .82rem; font-weight: 600; margin-top: 10px; }
.ws-donut-tip .pos { color: var(--green); }
.ws-donut-tip .neg { color: var(--red); }
.ws-donut-tip .sep { color: var(--text-muted); margin: 0 7px; }

/* keyframes workspace */
@keyframes brickPulse {
  0%,100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 35%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--purple) 15%, transparent); }
}
@keyframes sectionFlash {
  0% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--purple) 70%, transparent), 0 0 0 3px color-mix(in srgb, var(--purple) 25%, transparent); }
  100% { box-shadow: inset 0 0 0 2px transparent, 0 0 0 3px transparent; }
}

/* ════════════════════════════════════════════════════════════════════
   STATISTICS SIDEBAR — report a capitoli in versione COMPATTA (narrow)
   Lo stesso documento dell'overlay fullscreen, montato nel pannello laterale
   ridimensionabile. Le griglie collassano via @container (larghezza del pannello),
   così l'overlay (largo) resta multi-colonna senza essere toccato.
   ════════════════════════════════════════════════════════════════════ */
.st-side-report-wrap { display: flex; flex-direction: column; min-height: 0; }
/* header sticky: titolo + bottone Espandi sempre raggiungibili durante lo scroll */
.st-side-report-head {
  position: sticky; top: 0; z-index: 8;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0 10px; margin: 0 0 6px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-hi);
}
.st-side-report-head .st-title { font-size: 1.05rem; }
.st-side-expand-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: var(--radius-sm);
  background: var(--hover-subtle, rgba(255,255,255,.05));
  border: 1px solid var(--border-hi);
  color: var(--text-bright); cursor: pointer;
  font-family: var(--font-ui); font-size: .85rem; font-weight: 600;
  transition: background var(--ease);
}
.st-side-expand-btn:hover { background: var(--hover-medium, rgba(255,255,255,.08)); }
.st-side-expand-btn svg { width: 12px; height: 12px; }

/* contenitore = contesto per le container-query */
.ws-report-narrow { container-type: inline-size; }
/* niente max-width/centratura/padding da overlay nel pannello */
.ws-report-narrow .ws-report { max-width: none; margin: 0; }
.ws-report-narrow .ws-page { max-width: none; margin: 0; padding: 0; }
.ws-report-narrow .ws-chap { padding-left: 0; padding-right: 0; }
/* la barra range-ctrls in overlay è sticky: nel pannello starebbe sotto l'header
   sticky → la rendo statica per evitare sovrapposizioni */
/* header dei selettori (High-Low/Open-Close + compute row): sticky come nell'overlay,
   ma sotto l'header del pannello (.st-side-report-head, ~46px) per non sovrapporsi */
.ws-report-narrow .ws-range-ctrls {
  position: sticky; top: 46px; z-index: 6;
  box-shadow: 0 6px 14px -10px rgba(0, 0, 0, .45);
}
/* l'area insight (se larga) si adatta */
.ws-report-narrow .stm-insight-area { width: auto; max-width: none; min-width: 0; }

/* ── Selettori Period/History: DROPDOWN quando il pannello è stretto, PILL quando c'è spazio ──
   Il <select> è nascosto di default (l'overlay, non .ws-report-narrow, usa i pill).
   Nel pannello: di default si vede il dropdown a tutta larghezza; i pill ricompaiono
   solo se il pannello viene allargato oltre ~480px. */
.stm-ret-select {
  display: none;
  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,.12);
  border-radius: var(--radius-sm);
  padding: 8px 32px 8px 12px;
  font-family: var(--font-ui); font-size: .92rem; font-weight: 700;
  cursor: pointer;
  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 11px center;
}
.stm-ret-select option { background: var(--card, #181a23); color: var(--text); font-weight: 500; }

/* Period e History AFFIANCATI sulla stessa riga (ognuno 50%); la label resta
   sopra il proprio dropdown. Wrap a colonna solo se il pannello è davvero stretto. */
.ws-report-narrow .ws-controls { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.ws-report-narrow .ws-ctrl-group { flex-direction: column; align-items: stretch; gap: 5px; flex: 1 1 140px; min-width: 0; width: auto; }
.ws-report-narrow .ws-ctrl-label { align-self: flex-start; }
/* Nel pannello SEMPRE dropdown (a qualsiasi larghezza, anche al 50%): pill nascosti,
   <select> a tutta larghezza. I pill restano solo nell'overlay fullscreen (non .ws-report-narrow). */
.ws-report-narrow .stm-ret-pills { display: none; }
.ws-report-narrow .stm-ret-select { display: block; width: 100%; }

/* ── collasso colonne in base alla LARGHEZZA DEL PANNELLO ──
   Soglie tarate sul pannello reale (~360-460px). A 460px le griglie fitte
   (3/4/5/6 col) collassano già a 2 colonne; sotto 360px tutto a 1 colonna. */
@container (max-width: 460px) {
  .ws-report-narrow .stm-cards-3,
  .ws-report-narrow .stm-cards-4,
  .ws-report-narrow .stm-cards-5,
  .ws-report-narrow .stm-cards-6,
  .ws-report-narrow .stm-cards-8 { grid-template-columns: repeat(2, 1fr); }
  .ws-report-narrow .stm-two-col,
  .ws-report-narrow .stm-two-col-streak,
  .ws-report-narrow .stm-direction-trio { grid-template-columns: 1fr; }
  /* chart un po' più bassi nel pannello stretto */
  .ws-report-narrow .ws-range-main .stm-canvas-wrap.stm-chart-hist { height: 280px; }
}
@container (max-width: 340px) {
  .ws-report-narrow .stm-cards-3,
  .ws-report-narrow .stm-cards-4,
  .ws-report-narrow .stm-cards-5,
  .ws-report-narrow .stm-cards-6,
  .ws-report-narrow .stm-cards-8 { grid-template-columns: 1fr; }
  .ws-report-narrow .stm-ret-period-btn,
  .ws-report-narrow .stm-ret-lb-btn { padding: 6px 6px; font-size: .82rem; }
}

/* ── Tabelle Extremes a colonne fisse → overflow orizzontale nel pannello ──
   .stm-grid usa grid-template-columns fisse (46px 110px repeat(...)) che a pannello
   stretto sforerebbero. Lascio lo scroll orizzontale sul wrapper così l'allineamento
   testata/righe resta intatto, e impongo una min-width al grid pari alla somma colonne. */
.ws-report-narrow .stm-grid-wrap { overflow-x: auto; }
.ws-report-narrow .stm-grid-7,
.ws-report-narrow .stm-grid-8 { min-width: 520px; }
.ws-report-narrow .stm-grid-ret-fwd { min-width: 480px; }

/* ── Switch range-mode + compute row: vanno a capo, mai tagliati ── */
.ws-report-narrow .stm-range-mode-switch { width: 100%; }
.ws-report-narrow .stm-range-mode-btn { flex: 1 1 0; min-width: 0; }
.ws-report-narrow .st-compute-row { flex-wrap: wrap; }
.ws-report-narrow .st-compute-select { max-width: 100%; }

/* ── Forward summary + qualunque riga di card/badge: wrap garantito ── */
.ws-report-narrow .stm-ret-fwd-summary { flex-wrap: wrap; }
.ws-report-narrow .stm-ret-fwd-card { flex: 1 1 80px; }

/* ── Yearly: niente overflow su card e CTA ── */
.ws-report-narrow .ws-yr-cta { flex-wrap: wrap; }
.ws-report-narrow .ws-yr-cta-btn { flex: 1 1 auto; justify-content: center; }

/* ── Card predittori (.yr-ins-card): 1 colonna nel pannello + font che si RIDUCONO
   per stare dentro i margini. Ogni card è un container (container-type:inline-size):
   i font usano clamp(min, N cqi, max) dove 1cqi = 1% della larghezza della card,
   quindi il numero grande si rimpicciolisce automaticamente quando la card si stringe,
   senza mai sforare i bordi. L'overlay (non .ws-report-narrow) resta invariato. */
.ws-report-narrow .yr-ins-grid { grid-template-columns: 1fr; }
.ws-report-narrow .yr-ins-card { container-type: inline-size; }
.ws-report-narrow .yr-ins-card .yr-ins-prob-num { font-size: clamp(1.6rem, 17cqi, 3.2rem); }
.ws-report-narrow .yr-ins-card.yr-ins-hero .yr-ins-prob-num { font-size: clamp(1.7rem, 18cqi, 3.6rem); }
.ws-report-narrow .yr-ins-card .yr-ins-period { font-size: clamp(1.05rem, 9.5cqi, 1.7rem); }
.ws-report-narrow .yr-ins-card.yr-ins-hero .yr-ins-period { font-size: clamp(1.1rem, 11cqi, 2rem); }
.ws-report-narrow .yr-ins-card .yr-ins-prob-num,
.ws-report-narrow .yr-ins-card .yr-ins-period,
.ws-report-narrow .yr-ins-card .yr-ins-question { overflow-wrap: anywhere; }
.ws-report-narrow .yr-ins-foot strong { font-size: clamp(.84rem, 4.6cqi, .95rem); }
.ws-report-narrow .yr-ins-foot-lbl { font-size: clamp(.74rem, 3.6cqi, .78rem); }

/* ── Bottone "Espandi" sotto il titolo AI · Statistical Report (solo pannello) ──
   Dorato e centrato. Emesso da pageOverview solo in modalità narrow. */
.ws-ov-expand-btn {
  display: flex; align-items: center; gap: 7px;
  width: fit-content; margin: 14px auto 2px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, rgba(201,162,79,.18), rgba(201,162,79,.06));
  border: 1px solid rgba(201,162,79,.55);
  color: #d8b56a;
  font-family: var(--font-ui); font-size: .9rem; font-weight: 700;
  cursor: pointer; transition: background var(--ease), border-color var(--ease);
}
.ws-ov-expand-btn:hover {
  background: linear-gradient(120deg, rgba(201,162,79,.28), rgba(201,162,79,.10));
  border-color: rgba(201,162,79,.85);
}
.ws-ov-expand-btn svg { stroke: currentColor; flex: 0 0 13px; }