/* === Variables === */
:root {
  --surface-0: #0d1117;
  --surface-1: #161b22;
  --surface-2: #21262d;
  --surface-3: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --gain: #3fb950;
  --loss: #f85149;
  --warn: #d29922;
  --radius: 8px;
  --transition: 0.2s ease;
}

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

/* === Base === */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.ticker-link { color: inherit; }
a.ticker-link:hover { color: var(--accent); text-decoration: underline; }

/* === Logo === */
.logo {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo .u { color: var(--accent); }

/* === Navigation === */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--surface-3);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-nav .nav-links { display: flex; gap: 1.5rem; align-items: center; }
.site-nav .nav-links a { color: var(--text-secondary); font-size: 0.875rem; }
.site-nav .nav-links a:hover { color: var(--text-primary); text-decoration: none; }

/* === Landing Page === */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 2rem;
  text-align: center;
}
.landing .hero-logo {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.landing .hero-logo .u { color: var(--accent); }
.landing .tagline {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 3rem;
}
.nav-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  max-width: 960px;
  width: 100%;
}
.nav-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: left;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: border-color var(--transition), transform var(--transition);
}
.nav-card.primary { grid-column: span 3; }
.nav-card.secondary { grid-column: span 2; }
.nav-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.nav-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.nav-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0;
}
.card-arrow {
  position: absolute;
  right: 1.5rem;
  top: 1.5rem;
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: transform var(--transition), color var(--transition);
}
.nav-card:hover .card-arrow {
  transform: translateX(4px);
  color: var(--accent);
}
@media (max-width: 768px) {
  .nav-cards { grid-template-columns: 1fr; }
  .nav-card.primary,
  .nav-card.secondary { grid-column: span 1; }
}

/* === Dashboard === */
.dashboard { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }

/* Header metrics */
.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
}
.metric-card .label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric-card .value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.metric-card .value.gain { color: var(--gain); }
.metric-card .value.loss { color: var(--loss); }

/* Freshness indicator */
.freshness { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.8rem; }
.freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.freshness-dot.fresh { background: var(--gain); }
.freshness-dot.stale { background: var(--warn); }
.freshness-dot.old { background: var(--loss); }

/* Search */
.ticker-search {
  margin-left: auto;
  position: relative;
}
.ticker-search input {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  width: 200px;
  transition: border-color var(--transition);
}
.ticker-search input::placeholder { color: var(--text-secondary); }
.ticker-search input:focus {
  border-color: var(--accent);
  outline: none;
}

/* === Tabs === */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--surface-3);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.tab-badge {
  background: var(--accent);
  border-radius: 10px;
  color: var(--surface-0);
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  padding: 0.1rem 0.4rem;
  text-align: center;
}
.tab-badge.warn { background: var(--warn); }
.tab-badge.danger { background: var(--loss); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.625rem 0.75rem;
  position: sticky;
  top: 0;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--surface-3);
  white-space: nowrap;
}
tr:nth-child(even) { background: var(--surface-1); }
tr:nth-child(odd) { background: var(--surface-0); }
tr:hover { background: var(--surface-2); }
tr[data-ticker] { transition: background var(--transition); }

/* Sticky first column */
table th:first-child,
table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}
table th:first-child { z-index: 2; background: var(--surface-2); }
table tr:nth-child(even) td:first-child { background: var(--surface-1); }
table tr:nth-child(odd) td:first-child { background: var(--surface-0); }
table tr:hover td:first-child { background: var(--surface-2); }

/* P&L coloring in tables */
.pnl-gain { color: var(--gain); font-weight: 600; }
.pnl-loss { color: var(--loss); font-weight: 600; }

