/* ============================================================
   CapitalVerse — Global Theme: "Capital Universe Star Map"
   ============================================================
   Brand Narrative: "Explore the Capital Universe"
   Every asset is a star; brighter & bigger = better risk-adjusted return.
   Drill-down feels like zooming from galaxy → star system → single star.
   ============================================================ */

:root {
  /* ---- 背景 (slightly warmer deep space) ---- */
  --bg-primary: #0c0e18;
  --bg-secondary: #111826;
  --bg-surface: #161b22;
  --bg-hover: #1c2128;

  /* ---- 文字 ---- */
  --text-primary: rgba(255, 255, 255, 0.92);
  --text-secondary: rgba(255, 255, 255, 0.56);
  --text-muted: rgba(255, 255, 255, 0.28);

  /* ---- 资产类别色板（6 类） ---- */
  --color-equity: #4da6ff;
  --color-fixed-income: #9b7dff;
  --color-real-estate: #f59e42;
  --color-commodity: #ffd700;
  --color-alternative: #4ade80;
  --color-crypto: #f472b6;

  /* ---- 语义色 ---- */
  --color-positive: #4ade80;
  --color-warning: #facc15;
  --color-negative: #f87171;

  /* ---- 交互 ---- */
  --glow-strength: 0 0 12px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;

  /* ---- 尺寸 ---- */
  --nav-height: 52px;
  --panel-width: 340px;
  --border-radius: 8px;

  /* ---- 字体 ---- */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ============================================================
   Global Reset & Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  margin: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Top Navigation Bar
   ============================================================ */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  user-select: none;
}

/* Brand */
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-logo .logo-accent {
  background: linear-gradient(135deg, var(--color-equity), var(--color-fixed-income));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Breadcrumb (placeholder) */
#breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

/* Time Window (placeholder) */
#time-window {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   Main Layout
   ============================================================ */
#app {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--nav-height));
  margin-top: var(--nav-height);
  overflow: hidden;
}

/* Chart Container — fills all available space */
#chart-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Star Background Canvas — decorative bottom layer */
#star-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Nebula Fog Canvas — above star-bg, below Plotly chart */
#nebula-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Twinkle Animation Canvas — above nebula, below Plotly chart */
#twinkle-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

/* Financial Coordinate Grid — between nebula and twinkle */
#coord-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* Premium Node Canvas — above twinkle, below Plotly hit-area */
#node-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* Detail Panel — slides in from right */
#detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 50;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  overflow-y: auto;
  overflow-x: hidden;
}

#detail-panel.open {
  transform: translateX(0);
  opacity: 1;
}

/* ============================================================
   Detail Panel — Internal Components
   ============================================================ */

/* Header */
.dp-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.dp-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.dp-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.dp-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-right: 36px;
  line-height: 1.3;
}

.dp-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.dp-symbol {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.dp-class-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.dp-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.dp-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.dp-change {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.dp-change.positive { color: var(--color-positive); }
.dp-change.negative { color: var(--color-negative); }

/* ── Core Metrics 2×2 Grid ── */
.dp-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255, 255, 255, 0.04);
  margin: 0;
}

.dp-metric {
  padding: 12px 16px;
  background: rgba(13, 17, 23, 0.6);
}

.dp-metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.dp-metric-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  min-height: 27px;
}
.dp-metric-value.sharpe-good { color: var(--color-positive); }
.dp-metric-value.sharpe-ok   { color: var(--color-warning); }
.dp-metric-value.sharpe-bad  { color: var(--color-negative); }
.dp-metric-value.sharpe-na   { color: var(--text-muted); }

