/* ============================================================
   Quant Agent Dashboard — Professional Split-Pane Layout
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0a0c10;
  --bg-panel:     #0f1218;
  --bg-card:      #161b25;
  --bg-card-hover:#1c2232;
  --bg-elevated:  #1e2433;
  --border:       #1e2536;
  --border-light: #2a3348;
  --text:         #e8eaed;
  --text-sec:     #9aa0b0;
  --text-muted:   #6b7280;
  --accent:       #4f8cff;
  --accent-dim:   rgba(79,140,255,.12);
  --buy:          #34d399;
  --buy-bg:       rgba(52,211,153,.1);
  --hold:         #fbbf24;
  --hold-bg:      rgba(251,191,36,.08);
  --sell:         #f87171;
  --sell-bg:      rgba(248,113,113,.1);
  --green:        #34d399;
  --red:          #f87171;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 8px 32px rgba(0,0,0,.4);
  --transition:   .15s ease;
  --list-width:   380px;
}

/* ---- Light Theme ---- */
[data-theme="light"] {
  --bg:           #f5f6f8;
  --bg-panel:     #ffffff;
  --bg-card:      #f0f1f4;
  --bg-card-hover:#e6e8ed;
  --bg-elevated:  #e8eaef;
  --border:       #d4d8e0;
  --border-light: #c4c9d4;
  --text:         #1a1d24;
  --text-sec:     #4a5060;
  --text-muted:   #8891a0;
  --accent:       #2563eb;
  --accent-dim:   rgba(37,99,235,.1);
  --buy:          #059669;
  --buy-bg:       rgba(5,150,105,.08);
  --hold:         #d97706;
  --hold-bg:      rgba(217,119,6,.08);
  --sell:         #dc2626;
  --sell-bg:      rgba(220,38,38,.08);
  --green:        #059669;
  --red:          #dc2626;
  --shadow:       0 8px 32px rgba(0,0,0,.1);
}
[data-theme=\"light\"] .hero-badge.session,
[data-theme=\"light\"] .st-sentiment { background: rgba(0,0,0,.05); }
[data-theme=\"light\"] .about-overlay { background: rgba(0,0,0,.3); }
[data-theme=\"light\"] .about-close:hover { background: rgba(0,0,0,.05); }
[data-theme=\"light\"] .about-table td { border-bottom-color: rgba(0,0,0,.06); }
[data-theme=\"light\"] .about-table tr:hover td { background: rgba(0,0,0,.03); }
[data-theme=\"light\"] .about-footer { background: rgba(0,0,0,.02); }
[data-theme=\"light\"] ::-webkit-scrollbar-thumb { background: #c4c9d4; }
[data-theme=\"light\"] ::-webkit-scrollbar-thumb:hover { background: #a0a8b8; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex; flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Top Bar ---- */
#topBar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex; align-items: center;
  padding: 0 16px;
  z-index: 100;
  flex-shrink: 0;
  overflow: visible;
}
.top-bar-inner {
  display: flex; align-items: center; width: 100%; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-icon { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.3px; }

.market-ticker {
  display: flex; gap: 16px; font-size: 12px; color: var(--text-sec);
  overflow: hidden; white-space: nowrap; flex: 1; min-width: 0;
}
.market-ticker .idx { display: inline-flex; gap: 4px; }
.market-ticker .idx-name { color: var(--text-muted); }
.market-ticker .idx-val { font-weight: 600; }
.market-ticker .idx-chg { font-weight: 500; }
.market-ticker .up { color: var(--green); }
.market-ticker .down { color: var(--red); }

.top-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ---- Theme Toggle Switch ---- */
.theme-switch {
  position: relative; display: inline-flex; align-items: center;
  flex-shrink: 0; cursor: pointer; margin-left: auto;
}
.theme-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-slider {
  width: 48px; height: 26px; border-radius: 13px;
  background: var(--border-light); position: relative;
  transition: background var(--transition);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 5px;
}
.theme-slider::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text); transition: transform .2s ease;
}
.theme-switch input:checked ~ .theme-slider::after { transform: translateX(22px); }
.theme-switch input:checked ~ .theme-slider { background: var(--accent); }
.theme-slider-icon { font-size: 12px; line-height: 1; z-index: 1; user-select: none; }
.theme-slider-icon.sun { opacity: .7; }
.theme-slider-icon.moon { opacity: .7; }

.search-box input {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 6px 12px;
  font-size: 13px; width: 180px; outline: none;
  transition: border-color var(--transition);
}
.search-box { position: relative; }
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }

.filter-pills { display: flex; gap: 6px; }
.filter-pills select {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-sec); padding: 5px 8px;
  font-size: 12px; cursor: pointer; outline: none;
}

/* ---- Split Layout ---- */
.split-layout {
  display: flex;
  flex: 1; min-height: 0;
  overflow: hidden;
}

/* ---- Stock List Panel (Left) ---- */
.stock-list-panel {
  width: var(--list-width);
  min-width: var(--list-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.list-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.list-title { font-weight: 700; font-size: 14px; }
.list-count {
  background: var(--accent-dim); color: var(--accent);
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.list-content {
  flex: 1; overflow-y: auto; padding: 4px 0;
}

/* Toggle Buttons (All / Watchlist) */
.list-toggle { display: flex; gap: 0; }
.toggle-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: 5px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: var(--font);
}
.toggle-btn:first-child { border-radius: 6px 0 0 6px; }
.toggle-btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.toggle-btn.active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.toggle-btn:not(.active):hover { background: var(--bg-card-hover); color: var(--text); }

/* Stock Row */
.stock-row {
  display: flex; align-items: center; padding: 10px 16px;
  cursor: pointer; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  gap: 12px;
}
.stock-row:hover { background: var(--bg-card-hover); }
.stock-row.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }

.row-rank {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.row-rank.buy { background: var(--buy-bg); color: var(--buy); }
.row-rank.hold { background: var(--hold-bg); color: var(--hold); }
.row-rank.sell { background: var(--sell-bg); color: var(--sell); }

.row-info { flex: 1; min-width: 0; }
.row-ticker { font-weight: 700; font-size: 13px; }
.row-name { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-data { text-align: right; flex-shrink: 0; }
.row-price { font-weight: 600; font-size: 13px; }
.row-change { font-size: 11px; font-weight: 500; }
.row-change.up { color: var(--green); }
.row-change.down { color: var(--red); }

.row-signal {
  font-size: 9px; font-weight: 700; padding: 2px 6px;
  border-radius: 3px; text-transform: uppercase; letter-spacing: .3px;
  flex-shrink: 0;
}
.row-signal.buy { background: var(--buy-bg); color: var(--buy); }
.row-signal.hold { background: var(--hold-bg); color: var(--hold); }
.row-signal.sell { background: var(--sell-bg); color: var(--sell); }

/* ---- Detail Panel (Right) ---- */
.detail-panel {
  flex: 1; overflow-y: auto; background: var(--bg);
}
.detail-content { padding: 0; min-height: 100%; }

/* Market Overview — v2 */
.market-overview {
  padding: 28px 32px;
  max-width: 1100px;
}
.section-heading {
  font-size: 15px; font-weight: 700; margin-bottom: 16px;
  color: var(--text); letter-spacing: -.2px;
}
.overview-indices {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 28px;
}
.index-card-v2 {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  transition: border-color var(--transition);
}
.index-card-v2:hover { border-color: var(--border-light); }
.idx-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px; }
.idx-value-lg { font-size: 20px; font-weight: 700; }
.idx-delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.idx-delta.up { color: var(--green); }
.idx-delta.down { color: var(--red); }

.overview-section { margin-bottom: 28px; }

/* News Grid — 2-row image cards */
.news-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.news-card {
  display: flex; flex-direction: column; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-card); border: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.news-card:hover {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(79,140,255,.12);
  text-decoration: none;
}
.news-card-img {
  height: 100px; display: flex; align-items: flex-end; padding: 8px 10px;
  position: relative;
}
.news-card-src {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: rgba(255,255,255,.7);
  background: rgba(0,0,0,.4); padding: 2px 6px; border-radius: 3px;
}
.news-card-body { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; }
.news-card-title {
  font-size: 12px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.news-card-time { font-size: 10px; color: var(--text-muted); margin-top: 6px; }

/* Featured Article */
.featured-article {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px 28px; margin-bottom: 24px;
  border-left: 3px solid var(--accent);
}
.feat-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.feat-source { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.feat-time { font-size: 10px; color: var(--text-muted); }
.feat-title {
  font-size: 18px; font-weight: 700; line-height: 1.3;
  color: var(--text); display: block; margin-bottom: 10px;
  text-decoration: none;
}
.feat-title:hover { color: var(--accent); text-decoration: none; }
.feat-summary { font-size: 13px; color: var(--text-sec); line-height: 1.5; margin-bottom: 12px; }
.feat-link {
  font-size: 12px; font-weight: 600; color: var(--accent);
  text-decoration: none;
}
.feat-link:hover { text-decoration: underline; }

/* More Headlines (compact list) */
.news-rest-section { margin-bottom: 20px; }
.news-rest-list { display: flex; flex-direction: column; }
.news-rest-item {
  display: block; padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: background var(--transition);
}
.news-rest-item:hover { background: var(--bg-card); margin: 0 -8px; padding: 10px 8px; border-radius: 6px; }
.news-rest-title { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.4; }
.news-rest-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Stock Detail View ---- */
.stock-detail { padding: 0; }

.detail-hero {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-ticker { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.hero-company { font-size: 14px; color: var(--text-sec); margin-top: 2px; }
.hero-badges { display: flex; gap: 6px; margin-top: 8px; }
.hero-badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 4px; text-transform: uppercase; letter-spacing: .3px;
}
.hero-badge.sector { background: var(--accent-dim); color: var(--accent); }
.hero-badge.session { background: rgba(255,255,255,.06); color: var(--text-muted); }

.hero-price-block { text-align: right; }
.hero-price { font-size: 32px; font-weight: 700; }
.hero-change { font-size: 14px; font-weight: 600; margin-top: 2px; }
.hero-change.up { color: var(--green); }
.hero-change.down { color: var(--red); }
.hero-updated { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Tabs */
.detail-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--bg-panel); padding: 0 32px;
  position: sticky; top: 0; z-index: 10;
}
.detail-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab Content */
.tab-content { display: none; padding: 24px 32px; }
.tab-content.active { display: block; }

/* Analysis Cards */
.analysis-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.analysis-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.analysis-card h4 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.analysis-rec {
  font-size: 24px; font-weight: 700; margin-bottom: 4px;
}
.analysis-rec.buy { color: var(--buy); }
.analysis-rec.hold { color: var(--hold); }
.analysis-rec.sell { color: var(--sell); }
.analysis-conf { font-size: 12px; color: var(--text-sec); margin-bottom: 12px; }
.analysis-summary { font-size: 13px; color: var(--text-sec); line-height: 1.5; }
.analysis-outlook { font-size: 12px; color: var(--text-sec); line-height: 1.5; margin-top: 8px; }
.analysis-outlook strong { color: var(--text); }
.analysis-target {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.analysis-target span { color: var(--text); font-weight: 600; }

/* Confidence Bar */
.confidence-bar-wrap {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.confidence-bar {
  flex: 1; height: 6px; background: var(--bg-elevated);
  border-radius: 3px; overflow: hidden;
}
.confidence-fill {
  height: 100%; border-radius: 3px;
  transition: width .6s ease;
}
.confidence-fill.buy { background: var(--buy); }
.confidence-fill.hold { background: var(--hold); }
.confidence-fill.sell { background: var(--sell); }
.confidence-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.analysis-sentiment { font-size: 12px; color: var(--text-sec); margin-bottom: 10px; }
.analysis-sentiment .up { color: var(--green); font-weight: 600; }
.analysis-sentiment .down { color: var(--red); font-weight: 600; }

/* AI Pending State */
.analysis-pending { border-color: var(--hold); border-style: dashed; }
.pending-banner {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
}
.pending-icon { font-size: 28px; }
.pending-title { font-size: 14px; font-weight: 700; color: var(--hold); margin-bottom: 4px; }
.pending-desc { font-size: 12px; color: var(--text-sec); line-height: 1.5; }

/* Metrics Grid */
.metrics-section { margin-bottom: 24px; }
.metrics-section h3 {
  font-size: 14px; font-weight: 700; margin-bottom: 12px;
  color: var(--text);
}
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.metric-cell {
  background: var(--bg-card); border-radius: 6px; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.metric-label { font-size: 11px; color: var(--text-muted); }
.metric-val { font-size: 13px; font-weight: 600; }
.metric-val.up { color: var(--green); }
.metric-val.down { color: var(--red); }

/* Factors */
.factors-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.factor-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 16px;
}
.factor-card h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 8px; font-weight: 700;
}
.factor-card.catalysts h4 { color: var(--buy); }
.factor-card.risks h4 { color: var(--sell); }
.factor-card.factors h4 { color: var(--accent); }
.factor-list { list-style: none; }
.factor-list li {
  font-size: 12px; color: var(--text-sec); padding: 4px 0;
  border-bottom: 1px solid var(--border); line-height: 1.4;
}
.factor-list li:last-child { border: none; }

/* Sources */
.sources-list { list-style: none; }
.sources-list li {
  font-size: 12px; color: var(--text-sec); padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.sources-list li .src-name { color: var(--accent); font-weight: 600; }

/* Chart Container */
.chart-box {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px; height: 280px; position: relative; margin-bottom: 20px;
}

/* News in detail */
.news-detail-list { list-style: none; }
.news-detail-list li {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.news-detail-list li a { font-size: 13px; font-weight: 500; }
.news-detail-list .news-src { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.news-detail-list .news-summary { font-size: 12px; color: var(--text-sec); margin-top: 3px; line-height: 1.4; }

/* Earnings table */
.earnings-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.earnings-table th {
  text-align: left; padding: 8px 12px; font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
}
.earnings-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-sec);
}
.earnings-table tr:hover { background: var(--bg-card-hover); }

/* Loading */
.loading-indicator {
  text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg-elevated); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 9999;
  transition: opacity .3s, transform .3s;
}
.toast.hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }
.toast.error { border-color: var(--sell); }

/* ---- Social Tab ---- */
.social-overview { margin-bottom: 24px; }
.social-gauge { margin-bottom: 16px; }
.gauge-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.gauge-bar {
  display: flex; height: 32px; border-radius: 6px; overflow: hidden;
  background: var(--bg-elevated);
}
.gauge-bullish {
  background: linear-gradient(90deg, var(--buy), #22c55e);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: width .6s ease;
}
.gauge-bearish {
  background: linear-gradient(90deg, #dc2626, var(--sell));
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: width .6s ease;
}
.social-stats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px; margin-top: 12px;
}

.reddit-posts-list { display: flex; flex-direction: column; gap: 8px; }
.reddit-post {
  display: block; padding: 12px 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: inherit;
  transition: border-color var(--transition);
}
.reddit-post:hover { border-color: var(--accent); text-decoration: none; }
.reddit-post-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.reddit-sub { font-size: 10px; font-weight: 700; color: #ff4500; text-transform: lowercase; }
.reddit-score { font-size: 10px; color: var(--text-muted); }
.reddit-post-title { font-size: 13px; font-weight: 500; line-height: 1.4; margin-bottom: 6px; }
.reddit-sentiment-chip {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--text-muted);
}
.reddit-sentiment-chip.up { background: var(--buy-bg); color: var(--buy); }
.reddit-sentiment-chip.down { background: var(--sell-bg); color: var(--sell); }

/* Responsive rules moved to end of file */

/* ---- Schedule Bar ---- */
.schedule-bar {
  background: linear-gradient(90deg, #0e1420 0%, #151d2e 100%);
  border-bottom: 1px solid #1e2536;
  padding: 6px 24px;
  font-size: 12px;
  color: #8b93a7;
}
.sched-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1400px;
  margin: 0 auto;
}
.sched-next {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sched-next-label {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sched-next-time {
  color: #00e5a0;
  font-weight: 600;
  font-size: 12px;
}
.sched-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.sched-pill {
  background: #1a2235;
  border: 1px solid #252e42;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.sched-pill-name {
  color: #9aa0b0;
  margin-right: 4px;
}
.sched-count {
  color: #6b7280;
  font-size: 11px;
  white-space: nowrap;
}

/* ---- Analyst Ratings Tab ---- */
.analyst-summary {
  margin-bottom: 20px;
}
.analyst-consensus-bar {
  display: flex;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.consensus-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  min-width: 40px;
}
.consensus-seg.buy { background: #34d399; }
.consensus-seg.hold { background: #fbbf24; color: #1a1a2e; }
.consensus-seg.sell { background: #f87171; }
.analyst-targets {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.analyst-table-wrap {
  overflow-x: auto;
}
.analyst-table th,
.analyst-table td {
  white-space: nowrap;
  padding: 8px 12px;
}
.analyst-date {
  color: #6b7280;
  font-size: 12px;
}
.analyst-firm {
  font-weight: 600;
  color: #e0e4ec;
}
.analyst-action {
  font-size: 12px;
  color: #9aa0b0;
}
.analyst-rating {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
}
.analyst-rating.buy { background: rgba(52,211,153,0.15); color: #34d399; }
.analyst-rating.hold { background: rgba(251,191,36,0.15); color: #fbbf24; }
.analyst-rating.sell { background: rgba(248,113,113,0.15); color: #f87171; }
.analyst-prior {
  font-size: 11px;
  color: #6b7280;
  margin-left: 4px;
}
.analyst-pt.up { color: #34d399; }
.analyst-pt.down { color: #f87171; }
.analyst-prior-pt {
  font-size: 11px;
  color: #6b7280;
}
.analyst-source-link {
  color: #4f8cff;
  text-decoration: none;
  font-size: 12px;
}
.analyst-source-link:hover { text-decoration: underline; }
.analyst-disclaimer {
  margin-top: 12px;
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
}

/* ---- Live Price ---- */
.price-source-link {
  color: #4f8cff;
  text-decoration: none;
  font-size: 11px;
}
.price-source-link:hover { text-decoration: underline; }
.market-state {
  font-size: 11px;
  margin-left: 6px;
}
.intraday-chart-box {
  height: 180px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #0e1420, #151d2e);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid #1e2536;
}

/* ---- Tournament Ranking ---- */
.tournament-rank {
  background: linear-gradient(135deg, #4f8cff, #7c5cff) !important;
  color: #fff !important;
  font-weight: 800;
  font-size: 12px;
}
.tournament-overview {
  padding: 28px 32px;
  max-width: 1100px;
}
.tournament-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tournament-status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.tournament-status.complete {
  background: rgba(52,211,153,.15);
  color: #34d399;
}
.tournament-status.in-progress {
  background: rgba(251,191,36,.12);
  color: #fbbf24;
}
.tournament-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.tournament-stat {
  font-size: 12px;
  color: var(--text-sec);
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.tournament-top-section {
  margin-bottom: 24px;
}
.tournament-top-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tournament-top-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}
.tournament-top-card:hover {
  border-color: var(--accent);
}
.tournament-top-rank {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  min-width: 32px;
}
.tournament-top-ticker {
  font-weight: 700;
  font-size: 14px;
  min-width: 60px;
}
.tournament-top-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-sec);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tournament-top-signal {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}
.tournament-top-signal.buy { background: var(--buy-bg); color: var(--buy); }
.tournament-top-signal.hold { background: var(--hold-bg); color: var(--hold); }
.tournament-top-signal.sell { background: var(--sell-bg); color: var(--sell); }

.tournament-matchups-section {
  margin-top: 20px;
}
.tournament-matchup {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.matchup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.matchup-winner {
  font-weight: 700;
  font-size: 14px;
  color: var(--buy);
}
.matchup-vs {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.matchup-loser {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sec);
}
.matchup-conf {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 10px;
}
.matchup-reasoning {
  font-size: 12px;
  color: var(--text-sec);
  line-height: 1.5;
}

.tournament-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-sec);
}
.tournament-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.tournament-empty p {
  font-size: 14px;
  margin-bottom: 8px;
}
.tournament-empty-desc {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 8px;
  line-height: 1.5;
}

/* ---- Mobile Back Button ---- */
.mobile-back-btn {
  display: none;
  background: var(--bg-panel);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.mobile-back-btn:hover {
  background: var(--bg-card);
}

/* ============================================================
   RESPONSIVE — Tablet (iPad) & Mobile (iPhone)
   ============================================================ */

/* Tablet: 768px — 1024px */
@media (max-width: 1024px) {
  :root { --list-width: 320px; }
  .market-overview { padding: 20px 24px; }
  .tab-content { padding: 20px 24px; }
  .detail-hero { padding: 20px 24px; }
  .detail-tabs { padding: 0 24px; }
  .toggle-btn { padding: 5px 10px; font-size: 11px; }
  .news-grid { grid-template-columns: repeat(2, 1fr); }
  .analysis-cards { grid-template-columns: 1fr 1fr; }
  .factors-grid { grid-template-columns: 1fr 1fr; }
  .metrics-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Small tablet / large phone landscape */
@media (max-width: 900px) {
  :root { --list-width: 100%; }
  .split-layout { flex-direction: column; }
  .stock-list-panel {
    width: 100%; min-width: auto;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .detail-panel { flex: 1; }
  .market-ticker { display: none; }
  .filter-pills { display: none; }
  .analysis-cards { grid-template-columns: 1fr; }
  .factors-grid { grid-template-columns: 1fr; }
  .detail-hero { padding: 16px; }
  .tab-content { padding: 16px; }
  .detail-tabs { padding: 0 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .detail-tab { white-space: nowrap; padding: 10px 12px; font-size: 12px; }
  .market-overview { padding: 16px; }
  .hero-ticker { font-size: 22px; }
  .hero-price { font-size: 24px; }
  .news-grid { grid-template-columns: 1fr 1fr; }
  .featured-article { padding: 16px; }
  .feat-title { font-size: 15px; }
  .tournament-overview { padding: 16px; }
}

/* Phone portrait: <600px */
@media (max-width: 600px) {
  body.mobile-detail-open .stock-list-panel { display: none; }
  body.mobile-detail-open .detail-panel { height: 100%; }
  body.mobile-detail-open .mobile-back-btn { display: block; }

  .stock-list-panel {
    max-height: 100vh;
    flex: 1; min-height: 0;
  }
  .detail-panel { display: none; }
  body.mobile-detail-open .detail-panel { display: block; }

  #topBar { padding: 0 10px; height: 48px; }
  .brand-name { font-size: 13px; }
  .brand-icon { font-size: 15px; }
  .search-box input { width: 120px; font-size: 12px; padding: 5px 10px; }
  .top-actions { gap: 6px; }

  .list-header { padding: 8px 12px; }
  .toggle-btn { padding: 4px 8px; font-size: 10px; }
  .stock-row { padding: 8px 12px; gap: 8px; }
  .row-rank { width: 24px; height: 24px; font-size: 10px; }
  .row-ticker { font-size: 12px; }
  .row-name { font-size: 10px; }
  .row-price { font-size: 12px; }
  .row-signal { font-size: 8px; padding: 2px 5px; }

  .detail-hero { padding: 12px; }
  .hero-top { flex-direction: column; gap: 8px; }
  .hero-price-block { text-align: left; }
  .hero-ticker { font-size: 20px; }
  .hero-company { font-size: 12px; }
  .hero-price { font-size: 22px; }
  .hero-change { font-size: 12px; }
  .hero-badges { flex-wrap: wrap; }
  .hero-badge { font-size: 9px; }

  .detail-tabs { padding: 0 8px; gap: 0; }
  .detail-tab { padding: 8px 10px; font-size: 11px; }

  .tab-content { padding: 12px; }
  .analysis-card { padding: 14px; }
  .analysis-rec { font-size: 20px; }
  .analysis-summary { font-size: 12px; }
  .analysis-outlook { font-size: 11px; }

  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .metric-cell { padding: 8px 10px; }
  .metric-label { font-size: 10px; }
  .metric-val { font-size: 12px; }

  .news-grid { grid-template-columns: 1fr; }
  .news-card-img { height: 80px; }
  .news-card-title { font-size: 11px; }

  .featured-article { padding: 12px; }
  .feat-title { font-size: 14px; }
  .feat-summary { font-size: 12px; }

  .chart-box { height: 200px; padding: 10px; }
  .intraday-chart-box { height: 140px; padding: 8px; }

  .factors-grid { gap: 10px; }
  .factor-card { padding: 12px; }
  .factor-list li { font-size: 11px; }

  .earnings-table { font-size: 11px; }
  .earnings-table th, .earnings-table td { padding: 6px 8px; }
  .analyst-table-wrap { margin: 0 -12px; }

  .social-gauge { margin-bottom: 12px; }
  .gauge-bar { height: 28px; }
  .reddit-post { padding: 10px; }
  .reddit-post-title { font-size: 12px; }

  .section-heading { font-size: 13px; }

  /* Tournament on mobile */
  .tournament-overview { padding: 12px; }
  .tournament-meta { gap: 8px; }
  .tournament-stat { font-size: 11px; padding: 4px 8px; }
  .tournament-top-card { padding: 8px 10px; gap: 8px; }
  .tournament-top-rank { font-size: 12px; min-width: 28px; }
  .tournament-top-ticker { font-size: 12px; min-width: 50px; }
  .tournament-top-name { font-size: 11px; }
  .tournament-matchup { padding: 10px 12px; }
  .matchup-reasoning { font-size: 11px; }

  /* Schedule bar compact */
  .schedule-bar { padding: 4px 12px; font-size: 11px; }
  .sched-pills { display: none; }
  .sched-count { display: none; }
}

/* Very small phones (<380px) */
@media (max-width: 380px) {
  .search-box input { width: 90px; }
  .toggle-btn { padding: 3px 6px; font-size: 9px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .hero-ticker { font-size: 18px; }
  .hero-price { font-size: 20px; }
}

/* Touch-friendly: ensure tap targets are at least 44px */
@media (hover: none) and (pointer: coarse) {
  .stock-row { min-height: 48px; }
  .toggle-btn { min-height: 36px; }
  .detail-tab { min-height: 40px; }
  .reddit-post { min-height: 44px; }
  .news-card { min-height: 44px; }
  .news-rest-item { min-height: 44px; padding: 12px 0; }
  .mobile-back-btn { min-height: 44px; }
}

/* Landscape phone */
@media (max-width: 900px) and (orientation: landscape) {
  .stock-list-panel { max-height: 35vh; }
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  #topBar { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .tab-content { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast { bottom: max(20px, env(safe-area-inset-bottom)); right: max(20px, env(safe-area-inset-right)); }
}

/* ---- Search Dropdown ---- */
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  width: 320px; max-height: 360px; overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04);
  z-index: 9999;
  backdrop-filter: blur(12px);
  animation: ddFadeIn .12s ease-out;
}
@keyframes ddFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.search-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.search-dd-item:last-child { border-bottom: none; }
.search-dd-item:hover { background: var(--bg-card-hover); }
.search-dd-new { border-top: 1px solid var(--border); background: rgba(79,140,255,.04); }
.dd-ticker { font-weight: 700; font-size: 13px; min-width: 52px; color: var(--text); letter-spacing: .3px; }
.dd-ticker mark { background: none; color: var(--accent); font-weight: 700; }
.dd-name { font-size: 12px; color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-name mark { background: none; color: var(--text-sec); font-weight: 600; }
.dd-name-add { color: var(--accent); font-style: italic; opacity: .8; }
.dd-add-btn {
  width: 26px; height: 26px; border: none; border-radius: 6px;
  background: var(--accent-dim); color: var(--accent);
  font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
}
.dd-add-btn:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
.dd-wl-check { font-size: 13px; color: var(--buy); flex-shrink: 0; opacity: .7; }

/* ---- Watchlist Badge & Remove ---- */
.wl-badge {
  display: inline-block; font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent);
  margin-left: 6px; vertical-align: middle; letter-spacing: .5px;
}
.wl-remove-btn {
  width: 22px; height: 22px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color var(--transition), background var(--transition);
  margin-left: auto;
}
.wl-remove-btn:hover { background: var(--sell-bg); color: var(--sell); }

/* ---- StockTwits Messages ---- */
.st-messages-list { display: flex; flex-direction: column; gap: 8px; }
.st-message {
  padding: 10px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color var(--transition);
}
.st-message:hover { border-color: var(--accent); }
.st-msg-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.st-user { font-size: 11px; font-weight: 700; color: #1da1f2; }
.st-sentiment { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,.06); color: var(--text-muted); }
.st-sentiment.up { background: var(--buy-bg); color: var(--buy); }
.st-sentiment.down { background: var(--sell-bg); color: var(--sell); }
.st-msg-body { font-size: 12px; color: var(--text-sec); line-height: 1.5; word-break: break-word; }
.reddit-post-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ---- Site Footer ---- */
.site-footer {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 8px 16px; background: var(--bg-panel); border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted); flex-shrink: 0;
}
.site-footer-disclaimer { opacity: .7; }
.site-footer-link {
  color: var(--accent); text-decoration: none; font-weight: 600;
  opacity: .85; transition: opacity var(--transition);
}
.site-footer-link:hover { opacity: 1; text-decoration: underline; }

/* ---- About Overlay ---- */
.about-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 40px 20px;
  animation: aboutFadeIn .2s ease-out;
}
.about-overlay.hidden { display: none; }
@keyframes aboutFadeIn { from { opacity: 0; } to { opacity: 1; } }
.about-page {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 16px; max-width: 780px; width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,.5); position: relative;
}
.about-close {
  position: absolute; top: 16px; right: 18px;
  background: none; border: none; color: var(--text-muted);
  font-size: 28px; cursor: pointer; line-height: 1; padding: 4px 8px;
  border-radius: 8px; transition: all var(--transition);
}
.about-close:hover { color: var(--text); background: rgba(255,255,255,.06); }
.about-body {
  padding: 40px 44px 24px;
}
.about-body h1 {
  font-size: 24px; font-weight: 700; margin: 0 0 12px; color: var(--text);
}
.about-body h2 {
  font-size: 16px; font-weight: 700; margin: 28px 0 10px;
  color: var(--accent); letter-spacing: -.2px;
}
.about-body p, .about-body li {
  font-size: 13px; line-height: 1.7; color: var(--text-sec); margin: 0 0 8px;
}
.about-intro {
  font-size: 14px; line-height: 1.75; color: var(--text-sec); margin-bottom: 20px;
}
.about-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; margin: 12px 0 8px;
}
.about-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.about-card-wide { grid-column: 1 / -1; }
.about-card-head {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.about-weight {
  font-size: 10px; font-weight: 600; color: var(--accent);
  background: var(--accent-dim); padding: 2px 7px; border-radius: 8px;
}
.about-card p { font-size: 12px; line-height: 1.6; color: var(--text-muted); margin: 0; }
.about-card ul {
  margin: 8px 0 0; padding-left: 18px; list-style: disc;
}
.about-card li {
  font-size: 12px; line-height: 1.6; color: var(--text-muted); margin-bottom: 4px;
}
.about-table {
  width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px;
}
.about-table th {
  text-align: left; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border); padding: 8px 12px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
}
.about-table td {
  padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,.03); color: var(--text-sec);
}
.about-table tr:hover td { background: rgba(255,255,255,.02); }
.about-footer {
  background: rgba(255,255,255,.02); border-top: 1px solid var(--border);
  padding: 20px 44px; border-radius: 0 0 16px 16px;
}
.about-footer p {
  font-size: 11px; line-height: 1.7; color: var(--text-muted); margin: 0;
}
@media (max-width: 600px) {
  .about-body { padding: 28px 20px 16px; }
  .about-footer { padding: 16px 20px; }
  .about-grid { grid-template-columns: 1fr; }
  .about-body h1 { font-size: 20px; }
  .site-footer { flex-direction: column; gap: 4px; text-align: center; }
}
