/* ──────────────────────────────────────────────────────────
   IQLachmi · Institutional Watchlist
   Trading-desk dark theme
   ────────────────────────────────────────────────────────── */

:root, [data-theme="dark"] {
  /* Surfaces — deep purple-tinted dark (matches logo background) */
  --bg-base: #0c0518;
  --bg-elevated: #1a0f2e;
  --bg-card: #1f1538;
  --bg-card-hover: #2a1a47;
  --bg-row-hover: #251843;
  --border: #2d1f4a;
  --border-bright: #3d2b5e;

  /* Text */
  --text-primary: #f0e8ff;
  --text-secondary: #b8a8d4;
  --text-tertiary: #7e6f9a;
  --text-dim: #4a3f66;
  --bg-overlay: rgba(255, 215, 130, 0.08);

  /* === Logo palette === */
  --logo-purple: #5e2c8a;       /* mid royal purple */
  --logo-purple-deep: #3d1c5e;  /* deep purple shadow */
  --logo-violet: #a78bfa;       /* light lavender */
  --logo-gold: #ffa726;         /* lotus orange-gold */
  --logo-gold-bright: #ffc94d;  /* sunlit gold */
  --logo-gold-deep: #ff6f00;    /* flame orange */
  --logo-coin: #ffd54f;         /* coin yellow */
  --logo-blue-silver: #7a8bd8;  /* IQ letter blue-silver */

  /* Brand accents — primary becomes gold/purple (was cyan) */
  --accent-primary: var(--logo-gold);
  --accent-primary-bright: var(--logo-gold-bright);
  --accent-secondary: var(--logo-violet);
  --accent-cyan: var(--logo-blue-silver);    /* legacy alias — soft blue-silver */
  --accent-blue: var(--logo-blue-silver);
  --accent-purple: var(--logo-purple);
  --accent-violet: var(--logo-violet);

  /* Semantic — kept for trading meaning */
  --pos: #10b981;
  --pos-bright: #34d399;
  --pos-dim: rgba(16, 185, 129, 0.15);
  --neg: #ef4444;
  --neg-bright: #f87171;
  --neg-dim: rgba(239, 68, 68, 0.15);
  --warn: var(--logo-gold);
  --warn-bright: var(--logo-gold-bright);

  /* Stages — semantic meaning preserved, slight tweak for FADING/PEAKING to fit theme */
  --stage-accumulation: #ef4444;
  --stage-approaching: var(--logo-gold-bright);
  --stage-breakout: #10b981;
  --stage-peaking: var(--logo-violet);
  --stage-fading: #7e6f9a;
  --stage-dropped: #4a3f66;

  /* Effects — brand glows */
  --glow-gold: 0 0 28px rgba(255, 167, 38, 0.35);
  --glow-purple: 0 0 28px rgba(167, 139, 250, 0.35);
  --glow-cyan: 0 0 24px rgba(122, 139, 216, 0.30);  /* now blue-silver */
  --glow-green: 0 0 24px rgba(16, 185, 129, 0.25);
  --glow-red: 0 0 24px rgba(239, 68, 68, 0.25);
  --shadow-card: 0 4px 24px -8px rgba(20, 5, 40, 0.6);
  --shadow-pop: 0 12px 32px -12px rgba(20, 5, 40, 0.8);

  /* Brand gradient (used in logo container, hero accents) */
  --brand-gradient: linear-gradient(135deg, var(--logo-purple) 0%, var(--logo-gold) 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(94, 44, 138, 0.4) 0%, rgba(255, 167, 38, 0.4) 100%);
}