/* ── Skeleton Loader ── */
.dp-skeleton {
  width: 60%;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mini Sparkline ── */
.dp-spark-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dp-spark-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.dp-sparkline {
  width: 100%;
  height: 80px;
}

.dp-spark-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Additional Info ── */
.dp-info {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dp-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}

.dp-info-label {
  font-size: 12px;
  color: var(--text-muted);
}

.dp-info-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.dp-info-muted {
  color: var(--text-muted);
  font-size: 11px;
}

/* ── Data Source Badges ── */
.ds-badge {
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  white-space: nowrap;
  user-select: none;
  transition: opacity 0.2s;
}
.ds-badge:hover {
  opacity: 0.8;
}

/* ── P7: Data Freshness Indicator ── */
.dp-fresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dp-fresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dp-fresh-pulse {
  animation: dp-pulse 2s ease-in-out infinite;
}
@keyframes dp-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
.dp-fresh-txt {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Portfolio / Watchlist Quick Action Buttons ── */
.dp-quick-actions {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
}
.dp-qaction-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(96, 181, 255, 0.15);
  background: rgba(96, 181, 255, 0.04);
  color: #e0e6ed;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all 0.2s ease;
}
.dp-qaction-btn:hover {
  background: rgba(96, 181, 255, 0.12);
  border-color: rgba(96, 181, 255, 0.3);
}
.dp-qaction-btn.dp-qa-active {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
}

/* ── Explore Stocks Button ── */
.dp-actions {
  padding: 12px 16px;
}

.dp-explore-btn {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dp-explore-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* "Back to overview" variant */
.dp-back-btn {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}
.dp-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Error State ── */
.dp-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 12px;
}

.dp-error-text {
  color: var(--text-muted);
  font-size: 13px;
}

.dp-retry-btn {
  padding: 6px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dp-retry-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ============================================================
   Scrollbar Styling (for detail-panel)
   ============================================================ */
#detail-panel::-webkit-scrollbar {
  width: 4px;
}

#detail-panel::-webkit-scrollbar-track {
  background: transparent;
}

#detail-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

#detail-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   Breadcrumb Navigation
   ============================================================ */
.bc-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-size: 13px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.bc-link {
  background: transparent;
  color: var(--text-secondary);
}
.bc-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.bc-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
  cursor: default;
}

.bc-sep {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 2px;
  user-select: none;
}

.bc-back {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.bc-back:hover {
  background: var(--bg-hover);
}

/* ============================================================
   Time Window Selector
   ============================================================ */
.tw-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 2px;
}

.tw-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.tw-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.tw-active {
  background: rgba(255, 255, 255, 0.1) !important;
  color: var(--text-primary) !important;
}

/* ============================================================
   Sharpe Toggle Switch
   ============================================================ */
