:root {
  --bg: #080c14;
  --bg-card: #0e1420;
  --bg-card2: #121929;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(99,102,241,0.4);
  --accent: #6366f1;
  --accent2: #818cf8;
  --positive: #10b981;
  --negative: #f43f5e;
  --neutral: #64748b;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #334155;
  --radius: 16px;
  --radius-sm: 10px;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.logo-icon {
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 6px 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.search-icon { color: var(--text-muted); font-size: 18px; margin-right: 8px; }
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  padding: 10px 0;
  letter-spacing: 0.3px;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-btn {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.search-btn:hover { opacity: 0.85; }
.search-btn:active { transform: scale(0.97); }
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  list-style: none;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  z-index: 200;
}
.suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  transition: background 0.15s;
}
.suggestions li:hover { background: rgba(99,102,241,0.1); }
.suggestions li .sug-ticker { font-weight: 700; color: var(--accent2); min-width: 52px; }
.suggestions li .sug-name { color: var(--text-muted); }
.suggestions.hidden { display: none; }
.header-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.live-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--positive);
  letter-spacing: 1px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.update-time { font-size: 12px; color: var(--text-muted); }

/* ── Main ── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.hidden { display: none !important; }

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  text-align: center;
}
.empty-icon {
  font-size: 64px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 8px;
}
.empty-state h2 { font-size: 26px; font-weight: 700; color: var(--text); }
.empty-state p { color: var(--text-muted); font-size: 15px; max-width: 380px; }
.ticker-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent2);
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.chip:hover {
  background: rgba(99,102,241,0.15);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ── Dashboard Header ── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.ticker-info { display: flex; align-items: baseline; gap: 12px; }
.ticker-name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.company-name { font-size: 16px; color: var(--text-muted); font-weight: 400; }
.sentiment-label-badge {
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.sentiment-label-badge.positive { background: rgba(16,185,129,0.15); color: var(--positive); border: 1px solid rgba(16,185,129,0.3); }
.sentiment-label-badge.negative { background: rgba(244,63,94,0.15); color: var(--negative); border: 1px solid rgba(244,63,94,0.3); }
.sentiment-label-badge.neutral { background: rgba(100,116,139,0.15); color: var(--neutral); border: 1px solid rgba(100,116,139,0.3); }

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px; }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }
.stat-sub { font-size: 12px; color: var(--text-muted); }

/* ── Charts Row ── */
.charts-row {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s;
}
.chart-card:hover { border-color: var(--border-hover); }
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.chart-card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.chart-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent2);
  background: rgba(99,102,241,0.12);
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.8px;
}
.chart-wrap { position: relative; height: 200px; }
.chart-card--timeline .chart-wrap { height: 220px; }
.chart-card--source .chart-wrap { height: 200px; }

/* Donut */
.donut-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto 16px; }
.donut-wrap canvas { width: 100% !important; height: 100% !important; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-score { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.donut-label { font-size: 11px; color: var(--text-muted); }
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.legend-left { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-name { color: var(--text-muted); }
.legend-pct { font-weight: 700; }

/* ── News Section ── */
.news-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.news-header h3 { font-size: 15px; font-weight: 600; }
.news-filters { display: flex; gap: 6px; }
.filter-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent2); }
.filter-btn.active { background: rgba(99,102,241,0.15); border-color: var(--accent); color: var(--accent2); }
.news-list { display: flex; flex-direction: column; }
.news-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: rgba(255,255,255,0.02); }
.news-title { font-size: 14px; font-weight: 500; line-height: 1.5; margin-bottom: 6px; color: var(--text); }
.news-meta { display: flex; align-items: center; gap: 10px; }
.news-source { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.news-time { font-size: 12px; color: var(--text-dim); }
.news-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.sentiment-score {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}
.sentiment-score.positive { color: var(--positive); }
.sentiment-score.negative { color: var(--negative); }
.sentiment-score.neutral { color: var(--neutral); }
.sentiment-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}
.sentiment-tag.positive { background: rgba(16,185,129,0.15); color: var(--positive); }
.sentiment-tag.negative { background: rgba(244,63,94,0.15); color: var(--negative); }
.sentiment-tag.neutral { background: rgba(100,116,139,0.15); color: var(--neutral); }

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,12,20,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .charts-row { grid-template-columns: 1fr 1fr; }
  .chart-card--source { grid-column: span 2; }
}
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 12px; }
  .search-wrap { order: 3; width: 100%; max-width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .chart-card--source { grid-column: span 1; }
  .ticker-name { font-size: 28px; }
}