[data-theme="light"] {
  /* Surfaces — warm cream daylight palette (subtle gold tint) */
  --bg-base: #fdfaf3;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f1e6;
  --bg-row-hover: #fbf7ee;
  --border: #ebe1cf;
  --border-bright: #d6c39e;

  /* Text */
  --text-primary: #1c0d3d;       /* deep purple-black for high contrast */
  --text-secondary: #5e4c7e;
  --text-tertiary: #8b7aa3;
  --text-dim: #b3a4c4;
  --bg-overlay: rgba(94, 44, 138, 0.05);

  /* Logo palette — slightly darker for contrast on white */
  --logo-purple: #4a1f6e;
  --logo-purple-deep: #2d1247;
  --logo-violet: #7c3aed;
  --logo-gold: #e88e0a;
  --logo-gold-bright: #f5b73a;
  --logo-gold-deep: #d35400;
  --logo-coin: #e6b800;
  --logo-blue-silver: #4a5c9d;

  --accent-primary: var(--logo-gold);
  --accent-primary-bright: var(--logo-gold-bright);
  --accent-secondary: var(--logo-violet);
  --accent-cyan: var(--logo-blue-silver);
  --accent-blue: var(--logo-blue-silver);
  --accent-purple: var(--logo-purple);
  --accent-violet: var(--logo-violet);

  --pos: #059669;
  --pos-bright: #10b981;
  --neg: #dc2626;
  --neg-bright: #ef4444;
  --warn: var(--logo-gold);
  --warn-bright: var(--logo-gold-bright);

  --stage-accumulation: #dc2626;
  --stage-approaching: var(--logo-gold-bright);
  --stage-breakout: #059669;
  --stage-peaking: var(--logo-violet);
  --stage-fading: #8b7aa3;
  --stage-dropped: #b3a4c4;

  --glow-gold: 0 0 24px rgba(232, 142, 10, 0.25);
  --glow-purple: 0 0 24px rgba(124, 58, 237, 0.20);
  --glow-cyan: 0 0 18px rgba(74, 92, 157, 0.15);

  --shadow-card: 0 1px 3px rgba(28, 13, 61, 0.08), 0 1px 2px rgba(28, 13, 61, 0.04);
  --shadow-pop: 0 10px 25px -5px rgba(28, 13, 61, 0.15), 0 4px 6px -2px rgba(28, 13, 61, 0.06);

  --brand-gradient: linear-gradient(135deg, var(--logo-purple) 0%, var(--logo-gold) 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(74, 31, 110, 0.12) 0%, rgba(232, 142, 10, 0.12) 100%);
}