.sharpe-toggle-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.sharpe-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.sharpe-toggle-text {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.sharpe-switch {
  position: relative;
  width: 32px;
  height: 18px;
}

.sharpe-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.sharpe-slider {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.sharpe-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.sharpe-switch input:checked + .sharpe-slider {
  background: rgba(255, 215, 0, 0.25);
}

.sharpe-switch input:checked + .sharpe-slider::after {
  transform: translateX(14px);
  background: rgba(255, 215, 0, 0.9);
}

.sharpe-switch:hover .sharpe-slider {
  background: rgba(255, 255, 255, 0.15);
}

.sharpe-switch input:checked:hover + .sharpe-slider {
  background: rgba(255, 215, 0, 0.35);
}

/* ============================================================
   Loading Overlay (3-dot pulse)
   ============================================================ */
.loading-hidden {
  display: none;
}
.loading-visible {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  padding-top: 6px;
  pointer-events: none;
}

.dot-pulse {
  display: inline-flex;
  gap: 5px;
}
.dot-pulse::before,
.dot-pulse::after,
.dot-pulse {
  content: '';
}
.dot-pulse,
.dot-pulse::before,
.dot-pulse::after {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  animation: dotPulse 1.2s infinite ease-in-out;
}
.dot-pulse::before {
  animation-delay: -0.32s;
}
.dot-pulse::after {
  animation-delay: 0.16s;
}
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ============================================================
   Responsive — ≤ 1023px (Tablet)
   ============================================================ */
@media (max-width: 1023px) {
  #detail-panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: 50%;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    transform: translateY(100%);
    opacity: 0;
  }
  #detail-panel.open {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================================
   Responsive — ≤ 768px (Mobile)
   ============================================================ */
@media (max-width: 768px) {
  #detail-panel {
    width: 100%;
    height: 100%;
    top: 0;
    bottom: auto;
    border: none;
    transform: translateX(100%);
  }
  #detail-panel.open {
    transform: translateX(0);
    opacity: 1;
  }

  .brand-tagline {
    display: none;
  }

  /* On mobile, breadcrumb shows back button instead of pills */
  #breadcrumb {
    display: flex;
  }

  #top-bar {
    padding: 0 12px;
  }

  .tw-btn {
    padding: 3px 7px;
    font-size: 11px;
  }

  /* Detail panel metrics: stack to single column on small screens */
  .dp-metrics {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Sharpe Info Icons (ⓘ) — absolute positioned on chart
   ============================================================ */
.sharpe-info-icon {
  position: absolute;
  z-index: 55;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  pointer-events: auto;
  line-height: 1;
}
.sharpe-info-icon:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* ============================================================
   Sharpe Tooltip — appears on ⓘ hover
   ============================================================ */
.sharpe-tooltip {
  position: absolute;
  z-index: 65;
  width: 310px;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(15, 15, 30, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-family);
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.sharpe-tip-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.3;
}

.sharpe-tip-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.sharpe-tip-body p {
  margin: 0 0 8px 0;
}

.sharpe-tip-body ul {
  margin: 0 0 8px 0;
  padding-left: 16px;
}

.sharpe-tip-body li {
  margin-bottom: 3px;
}

.sharpe-tip-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.5;
}

/* ── Sharpe Benchmark Callout ── */
.sharpe-tip-benchmark {
  margin: 10px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid rgba(255, 215, 0, 0.4);
  border-radius: 0 6px 6px 0;
}
.stb-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stb-formula {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.8;
}

/* ── Sharpe Formula Box (inside tooltip) ── */
.sharpe-formula-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255,215,0,0.06) 0%, rgba(180,200,255,0.04) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}
.sharpe-formula-eq {
  text-align: center;
  font-size: 18px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.sf-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 2px;
}
.sf-num {
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.5);
  padding: 0 6px 2px;
  font-size: 14px;
}
.sf-den {
  padding: 2px 6px 0;
  font-size: 14px;
}
.sharpe-formula-vars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sf-var {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
}
.sf-var-name {
  display: inline-block;
  min-width: 24px;
  font-family: var(--font-mono);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
}

/* ── Enhanced Sharpe Info Icons (clickable galaxy-style) ── */
.sharpe-info-clickable {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.sharpe-info-clickable:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.3);
}
.sharpe-info-glow {
  font-size: 14px;
  text-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
  animation: sharpeIconPulse 3s ease-in-out infinite;
}
@keyframes sharpeIconPulse {
  0%, 100% { opacity: 0.7; text-shadow: 0 0 4px currentColor, 0 0 8px currentColor; }
  50% { opacity: 1; text-shadow: 0 0 8px currentColor, 0 0 16px currentColor, 0 0 24px currentColor; }
}

/* ── Wider tooltip handled in main .sharpe-tooltip rule above ── */

/* ============================================================
   Bloom Sharpe Formula Popup (click to reveal)
   ============================================================ */
.bloom-sharpe-popup {
  position: absolute;
  z-index: 70;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 340px;
  max-width: 90vw;
  background: rgba(12, 12, 28, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.05);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}
