/* ===== Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #090e1a;
  --bg-secondary: #0d1424;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(13, 20, 36, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 212, 255, 0.4);

  --accent-blue: #00d4ff;
  --accent-blue-dim: rgba(0, 212, 255, 0.15);
  --accent-green: #00e676;
  --accent-green-dim: rgba(0, 230, 118, 0.12);
  --accent-red: #ff4c6a;
  --accent-red-dim: rgba(255, 76, 106, 0.12);
  --accent-purple: #8b5cf6;

  --text-primary: #f0f4ff;
  --text-secondary: #7a8aab;
  --text-muted: #4a5568;

  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.1);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 10% 0%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-blue), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  background: none;
}

.nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 12px;
  margin: 16px 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  border: 1px solid var(--border-active);
}

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-green-dim);
  border: 1px solid rgba(0, 230, 118, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--accent-green);
}

.status-dot {
  width: 7px; height: 7px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===== Main ===== */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Top Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 26, 0.8);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0; z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
}

.market-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: var(--transition);
}
.search-box:focus-within {
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 180px;
  font-family: 'Inter', sans-serif;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 14px; }

.btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #0099cc);
  color: #000;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,212,255,0.3); }

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ===== Content ===== */
.content {
  padding: 28px 32px;
  flex: 1;
}

/* ===== Page ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== Section Title ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  width: 3px; height: 14px;
  background: var(--accent-blue);
  border-radius: 2px;
}

/* ===== Stat Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
  opacity: 0;
  transition: var(--transition);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: var(--border-active); background: var(--bg-card-hover); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}
.stat-change {
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-value.up, .stat-change.up { color: var(--accent-green); }
.stat-value.down, .stat-change.down { color: var(--accent-red); }
.stat-value.neutral { color: var(--text-primary); }
.stat-icon {
  font-size: 28px;
  position: absolute;
  right: 20px; top: 18px;
  opacity: 0.15;
}

/* ===== Watchlist Grid ===== */
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stock-card:hover {
  border-color: var(--border-active);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.stock-card.selected {
  border-color: var(--accent-blue);
  background: var(--accent-blue-dim);
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}
.ticker-badge {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.ticker-name {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.signal-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}
.signal-buy {
  background: var(--accent-green-dim);
  color: var(--accent-green);
  border: 1px solid rgba(0, 230, 118, 0.25);
}
.signal-sell {
  background: var(--accent-red-dim);
  color: var(--accent-red);
  border: 1px solid rgba(255, 76, 106, 0.25);
}
.signal-hold {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.stock-price {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.stock-change {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}

.mini-chart { height: 48px; width: 100%; }

.stock-indicators {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.indicator-chip {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--bg-card-hover);
  color: var(--text-secondary);
}

/* ===== Chart Page ===== */
.chart-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.chart-stock-info {
  display: flex;
  align-items: center;
  gap: 16px;
}
.chart-ticker {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.chart-price {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.interval-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.interval-tab {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: none;
  transition: var(--transition);
  font-family: 'Inter', sans-serif;
}
.interval-tab.active {
  background: var(--accent-blue);
  color: #000;
}
.interval-tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

#kline-chart { height: 340px; width: 100%; }
#rsi-chart { height: 100px; width: 100%; }
#macd-chart { height: 110px; width: 100%; }
#volume-chart { height: 90px; width: 100%; }

.sub-chart-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 20px 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chart-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* ===== Right Panel ===== */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.stats-list { display: flex; flex-direction: column; gap: 10px; }
.stats-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.stats-list-item .label { color: var(--text-secondary); }
.stats-list-item .val { font-family: var(--font-mono); font-weight: 500; }

.indicator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.indicator-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.indicator-item .name {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.indicator-item .value {
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.gauge-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 10px 0 6px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ===== AI Page ===== */
.ai-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), transparent);
}
.report-title-wrap { display: flex; align-items: center; gap: 10px; }
.ai-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.report-card-title { font-size: 15px; font-weight: 600; }
.report-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.report-body { padding: 20px 22px; }

.report-section { margin-bottom: 18px; }
.report-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-blue);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.report-section p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.signal-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.signal-item .s-ticker {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 6px;
}
.signal-item .s-action {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}
.signal-item .s-confidence {
  font-size: 10px;
  opacity: 0.7;
}

.risk-meter { padding: 16px 22px; border-top: 1px solid var(--border); }
.risk-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.news-list { display: flex; flex-direction: column; gap: 0; }
.news-item {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--bg-card-hover); }
.news-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.news-item h4 {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 5px;
  color: var(--text-primary);
}
.news-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sentiment-tag {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}
.sentiment-bullish { background: var(--accent-green-dim); color: var(--accent-green); }
.sentiment-bearish { background: var(--accent-red-dim); color: var(--accent-red); }
.sentiment-neutral { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.ai-analysis-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===== Loading Animation ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ===== Utilities ===== */
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-blue { color: var(--accent-blue); }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* ===== Responsive ===== */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-layout { grid-template-columns: 1fr; }
}

@media (max-width:900px) {
  .sidebar { width: 64px; }
  .sidebar-logo span, .nav-item span, .nav-label, .status-badge span, .logo-sub { display: none; }
  .main { margin-left: 64px; }
  .watchlist-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-layout { grid-template-columns: 1fr; }
}