[data-theme="light"] .bg-gradient {
  background:
    radial-gradient(ellipse 80% 60% at 30% 0%, rgba(94, 44, 138, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 60% 80% at 80% 50%, rgba(255, 167, 38, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(167, 139, 250, 0.04) 0%, transparent 50%),
    var(--bg-base);
}
[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
}
[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.85);
}
[data-theme="light"] .brand h1 {
  background: linear-gradient(135deg, var(--text-primary), var(--accent-blue));
  -webkit-background-clip: text; background-clip: text;
}
[data-theme="light"] .prob-bar-wrapper { background: rgba(15, 23, 42, 0.06); }
[data-theme="light"] .factor-bar { background: rgba(15, 23, 42, 0.05); }
[data-theme="light"] .prob-ring-track { stroke: rgba(15, 23, 42, 0.08); }

/* ── Reset & base ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.font-mono { font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace; }

/* ── Animated background — purple+gold logo palette ── */
.bg-gradient {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse 80% 60% at 25% 0%, rgba(94, 44, 138, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse 60% 80% at 85% 30%, rgba(255, 167, 38, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(167, 139, 250, 0.08) 0%, transparent 50%),
    var(--bg-base);
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 60% 50% at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at center, black 30%, transparent 80%);
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8, 12, 24, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: 18px;
}
.brand-icon {
  width: 72px; height: 72px;
  background: var(--brand-gradient);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: var(--glow-gold);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
  flex-shrink: 0;
}
.brand-icon:hover {
  transform: scale(1.05);
  box-shadow: var(--glow-gold), var(--glow-purple);
}
.brand h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--logo-violet), var(--logo-gold-bright));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.brand p {
  font-size: 13px;
  margin-top: 4px;
}
.brand p {
  font-size: 12px; color: var(--text-tertiary);
  margin-top: 2px;
}
.header-actions {
  display: flex; align-items: center; gap: 12px;
}
.live-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.live-dot {
  width: 8px; height: 8px;
  background: var(--pos);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--pos);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.btn-icon {
  width: 36px; height: 36px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-icon:hover {
  background: var(--bg-card-hover); color: var(--text-primary);
  border-color: var(--border-bright);
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-ghost:hover {
  background: var(--bg-card); color: var(--text-primary);
  border-color: var(--border-bright);
}

/* ── Main ── */
.main {
  max-width: 1400px; margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Hero stats ── */
.hero-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.hero-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  position: relative; overflow: hidden;
  transition: all 0.2s ease;
}
.hero-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}
.hero-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent, transparent);
  opacity: 0.6; pointer-events: none;
}
.hero-card.accent-green::before {
  background: radial-gradient(ellipse at top right, rgba(16, 185, 129, 0.15), transparent 70%);
}
.hero-card.accent-blue::before {
  background: radial-gradient(ellipse at top right, rgba(59, 130, 246, 0.15), transparent 70%);
}
.hero-card.accent-purple::before {
  background: radial-gradient(ellipse at top right, rgba(139, 92, 246, 0.15), transparent 70%);
}
.hero-card.accent-amber::before {
  background: radial-gradient(ellipse at top right, rgba(255, 167, 38, 0.18), transparent 70%);
}
.hero-card.accent-gold::before {
  background:
    radial-gradient(ellipse at top right, rgba(255, 201, 77, 0.20), transparent 70%),
    radial-gradient(ellipse at bottom left, rgba(94, 44, 138, 0.15), transparent 70%);
}
.hero-card.accent-purple::before {
  background:
    radial-gradient(ellipse at top right, rgba(167, 139, 250, 0.18), transparent 70%),
    radial-gradient(ellipse at bottom left, rgba(255, 167, 38, 0.10), transparent 70%);
}
.hero-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  position: relative;
}
.hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1; margin-bottom: 8px;
  position: relative;
}
.hero-detail {
  font-size: 12px; color: var(--text-secondary);
  position: relative;
}
.hero-tickers {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.hero-ticker-chip {
  padding: 3px 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600;
  color: var(--text-primary);
}

/* ── Pipeline section ── */
.pipeline-section {
  margin-bottom: 28px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600;
  color: var(--text-primary);
}
.section-title svg {
  color: var(--logo-gold-bright);
}

.pipeline-flow {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  overflow-x: auto;
}
.pipeline-stage {
  flex: 1; min-width: 140px;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  overflow: hidden;
}
.pipeline-stage::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--stage-color), transparent 60%);
  opacity: 0.08; pointer-events: none;
  transition: opacity 0.2s;
}
.pipeline-stage:hover { border-color: var(--stage-color); }
.pipeline-stage:hover::before { opacity: 0.18; }
.pipeline-stage.active {
  border-color: var(--stage-color);
  box-shadow: 0 0 0 1px var(--stage-color), 0 0 24px rgba(255, 255, 255, 0.08);
}
.pipeline-stage.active::before { opacity: 0.22; }
.pipeline-stage-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  position: relative;
}
.pipeline-stage-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--stage-color);
}
.pipeline-stage-icon {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--stage-color);
  box-shadow: 0 0 8px var(--stage-color);
}
.pipeline-stage-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
  position: relative;
}
.pipeline-stage-label {
  font-size: 11px; color: var(--text-tertiary);
  margin-top: 4px;
  position: relative;
}
.pipeline-arrow {
  display: flex; align-items: center;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ── Control bar ── */
.control-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px; flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 280px; flex: 0 1 auto;
  transition: all 0.15s;
}
.search-box:focus-within {
  border-color: var(--logo-gold-bright);
  box-shadow: 0 0 0 3px rgba(255, 167, 38, 0.18);
}
.search-box svg {
  color: var(--text-tertiary); flex-shrink: 0;
}
.search-box input {
  background: transparent; border: none; outline: none;
  color: var(--text-primary);
  font-size: 13px;
  flex: 1;
  min-width: 100px;
}
.search-box input::placeholder { color: var(--text-tertiary); }
#result-count {
  font-size: 12px; color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}