.bloom-sharpe-popup.bsp-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.bloom-sharpe-popup.bsp-closing {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.95);
}
.bsp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.bsp-title {
  font-size: 14px;
  font-weight: 600;
}
.bsp-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.bsp-close:hover {
  color: rgba(255, 255, 255, 0.8);
}
.bsp-body {
  padding: 14px 16px 16px;
}
.bsp-context {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.bsp-benchmark-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}
.bsp-bm {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.bsp-bm-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.bsp-bm-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}
.bsp-note {
  margin-top: 10px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  font-style: italic;
}

/* ============================================================
   Collapsible Legend Panel (scatter mode)
   ============================================================ */
.legend-toggle-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 56;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(30, 30, 50, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.legend-toggle-btn:hover {
  opacity: 1;
  background: rgba(30, 30, 50, 1);
  color: var(--text-primary);
}

.legend-panel {
  position: absolute;
  top: 12px;
  right: 52px;
  z-index: 56;
  background: rgba(15, 15, 30, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-family);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  transition: width 0.2s ease-out, opacity 0.2s ease-out, padding 0.2s ease-out;
}

.legend-collapsed {
  width: 0;
  opacity: 0;
  padding: 0;
  border: none;
  pointer-events: none;
}

.legend-expanded {
  width: 200px;
  opacity: 1;
}

.legend-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  white-space: nowrap;
}

.legend-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  white-space: nowrap;
}

.legend-label {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-note {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: nowrap;
}

/* ============================================================
   SCATTER EMPTY STATE CARD  (Prompt 16E)
   ============================================================ */

.scatter-empty-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 360px;
  background: rgba(20, 20, 40, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 24px;
  text-align: center;
  z-index: 60;
  animation: scatter-empty-in 300ms ease-out;
}

@keyframes scatter-empty-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.scatter-empty-icon {
  font-size: 48px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 16px;
  user-select: none;
}

.scatter-empty-title {
  font-size: 16px;
  color: #ffffff;
  font-weight: 600;
  margin-bottom: 6px;
}

.scatter-empty-sub {
  font-size: 13px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.45));
  margin-bottom: 20px;
}

.scatter-empty-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scatter-empty-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  transition: background 150ms, transform 100ms;
}
.scatter-empty-btn:active {
  transform: scale(0.97);
}

.scatter-empty-btn--primary {
  background: rgba(78, 166, 255, 0.18);
  color: #60b5ff;
  border: 1px solid rgba(78, 166, 255, 0.3);
}
.scatter-empty-btn--primary:hover {
  background: rgba(78, 166, 255, 0.28);
}

.scatter-empty-btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.scatter-empty-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   SCATTER SPARSE WARNING BANNER  (Prompt 16E)
   ============================================================ */

.scatter-sparse-banner {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 400px;
  background: rgba(255, 180, 0, 0.08);
  border: 1px solid rgba(255, 180, 0, 0.15);
  border-radius: 6px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 55;
  animation: sparse-banner-in 300ms ease-out;
}

@keyframes sparse-banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.scatter-sparse-text {
  font-size: 12px;
  color: rgba(255, 180, 0, 0.8);
  font-family: 'Inter', sans-serif;
  line-height: 1.4;
  flex: 1;
}

.scatter-sparse-close {
  background: none;
  border: none;
  color: rgba(255, 180, 0, 0.5);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.scatter-sparse-close:hover {
  color: rgba(255, 180, 0, 0.9);
}

/* ============================================================
   USER MENU — top-bar auth status
   ============================================================ */
.user-menu {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 12px;
}

.um-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.um-login-btn {
  padding: 5px 16px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(96,181,255,.15), rgba(167,139,250,.15));
  border: 1px solid rgba(96,181,255,.25);
  color: #60b5ff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.um-login-btn:hover {
  background: linear-gradient(135deg, rgba(96,181,255,.25), rgba(167,139,250,.25));
  border-color: rgba(96,181,255,.4);
}

.um-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60b5ff, #a78bfa);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-family);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow var(--transition-fast);
}
.um-avatar:hover {
  box-shadow: 0 0 0 3px rgba(96,181,255,.2);
}