/* === Signal Badges === */
.signal {
  border-radius: 4px;
  color: #fff;
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
}
.signal-strong-buy { background: #238636; }
.signal-strong-buy::before { content: "\25B2\25B2 "; }
.signal-buy { background: #238636; }
.signal-buy::before { content: "\25B2 "; }
.signal-neutral { background: #6e7681; }
.signal-neutral::before { content: "\2014 "; }
.signal-warning { background: var(--warn); }
.signal-warning::before { content: "\26A0 "; }
.signal-sell { background: #da3633; }
.signal-sell::before { content: "\25BC "; }
.signal-strong-sell { background: #da3633; }
.signal-strong-sell::before { content: "\25BC\25BC "; }

/* === Alert Cards === */
.alert-group { margin-bottom: 1.5rem; }
.alert-group h3 {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-priority {
  border-radius: 4px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
}
.alert-priority.high { background: var(--loss); }
.alert-priority.medium { background: var(--warn); }
.alert-priority.low { background: #6e7681; }
.alert-item {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  padding: 0.625rem 1rem;
}
.alert-item .alert-ticker {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  min-width: 60px;
  color: var(--accent);
}
.alert-item .alert-type {
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 180px;
}
/* Alert type coloring by signal category */
.alert-item[data-alert-type="STOP_LOSS_BREACH"] .alert-type,
.alert-item[data-alert-type="TRAILING_STOP_BREACH"] .alert-type,
.alert-item[data-alert-type="DEATH_CROSS_CONFIRMED"] .alert-type,
.alert-item[data-alert-type="WEEKLY_DEATH_CROSS"] .alert-type,
.alert-item[data-alert-type="DEATH_CROSS_IMMINENT"] .alert-type { color: var(--loss); }
.alert-item[data-alert-type="PROFIT_TARGET_ZONE"] .alert-type,
.alert-item[data-alert-type="GOLDEN_CROSS_CONFIRMED"] .alert-type,
.alert-item[data-alert-type="WEEKLY_GOLDEN_CROSS"] .alert-type,
.alert-item[data-alert-type="GOLDEN_CROSS_IMMINENT"] .alert-type,
.alert-item[data-alert-type="ATH_BREAKOUT"] .alert-type { color: var(--gain); }
.alert-item[data-alert-type="VOLATILITY_REGIME_CHANGE"] .alert-type,
.alert-item[data-alert-type="ATH_PROXIMITY"] .alert-type { color: var(--warn); }
.alert-item .alert-detail {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  flex: 1;
  min-width: 0;
}
.sparkline {
  flex-shrink: 0;
  opacity: 0.85;
}

/* === Alert Brackets === */
.alert-bracket {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--surface-3);
}
.alert-bracket:last-child { border-bottom: none; }
.bracket-title {
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.bracket-count {
  background: var(--accent);
  border-radius: 10px;
  color: var(--surface-0);
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  padding: 0.1rem 0.45rem;
  text-align: center;
}
.bracket-subtitle {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}

/* === Collapsible Sections (Debate) === */
details {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
details > summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "\25B6";
  font-size: 0.625rem;
  transition: transform var(--transition);
  color: var(--text-secondary);
}
details[open] > summary::before { transform: rotate(90deg); }
details .detail-content { padding: 0 1rem 1rem; }
details.sector-group { margin-bottom: 0.75rem; }
details.sector-group > summary { font-size: 0.9375rem; }
details.ticker-detail { background: var(--surface-0); margin: 0.25rem 0; }
details.ticker-detail > summary { font-size: 0.8125rem; padding: 0.5rem 0.75rem; }
.signal-dist {
  display: inline-flex;
  gap: 0.375rem;
  margin-left: auto;
  font-size: 0.7rem;
}

/* === Charts — Inline Thumbnails (Scanner/Portfolio) === */
.chart-inline {
  width: 100%;
  height: auto;
  aspect-ratio: 18 / 11;
  min-width: 120px;
  object-fit: cover;
  object-position: right center;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  background: var(--surface-2);
}
.chart-cell { padding: 0.25rem; }

table.has-chart-col { table-layout: auto; }
table.has-chart-col td:last-of-type:not(.chart-cell) { white-space: normal; min-width: 120px; }
table.has-chart-col th.chart-cell,
table.has-chart-col td.chart-cell { width: 140px; min-width: 120px; }

/* === Charts — Debate Detail === */
.chart-debate {
  max-width: 520px;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  cursor: pointer;
  margin: 0.5rem auto 1rem;
  display: block;
}
.chart-detail {
  text-align: center;
  border-bottom: 1px solid var(--surface-3);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}


/* === Interactive Charts (TradingView Lightweight Charts) === */
.interactive-chart { width: 100%; height: 400px; border-radius: var(--radius); overflow: hidden; }
.chart-timeframe-bar { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.chart-timeframe-btn {
  background: none;
  border: 1px solid var(--surface-3);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  transition: border-color var(--transition), color var(--transition);
}
.chart-timeframe-btn:hover, .chart-timeframe-btn.active {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Overlay wrapper for interactive chart */
.chart-overlay-wrapper {
  background: var(--surface-0);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 1rem;
  width: 90vw;
  max-width: 1200px;
  max-height: 90vh;
}
.chart-overlay-wrapper .interactive-chart { height: 70vh; max-height: 600px; }
.chart-overlay-title {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* === Chart Fullscreen Overlay === */
.chart-overlay {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.chart-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.chart-overlay img {
  max-width: 95%;
  max-height: 95vh;
  border-radius: var(--radius);
}

/* === Markdown Content === */
.md-content h1 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; }
.md-content h2 { font-size: 1.25rem; margin: 1.25rem 0 0.625rem; border-bottom: 1px solid var(--surface-3); padding-bottom: 0.375rem; }
.md-content h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
.md-content p { margin-bottom: 0.75rem; color: var(--text-secondary); }
.md-content strong { color: var(--text-primary); }
.md-content em { color: var(--text-secondary); }
.md-content ul, .md-content ol { margin: 0.5rem 0 0.75rem 1.5rem; color: var(--text-secondary); }
.md-content li { margin-bottom: 0.25rem; }
.md-content hr { border: none; border-top: 1px solid var(--surface-3); margin: 1.5rem 0; }
.md-content code {
  background: var(--surface-2);
  border-radius: 3px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  padding: 0.15rem 0.375rem;
}
.md-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  background: var(--surface-1);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* === Indicator Strip (inside expanded ticker detail) === */
.indicator-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0.75rem;
}
.indicator-chip {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.chip-green { background: rgba(63, 185, 80, 0.15); color: #3fb950; }
.chip-gray { background: rgba(110, 118, 129, 0.15); color: #9ca3af; }
.chip-amber { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.chip-red { background: rgba(218, 54, 51, 0.15); color: #f85149; }

/* === Indicator Chip Tooltips === */
.indicator-chip[data-tooltip] {
  position: relative;
  cursor: help;
}
.indicator-chip[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--surface-3);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 400;
  font-family: -apple-system, sans-serif;
  line-height: 1.4;
  white-space: normal;
  max-width: 280px;
  width: max-content;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.indicator-chip[data-tooltip]:hover::after {
  opacity: 1;
}

/* === Summary Exception Badges (conviction, quality) === */
.conviction-badge, .quality-badge {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  white-space: nowrap;
}

/* === Execution Plan Callout === */
.execution-plan {
  background: var(--surface-2);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
}
.execution-label {
  background: var(--warn);
  border-radius: 3px;
  color: var(--surface-0);
  font-family: 'SF Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 0.5rem;
  padding: 0.1rem 0.4rem;
}

/* === Health Flag Badge (header) === */
.health-flag {
  background: rgba(218, 54, 51, 0.15);
  color: #f85149;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  cursor: pointer;
}
.health-flag:hover { background: rgba(218, 54, 51, 0.3); }

/* Flags Detail Popup */
.flags-popup {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  min-width: 280px;
  max-width: 400px;
  background: var(--surface-2, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin-top: 0.5rem;
}
.flags-popup.active { display: block; }
.flags-popup-header {
  padding: 0.6rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #888);
  border-bottom: 1px solid var(--border, #333);
}
.flags-popup-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
  max-height: 300px;
  overflow-y: auto;
}
.flags-popup-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
}
.flags-popup-item:hover { background: rgba(255,255,255,0.04); }
.flags-ticker {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 50px;
  color: var(--text-primary, #e0e0e0);
}
.flags-reasons { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.flags-chip {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-red { background: rgba(218,54,51,0.2); color: #f85149; }
.chip-amber { background: rgba(227,179,65,0.2); color: #e3b341; }

/* === Trade Cards === */
.trades-summary {
  display: flex;
  background: var(--surface-3);
  border-radius: var(--radius);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.trades-summary-stat {
  flex: 1;
  background: var(--surface-1);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.trades-summary-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.trades-summary-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trades-summary-value.gain { color: var(--gain); }
.trades-summary-value.loss { color: var(--loss); }

.trades-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trade-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-left: 3px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.trade-card.is-gain {
  border-left-color: var(--gain);
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.04), var(--surface-1) 40%);
}
.trade-card.is-loss {
  border-left-color: var(--loss);
  background: linear-gradient(135deg, rgba(248, 81, 73, 0.04), var(--surface-1) 40%);
}
.trade-card.is-buy {
  border-left-color: var(--accent);
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.04), var(--surface-1) 40%);
}

/* Header */
.trade-card__header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}
.trade-ticker {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
}
.trade-pnl-group {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.trade-pnl {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 700;
}
.trade-pnl.gain { color: var(--gain); }
.trade-pnl.loss { color: var(--loss); }
.trade-pnl-dollar {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
}
.trade-pnl-dollar.gain { color: var(--gain); }
.trade-pnl-dollar.loss { color: var(--loss); }

/* Action badges */
.signal-tlh { background: var(--warn); }
.signal-loss { background: #da3633; }
.signal-profit { background: #238636; }
.signal-cash { background: #1f6feb; }

/* Stats grid */
.trade-card__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--surface-3);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.trade-stat {
  background: var(--surface-0);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-right: 1px solid var(--surface-3);
}
.trade-stat:last-child { border-right: none; }
.trade-stat-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.trade-stat-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Notes */
.trade-notes {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-style: italic;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* Reasoning (nested details) */
.trade-card__reasoning {
  background: transparent;
  border: 1px solid var(--surface-3);
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.trade-card__reasoning > summary {
  font-size: 0.75rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
}
.trade-reasoning-content { padding: 0 0.75rem 0.75rem; }
.trade-reasoning-content p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}
.trade-reasoning-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Footer */
.trade-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.trade-tags, .trade-tracking {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.chip-muted {
  background: rgba(110, 118, 129, 0.08);
  color: #484f58;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* === No Data Placeholder === */
.no-data {
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--surface-3);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 1rem 2rem;
  text-align: center;
}

/* === Architecture / System Tab === */
.arch-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface-3);
  margin-bottom: 0.75rem;
}
.arch-view-switcher {
  display: inline-flex;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 2px;
}
.arch-view-btn {
  padding: 0.375rem 1rem;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.arch-view-btn:hover { color: var(--text-primary); }
.arch-view-btn.active { background: var(--accent); color: var(--surface-0); }

.arch-filters { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.arch-layer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.arch-layer-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.arch-layer-btn.active { background: var(--surface-2); color: var(--text-primary); }
.arch-layer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.arch-search { margin-left: auto; }
.arch-search input {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  width: 180px;
  transition: border-color var(--transition);
}
.arch-search input::placeholder { color: var(--text-secondary); }
.arch-search input:focus { border-color: var(--accent); outline: none; }

.arch-canvas {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 500px;
  background: var(--surface-0);
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  position: relative;
  overflow: hidden;
}
.arch-canvas svg { width: 100%; height: 100%; display: block; }

.arch-legend {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.arch-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.arch-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Tooltip (follows .heatmap-tooltip pattern) */
.arch-tooltip {
  display: none;
  position: fixed;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  z-index: 1000;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
}
.arch-tooltip.show { display: block; }
.arch-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.arch-tooltip .tt-label { color: var(--text-secondary); }

/* Detail card (follows .flags-popup pattern) */
.arch-detail {
  display: none;
  position: absolute;
  z-index: 500;
  min-width: 280px;
  max-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.arch-detail.active { display: block; }
.arch-detail__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--surface-3);
}
.arch-detail__name {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  font-size: 0.9375rem;
  flex: 1;
}
.arch-detail__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
}
.arch-detail__close:hover { color: var(--text-primary); }
.arch-detail__desc {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.4;
  padding: 0.75rem 1rem 0;
  margin: 0;
}
.arch-detail__meta {
  padding: 0.5rem 1rem;
}
.arch-detail__meta .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  font-size: 0.8125rem;
}
.arch-detail__meta .tt-label { color: var(--text-secondary); font-size: 0.75rem; }
.arch-detail__connections {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid var(--surface-3);
}
.arch-detail__connections .tt-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}
.arch-detail__connections .tt-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  font-size: 0.8125rem;
}

/* === Responsive — Progressive Column Hiding === */
@media (max-width: 1200px) {
  .col-hide-lg { display: none; }
}

@media (max-width: 900px) {
  .col-hide-md { display: none; }
}

@media (max-width: 768px) {
  .site-nav { padding: 0.75rem 1rem; }
  .dashboard { padding: 1rem; }
  .dash-header { gap: 0.75rem; }
  .metric-card { padding: 0.5rem 0.75rem; }
  .metric-card .value { font-size: 1rem; }
  .ticker-search { margin-left: 0; width: 100%; }
  .ticker-search input { width: 100%; }
  .tab-btn { padding: 0.625rem 0.75rem; font-size: 0.8125rem; }
  .arch-search { margin-left: 0; width: 100%; }
  .arch-search input { width: 100%; }
  .arch-canvas { height: calc(100vh - 320px); min-height: 400px; }
  .arch-legend { flex-wrap: wrap; gap: 0.75rem; }
  .alert-item { flex-wrap: wrap; gap: 0.5rem; }
  .alert-item .alert-type { min-width: auto; }
  .chart-inline { min-width: 80px; }
  .chart-debate { max-width: 100%; }
  .indicator-chip, .conviction-badge, .quality-badge { font-size: 0.6rem; }
  details.ticker-detail > summary { flex-wrap: wrap; }
  .trades-summary { flex-wrap: wrap; }
  .trades-summary-stat { flex: 1 1 calc(50% - 1px); min-width: 0; }
}

@media (max-width: 600px) {
  .trade-card__stats { grid-template-columns: repeat(2, 1fr); }
  .trade-stat:nth-child(2) { border-right: none; }
  .trade-card__header { flex-wrap: wrap; }
  .trade-pnl-group { margin-left: 0; }
}

@media (max-width: 480px) {
  .chart-cell, th.chart-cell { display: none; }
  .interactive-chart { height: 280px; }
  .chart-overlay-wrapper { width: 96vw; padding: 0.5rem; }
  .chart-overlay-wrapper .interactive-chart { height: 60vh; }
}

/* === Signal Performance Tab === */
.signals-overview {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.signal-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
}
.signal-card h3 {
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.signal-card.signal-buy h3 { color: var(--gain); }
.signal-card.signal-sell h3 { color: var(--loss); }
.signal-count {
  background: var(--surface-3);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
}
.signal-card h4 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 1rem 0 0.5rem;
}
.signal-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-bottom: 0.5rem;
}
.signal-stats-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 2px solid var(--surface-3);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}
.signal-stats-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--surface-2);
}
.signals-filter-btn {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.signals-filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.signals-filter-btn.active { background: var(--accent); color: #0d1117; border-color: var(--accent); }
.signal-recent {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.signal-recent-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}
.signal-recent-item[data-ticker] { cursor: pointer; }
.signal-recent-item[data-ticker]:hover { background: var(--surface-2); }
.chart-signal-thumb {
  max-width: 120px;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
}
.signal-ticker {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  min-width: 55px;
  color: var(--accent);
}
.signal-date {
  color: var(--text-secondary);
  min-width: 80px;
}
.signal-price {
  min-width: 65px;
  text-align: right;
}
.signal-return {
  min-width: 60px;
  text-align: right;
  font-weight: 600;
}

/* === Overview: Heatmap === */
.overview-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.heatmap {
  display: grid;
  gap: 3px;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
}
.hm-cell {
  padding: 8px 6px;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.1s;
}
.hm-cell:hover { transform: scale(1.03); z-index: 1; }
.hm-ticker { font-weight: 700; font-size: 0.85rem; }
.hm-pnl { font-size: 0.75rem; opacity: 0.9; }
.hm-val { font-size: 0.65rem; opacity: 0.7; }

.heatmap-tooltip {
  display: none;
  position: fixed;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  z-index: 1000;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
}
.heatmap-tooltip.show { display: block; }
.heatmap-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.heatmap-tooltip .tt-label { color: var(--text-secondary); }

/* === Overview: Sort bar === */
.sort-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.sort-btn {
  padding: 4px 10px;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.sort-btn:hover { color: var(--text-primary); background: var(--surface-2); }

/* === Research Tab === */
.research-section {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.research-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--surface-3);
  padding-bottom: 0.5rem;
}
.research-cards {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.research-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 0.875rem 1.1rem;
  min-width: 140px;
  flex: 1 1 140px;
}
.research-card .rc-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.research-card .rc-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.research-card .rc-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}
.alloc-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
}
.alloc-label {
  width: 140px;
  flex-shrink: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alloc-bar-wrap {
  flex: 1;
  background: var(--surface-3);
  border-radius: 3px;
  height: 8px;
  overflow: hidden;
}
.alloc-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.alloc-bar-fill.alloc-cash { background: #3fb950; }
.alloc-bar-fill.alloc-bond { background: #d29922; }
.alloc-bar-fill.alloc-equity { background: #58a6ff; }
.alloc-bar-fill.alloc-etf { background: #bc8cff; }
.alloc-pct {
  width: 48px;
  text-align: right;
  color: var(--text-primary);
  font-weight: 600;
  flex-shrink: 0;
}
.alloc-val {
  width: 80px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.concentration-warn {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  color: var(--loss);
  margin-bottom: 0.75rem;
}
.hhi-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.hhi-badge.hhi-low { background: rgba(63,185,80,0.15); color: var(--gain); }
.hhi-badge.hhi-med { background: rgba(210,153,34,0.15); color: var(--warn); }
.hhi-badge.hhi-high { background: rgba(248,81,73,0.15); color: var(--loss); }
.stop-bar-wrap {
  flex: 1;
  background: var(--surface-3);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.stop-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gain);
}
.stop-bar-fill.danger { background: var(--loss); }
.stop-bar-fill.warn { background: var(--warn); }
.pnl-group-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.4rem 0;
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--surface-3);
  margin-bottom: 0.4rem;
}
.pnl-group-header.multi-bagger { color: #bc8cff; }
.pnl-group-header.winner { color: var(--gain); }
.pnl-group-header.loser { color: var(--loss); }
.research-mini-table td, .research-mini-table th {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--surface-2);
  white-space: nowrap;
}
.research-mini-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
}
.research-mini-table th:first-child { text-align: left; }
.research-mini-table td:not(:first-child) { text-align: right; }
.research-mini-table tr:last-child td { border-bottom: none; }
.signal-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
}
.sh-cell {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  text-align: center;
}
.sh-cell .sh-label { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 0.2rem; }
.sh-cell .sh-count { font-size: 1.4rem; font-weight: 700; }
.sh-cell.sh-buy .sh-count { color: var(--gain); }
.sh-cell.sh-sell .sh-count { color: var(--loss); }
.sh-cell.sh-warn .sh-count { color: var(--warn); }
.sh-cell.sh-neutral .sh-count { color: var(--text-secondary); }
.sort-btn.active { color: var(--text-primary); background: var(--surface-2); border-color: var(--accent); }