.sort-control {
  display: flex; align-items: center; gap: 8px;
}
.sort-label {
  font-size: 12px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.sort-control select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.sort-control select:hover { border-color: var(--border-bright); }
.sort-control select:focus { border-color: var(--logo-gold-bright); box-shadow: 0 0 0 3px rgba(255, 167, 38, 0.18); }

/* ── Table ── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.table-scroll {
  overflow-x: auto;
}
table {
  width: 100%; min-width: 1100px;
  border-collapse: collapse;
}
thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
th {
  padding: 12px 14px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary);
  white-space: nowrap;
}
.th-left { text-align: left; }
.th-right { text-align: right; }
.th-prob { min-width: 200px; }
.th-sortable {
  cursor: pointer; user-select: none;
  transition: color 0.15s;
}
.th-sortable:hover { color: var(--text-primary); }
.sort-arrow {
  display: inline-block;
  font-size: 10px;
  color: var(--text-dim);
  margin: 0 2px;
}

tbody tr.watchlist-row {
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
tbody tr.watchlist-row:hover {
  background: var(--bg-row-hover);
}
tbody td {
  padding: 14px;
  font-size: 13px;
  vertical-align: middle;
}
.ticker-cell {
  font-weight: 700; font-size: 14px;
  letter-spacing: -0.01em;
}
.loading-cell {
  padding: 40px !important;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.empty-cell {
  padding: 80px 40px !important;
  text-align: center;
  color: var(--text-tertiary);
}

/* Detail row */
tbody tr.detail-row {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
tbody tr.detail-row.hidden { display: none; }
tbody tr.detail-row td {
  padding: 20px 24px;
}

/* ── Stage pill ── */
.stage-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.stage-pill .pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.stage-accumulation { background: rgba(239, 68, 68, 0.12); color: var(--stage-accumulation); }
.stage-approaching { background: rgba(245, 158, 11, 0.12); color: var(--stage-approaching); }
.stage-breakout { background: rgba(16, 185, 129, 0.12); color: var(--stage-breakout); }
.stage-peaking { background: rgba(59, 130, 246, 0.12); color: var(--stage-peaking); }
.stage-fading { background: rgba(107, 114, 128, 0.12); color: var(--stage-fading); }
.stage-dropped { background: rgba(71, 85, 105, 0.10); color: var(--stage-dropped); }

/* ── Probability cell ── */
.prob-cell {
  display: flex; align-items: center; gap: 12px;
}
.prob-bar-wrapper {
  flex: 1; min-width: 70px;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.prob-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--prob-color-from), var(--prob-color-to));
  transition: width 0.4s ease;
  border-radius: 4px;
  box-shadow: 0 0 8px var(--prob-color-to);
}
.prob-text {
  display: flex; flex-direction: column;
  font-family: 'JetBrains Mono', monospace;
  min-width: 60px;
}
.prob-pct {
  font-size: 14px; font-weight: 700;
  color: var(--prob-color-to);
}
.prob-label {
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

/* ── Numeric values ── */
.num-pos { color: var(--pos-bright); }
.num-neg { color: var(--neg-bright); }
.num-warn { color: var(--warn-bright); }
.num-dim { color: var(--text-dim); }
.num-mono {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Signal cell ── */
.signal-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.sig-bullish { background: rgba(16, 185, 129, 0.15); color: var(--pos-bright); }
.sig-bearish { background: rgba(239, 68, 68, 0.15); color: var(--neg-bright); }
.sig-breakout { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.sig-ad { color: var(--text-tertiary); font-size: 10px; }

/* ── Detail panel ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.detail-explainer {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-left: 3px solid var(--detail-accent, var(--accent-cyan));
  border-radius: 8px;
}
.detail-explainer .stage-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--detail-accent, var(--accent-cyan));
  white-space: nowrap; flex-shrink: 0; padding-top: 2px;
}
.detail-explainer .stage-text {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.detail-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); font-weight: 600;
  margin-bottom: 14px;
}

/* Probability ring */
.prob-ring-container {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 14px;
}
.prob-ring {
  width: 90px; height: 90px;
  position: relative; flex-shrink: 0;
}
.prob-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.prob-ring-track {
  fill: none; stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 8;
}
.prob-ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
  filter: drop-shadow(0 0 6px var(--prob-color-to));
}
.prob-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
}
.prob-ring-pct {
  font-size: 22px; font-weight: 700;
  color: var(--prob-color-to);
  letter-spacing: -0.03em;
  line-height: 1;
}
.prob-ring-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-tertiary); text-transform: uppercase;
  margin-top: 4px;
}
.prob-ring-side .ring-explanation {
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}

.factor-list {
  display: flex; flex-direction: column; gap: 8px;
}
.factor-row {
  display: grid; grid-template-columns: 140px 1fr 36px;
  gap: 10px; align-items: center;
  font-size: 12px;
}
.factor-name {
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}
.factor-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}
.factor-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.factor-value {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600;
}