/* ── Notification Bell ─────────────── */
.um-bell {
  position: relative;
  color: #8b9ab5;
  font-size: 17px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  margin-right: 4px;
}
.um-bell:hover { color: #e0e6ed; }
.um-bell-badge {
  position: absolute;
  top: -5px;
  right: -7px;
  display: none;
  align-items: center;
  justify-content: center;
  background: #ff6b6b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  line-height: 1;
  pointer-events: none;
}

.um-role-tag {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.um-role-admin {
  background: rgba(255,180,0,.15);
  color: #ffb020;
  border: 1px solid rgba(255,180,0,.2);
}

/* Dropdown */
.um-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: rgba(15, 20, 35, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  z-index: 500;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}
.um-dropdown.um-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.um-dd-header {
  padding: 12px 14px 10px;
}
.um-dd-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.um-dd-email {
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.um-dropdown-sep {
  height: 1px;
  background: rgba(255,255,255,.06);
}

.um-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-family);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.um-dropdown-item:hover {
  background: rgba(255,255,255,.05);
  color: var(--text-primary);
}
.um-dd-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}
.um-logout-btn {
  color: #ff6b6b;
}
.um-logout-btn:hover {
  background: rgba(255,80,80,.08);
  color: #ff8a8a;
}

/* ============================================================
   AI ADVISOR — Floating Action Button + Side Panel
   ============================================================ */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60b5ff, #a78bfa);
  border: none;
  cursor: pointer;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(96,181,255,.3), 0 0 0 0 rgba(96,181,255,.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: ai-fab-pulse 3s ease-in-out infinite;
}
.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(96,181,255,.4);
  animation: none;
}
.ai-fab-icon {
  font-size: 24px;
  line-height: 1;
}
@keyframes ai-fab-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(96,181,255,.3), 0 0 0 0 rgba(96,181,255,.2); }
  50% { box-shadow: 0 4px 20px rgba(96,181,255,.3), 0 0 0 8px rgba(96,181,255,.0); }
}

/* AI Side Panel */
.ai-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: rgba(10, 14, 26, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(96,181,255,.12);
  z-index: 450;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.ai-panel.ai-open {
  transform: translateX(0);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.ai-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.ai-panel-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.06);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.ai-panel-close:hover {
  background: rgba(255,255,255,.12);
  color: var(--text-primary);
}

/* Messages area */
.ai-panel-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-panel-msgs::-webkit-scrollbar { width: 4px; }
.ai-panel-msgs::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.ai-msg {
  max-width: 92%;
}
.ai-msg-user {
  align-self: flex-end;
}
.ai-msg-bot {
  align-self: flex-start;
}
.ai-msg-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}
.ai-msg-user .ai-msg-content {
  background: rgba(96,181,255,.15);
  border: 1px solid rgba(96,181,255,.2);
  border-bottom-right-radius: 4px;
}
.ai-msg-bot .ai-msg-content {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-left-radius: 4px;
}
.ai-msg-bot .ai-msg-content code {
  background: rgba(255,255,255,.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.ai-error {
  color: #ff6b6b;
}

/* Thinking animation */
.ai-thinking {
  color: var(--text-muted);
  font-style: italic;
}
.ai-dots::after {
  content: '';
  animation: ai-dots-anim 1.4s steps(4, end) infinite;
}
@keyframes ai-dots-anim {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Input area */
.ai-panel-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.ai-panel-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}
.ai-panel-input:focus {
  border-color: rgba(96,181,255,.3);
}
.ai-panel-input::placeholder {
  color: var(--text-muted);
}
.ai-panel-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #60b5ff, #a78bfa);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}
.ai-panel-send:hover {
  opacity: .85;
}

/* ── Mobile Responsive — AI ── */
@media (max-width: 768px) {
  .ai-panel {
    width: 100%;
  }
  .ai-fab {
    bottom: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
  }
  .ai-fab-icon {
    font-size: 20px;
  }
}