/* Tech grid */
.tech-grid {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 12px;
  font-size: 12px;
}

/* Fundamentals 3-column compact layout */
.fund-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}
.fund-col {
  min-width: 0;  /* allow text to wrap inside grid cells */
}
.fund-col-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--logo-gold-bright);
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.fund-col-subtitle {
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.fund-col .tech-grid {
  font-size: 11.5px;
  gap: 5px 10px;
}
.fund-col .tech-label {
  font-size: 11.5px;
}
.fund-col .factor-list {
  font-size: 11px;
}
.fund-col .factor-row {
  grid-template-columns: 80px 1fr 28px;
  gap: 8px;
}
@media (max-width: 900px) {
  .fund-grid { grid-template-columns: 1fr; }
}
.tech-grid .tech-label {
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 4px;
}
.tech-grid .tech-value {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  font-weight: 500;
}

/* Options card */
.options-card {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(59, 130, 246, 0.06));
  border: 1px solid var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  padding: 18px;
}
.options-card.stock-only {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.06), rgba(245, 158, 11, 0.02));
  border-color: rgba(245, 158, 11, 0.3);
}
.options-card.skip {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(239, 68, 68, 0.02));
  border-color: rgba(239, 68, 68, 0.3);
}
.options-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-violet); font-weight: 700;
  margin-bottom: 14px;
}
.options-card.stock-only .options-title { color: var(--warn-bright); }
.options-card.skip .options-title { color: var(--neg-bright); }

.options-symbol-card {
  background: var(--bg-elevated);
  border: 1px solid var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.4);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.options-symbol {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.options-symbol-meta {
  font-size: 11px; color: var(--text-tertiary);
  margin-top: 3px;
}

.greek-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.greek-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.greek-label {
  font-size: 10px; text-transform: uppercase;
  color: var(--text-tertiary); letter-spacing: 0.06em;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.greek-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px; font-weight: 700;
  margin-top: 4px;
}
.greek-sub {
  font-size: 10px; color: var(--text-tertiary);
  margin-top: 2px;
}
.greek-2col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.options-rationale {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.5;
}
.options-trade-math {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-primary);
}
.options-reasons {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.options-reasons-header {
  font-size: 12px; font-weight: 600;
  color: var(--warn-bright);
  margin-bottom: 6px;
}
.options-reasons ul {
  list-style: disc; margin-left: 18px;
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.6;
}

/* Stock levels */
.stock-levels {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
}
.stock-levels-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary); font-weight: 600; margin-bottom: 8px;
}
.stock-levels-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stock-level-item .level-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary);
}
.stock-level-item .level-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 700;
  margin-top: 2px;
}
.level-entry { color: var(--text-primary); }
.level-stop { color: var(--neg-bright); }
.level-target { color: var(--pos-bright); }
.stock-levels-meta {
  margin-top: 8px;
  font-size: 11px; color: var(--text-tertiary);
}

/* Stage history */
.stage-history-card {
  margin-top: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.history-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
}
.history-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
}
.history-chip .history-date {
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Tooltips (smart-positioned) ── */
.tooltip {
  position: relative;
  display: inline-flex; align-items: center;
  cursor: help;
}
.tooltip .tip {
  visibility: hidden; opacity: 0;
  position: fixed; z-index: 9999;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-bright);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px; line-height: 1.5;
  font-weight: 400; letter-spacing: normal; text-transform: none;
  width: 320px;
  box-shadow: var(--shadow-pop);
  transition: opacity 0.1s; pointer-events: none;
}
.tooltip .tip code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-card);
  padding: 1px 5px; border-radius: 4px;
  font-size: 11px;
}
.tooltip .tip b { color: var(--text-primary); font-weight: 600; }
.tooltip:hover .tip { visibility: visible; opacity: 1; }
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  margin-left: 4px;
  background: var(--bg-card); color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 9px; font-weight: 700;
  cursor: help;
  transition: all 0.15s;
}
.tooltip:hover .help-icon {
  background: var(--logo-gold); color: white; border-color: var(--logo-gold);
}

/* Rebuild CTA button — uses brand gradient (purple → gold) */
.btn-pill-cta {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  background: var(--brand-gradient);
  color: white;
  border: none; border-radius: 10px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px -3px rgba(255, 167, 38, 0.4);
}
.btn-pill-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -4px rgba(255, 167, 38, 0.55);
}
.btn-pill-cta:disabled {
  opacity: 0.6; cursor: not-allowed;
  transform: none; box-shadow: none;
}
.btn-pill-cta.running {
  background: linear-gradient(135deg, var(--warn), var(--warn-bright));
  box-shadow: 0 4px 12px -3px rgba(245, 158, 11, 0.4);
  animation: pulse-running 1.5s ease-in-out infinite;
}
@keyframes pulse-running {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Rebuild modal */
.rebuild-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(5, 8, 19, 0.85);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.rebuild-modal.hidden { display: none; }
.rebuild-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  padding: 28px;
  width: 100%; max-width: 540px;
  box-shadow: var(--shadow-pop);
}
.rebuild-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.rebuild-modal-title {
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.rebuild-step {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px;
}
.rebuild-step-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.rebuild-step-text {
  flex: 1;
  font-size: 14px; font-weight: 500;
}
.rebuild-step-meta {
  font-size: 11px; color: var(--text-tertiary);
  margin-top: 2px;
}
.rebuild-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rebuild-progress {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
}
.rebuild-progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.rebuild-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  transition: width 0.5s ease;
}
.rebuild-log {
  background: #050813;
  color: #97a3bf;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin-top: 12px;
  border: 1px solid var(--border);
}
.rebuild-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--pos-bright);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 14px;
  font-size: 13px;
}
.rebuild-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--neg-bright);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 14px;
  font-size: 13px;
}

/* Transition toast (intraday refresh notification) */
.transition-toast {
  position: fixed; top: 80px; right: 20px; z-index: 1500;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-left: 4px solid var(--logo-gold);
  border-radius: 12px;
  padding: 16px;
  width: 380px;
  box-shadow: var(--shadow-pop);
  transform: translateX(110%);
  transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1);
  font-size: 13px;
}
.transition-toast.show { transform: translateX(0); }

/* User menu */
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 220px;
  box-shadow: var(--shadow-pop);
  z-index: 200;
}
.user-dropdown.hidden { display: none; }
.user-info {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-name {
  font-weight: 600; font-size: 13px;
  color: var(--text-primary);
}
.user-email {
  font-size: 11px; color: var(--text-tertiary);
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent; border: none;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px; text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.user-menu-item:hover { background: var(--bg-row-hover); }
.user-menu-item.danger { color: var(--neg-bright); }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-pop);
}
.auth-logo {
  width: 72px; height: 72px;
  background: var(--brand-gradient);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: white; margin: 0 auto 20px;
  box-shadow: var(--glow-gold);
  overflow: hidden;
}
.auth-title {
  text-align: center;
  font-size: 24px; font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 28px;
}
.auth-field {
  margin-bottom: 16px;
}
.auth-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.auth-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  outline: none;
  transition: all 0.15s;
}
.auth-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.auth-button {
  width: 100%;
  padding: 12px;
  background: var(--brand-gradient);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
  box-shadow: 0 0 0 0 rgba(255, 167, 38, 0);
}
.auth-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -4px rgba(255, 167, 38, 0.45);
}
.auth-link-row a {
  color: var(--logo-gold-bright) !important;
}
.auth-error {
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--neg-bright);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.auth-success {
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--pos-bright);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.auth-link-row {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-tertiary);
}
.auth-link-row a {
  color: var(--accent-cyan);
  text-decoration: none; font-weight: 500;
}
.auth-link-row a:hover { text-decoration: underline; }

/* Admin user list */
.admin-card {
  margin-bottom: 24px;
}
.admin-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.admin-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.admin-stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
}
.admin-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px; font-weight: 700;
  margin-top: 4px;
}

/* Footer hint */
.footer-hint {
  text-align: center;
  font-size: 12px; color: var(--text-tertiary);
  margin-top: 24px;
  padding-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner { padding: 14px 16px; }
  .main { padding: 20px 16px 40px; }
  .brand h1 { font-size: 17px; }
  .hero-stats { grid-template-columns: 1fr; }
  .pipeline-flow { flex-direction: column; }
  .pipeline-arrow { transform: rotate(90deg); margin: -4px 0; }
  .detail-grid { grid-template-columns: 1fr; }
}
