@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Space+Mono:wght@400;700&display=swap');

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

:root {
  --bg: #080810;
  --surface: #0F0F1C;
  --surface2: #15152A;
  --surface3: #1C1C35;
  --surface4: #222240;
  --accent: #00E87A;
  --accent2: #FF6240;
  --accent3: #3D9EFF;
  --accent4: #FFB800;
  --text: #E8E8FF;
  --muted: #7070A0;
  --muted2: #4A4A70;
  --border: #1E1E38;
  --border2: #2A2A48;
  --green: #00E87A;
  --red: #FF3D5A;
  --amber: #FFB800;
  --blue: #3D9EFF;
  --radius: 12px;
  --radius-sm: 8px;
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: 'Syne', sans-serif; min-height: 100vh; overflow-x: hidden; }

/* ── LOADING ── */
.loading-screen {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.loading-inner { text-align: center; width: 300px; }
.loading-logo { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-bottom: 32px; }
.loading-logo span { color: var(--accent); }
.loading-bar-wrap { height: 3px; background: var(--surface3); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.loading-bar { height: 100%; background: var(--accent); border-radius: 2px; width: 0; transition: width 0.4s ease; }
.loading-msg { font-size: 12px; color: var(--muted); font-family: 'Space Mono', monospace; }

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 100;
  gap: 16px; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.logo span { color: var(--accent); }
.live-badge {
  background: var(--accent); color: #000; font-size: 10px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; font-family: 'Space Mono', monospace;
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green { 0%,100%{opacity:1}50%{opacity:.55} }
.clock { font-size: 12px; color: var(--muted); font-family: 'Space Mono', monospace; }
.date-label { font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 4px; background: var(--surface2); padding: 5px; border-radius: var(--radius-sm); }
.tab {
  padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 700;
  cursor: pointer; border: none; background: transparent; color: var(--muted);
  transition: all .2s; font-family: 'Syne', sans-serif; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface4); color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.btn-refresh {
  padding: 7px 14px; background: transparent; border: 1px solid var(--border2);
  color: var(--muted); border-radius: var(--radius-sm); font-size: 12px;
  cursor: pointer; font-family: 'Syne', sans-serif; transition: .2s;
}
.btn-refresh:hover { border-color: var(--accent3); color: var(--text); }

/* ── LAYOUT ── */
.main-layout {
  display: grid; grid-template-columns: 1fr 320px;
  min-height: calc(100vh - 57px);
}

.left-panel { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.right-panel {
  border-left: 1px solid var(--border); padding: 20px;
  background: var(--surface); overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}

/* ── TAB PANELS ── */
.tab-panel { display: none; flex-direction: column; gap: 16px; }
.tab-panel.active { display: flex; }

/* ── METRICS ── */
.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; transition: .2s;
}
.metric:hover { border-color: var(--border2); }
.metric-label { font-size: 10px; color: var(--muted); font-family: 'Space Mono', monospace; margin-bottom: 8px; letter-spacing: 1px; }
.metric-value { font-size: 20px; font-weight: 800; line-height: 1; margin-bottom: 5px; }
.metric-change { font-size: 11px; font-family: 'Space Mono', monospace; }
.metric-name { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── CARDS ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; transition: .2s;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.section-title { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
.panel-title { font-size: 15px; font-weight: 800; }

/* ── BADGES ── */
.badge-green { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: rgba(0,232,122,.12); color: var(--green); border: 1px solid rgba(0,232,122,.25); }
.badge-red { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: rgba(255,61,90,.12); color: var(--red); border: 1px solid rgba(255,61,90,.25); }

/* ── STOCK ROWS ── */
.stock-list { display: flex; flex-direction: column; gap: 7px; }
.stock-row {
  display: grid; grid-template-columns: 36px 1fr auto auto auto;
  align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: .2s; cursor: pointer;
}
.stock-row:hover { border-color: var(--accent3); transform: translateX(2px); }
.stock-rank { font-size: 11px; color: var(--muted); font-family: 'Space Mono', monospace; font-weight: 700; }
.stock-ticker { font-size: 13px; font-weight: 700; font-family: 'Space Mono', monospace; }
.stock-name { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-price { font-size: 13px; font-weight: 700; font-family: 'Space Mono', monospace; text-align: right; }
.stock-chg { font-size: 12px; font-family: 'Space Mono', monospace; text-align: right; min-width: 64px; }
.rec { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.rec-buy { background: rgba(0,232,122,.12); color: var(--green); border: 1px solid rgba(0,232,122,.25); }
.rec-sell { background: rgba(255,61,90,.12); color: var(--red); border: 1px solid rgba(255,61,90,.25); }
.rec-hold { background: rgba(255,184,0,.12); color: var(--amber); border: 1px solid rgba(255,184,0,.25); }

/* ── UP / DOWN colors ── */
.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--amber); }

/* ── NEWS ── */
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; cursor: pointer; transition: .2s;
}
.news-item:hover { border-color: var(--accent3); }
.news-cat { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; font-family: 'Space Mono', monospace; margin-bottom: 7px; }
.cat-markets { color: var(--accent3); }
.cat-tech { color: var(--accent); }
.cat-energy { color: var(--amber); }
.cat-economy { color: var(--accent2); }
.cat-general { color: var(--muted); }
.news-title { font-size: 13px; font-weight: 600; line-height: 1.45; margin-bottom: 7px; }
.news-summary { font-size: 12px; color: var(--muted); line-height: 1.55; margin-bottom: 8px; }
.news-meta { font-size: 11px; color: var(--muted2); }
.news-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sent-pill { font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.sent-bull { background: rgba(0,232,122,.1); color: var(--green); }
.sent-bear { background: rgba(255,61,90,.1); color: var(--red); }
.sent-neut { background: rgba(255,184,0,.1); color: var(--amber); }
.news-source { font-size: 10px; color: var(--muted2); }
.impact-pill { font-size: 10px; padding: 2px 8px; border-radius: 20px; background: rgba(61,158,255,.1); color: var(--accent3); }

/* ── FILTER BUTTONS ── */
.filter-btn {
  padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border2); background: transparent; color: var(--muted);
  cursor: pointer; font-family: 'Syne', sans-serif; transition: .2s;
}
.filter-btn:hover, .filter-btn.active { background: var(--surface3); color: var(--text); border-color: var(--border2); }

/* ── HEATMAP ── */
.heat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.heat-cell {
  padding: 10px 6px; border-radius: 8px; text-align: center;
  cursor: pointer; transition: .15s; border: 1px solid transparent;
}
.heat-cell:hover { transform: scale(1.05); border-color: rgba(255,255,255,.15); }
.heat-ticker { font-size: 11px; font-weight: 700; font-family: 'Space Mono', monospace; }
.heat-val { font-size: 10px; margin-top: 3px; font-family: 'Space Mono', monospace; }

/* ── SECTOR BARS ── */
.sector-row { display: grid; grid-template-columns: 90px 1fr 54px; align-items: center; gap: 10px; margin-bottom: 8px; }
.sector-name { font-size: 11px; color: var(--muted); }
.sector-bar-bg { background: var(--surface3); border-radius: 2px; height: 6px; overflow: hidden; }
.sector-bar-fill { height: 100%; border-radius: 2px; transition: width .8s ease; }
.sector-val { font-size: 11px; font-family: 'Space Mono', monospace; text-align: right; }

/* ── AI SIGNALS ── */
.signal-card { border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.signal-buy { background: rgba(0,232,122,.06); border: 1px solid rgba(0,232,122,.2); }
.signal-sell { background: rgba(255,61,90,.06); border: 1px solid rgba(255,61,90,.2); }
.signal-hold { background: rgba(255,184,0,.06); border: 1px solid rgba(255,184,0,.2); }
.signal-action { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin-bottom: 4px; }
.signal-ticker { font-size: 16px; font-weight: 800; font-family: 'Space Mono', monospace; margin-bottom: 6px; }
.signal-reason { font-size: 11px; color: var(--muted); line-height: 1.5; }
.signal-score-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.score-bar { flex: 1; height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 2px; }
.score-fill.buy { background: var(--green); }
.score-fill.sell { background: var(--red); }
.score-fill.hold { background: var(--amber); }
.score-num { font-size: 11px; font-family: 'Space Mono', monospace; font-weight: 700; min-width: 28px; text-align: right; }

/* ── REPORT ── */
.report-placeholder { text-align: center; padding: 60px 20px; color: var(--muted); }
.report-content { min-height: 300px; }
.report-section { margin-bottom: 24px; }
.report-section h2 { font-size: 14px; font-weight: 700; color: var(--accent); margin-bottom: 12px; letter-spacing: 1px; text-transform: uppercase; }
.report-section p { font-size: 13px; color: var(--text); line-height: 1.7; margin-bottom: 8px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report-table th { text-align: left; padding: 8px 12px; background: var(--surface3); color: var(--muted); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.report-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-family: 'Space Mono', monospace; font-size: 12px; }
.report-table tr:hover td { background: var(--surface2); }
.report-generated { font-size: 10px; color: var(--muted); font-family: 'Space Mono', monospace; margin-bottom: 20px; }

.btn-gen {
  padding: 10px 18px; background: var(--accent); color: #000;
  border: none; border-radius: var(--radius-sm); font-family: 'Syne', sans-serif;
  font-size: 12px; font-weight: 700; cursor: pointer; transition: .2s; white-space: nowrap;
}
.btn-gen:hover { opacity: .85; transform: translateY(-1px); }
.btn-gen:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); }

/* ── SKELETONS ── */
.skeleton { animation: shimmer 1.5s infinite; }
.skeleton-row { height: 54px; background: var(--surface2); border-radius: var(--radius-sm); margin-bottom: 7px; animation: shimmer 1.5s infinite; border: 1px solid var(--border); }
@keyframes shimmer { 0%{opacity:.6}50%{opacity:1}100%{opacity:.6} }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .main-layout { grid-template-columns: 1fr; }
  .right-panel { border-left: none; border-top: 1px solid var(--border); }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .tabs { flex-wrap: wrap; }
  .tab { font-size: 11px; padding: 6px 10px; }
  .heat-grid { grid-template-columns: repeat(4, 1fr); }
  .stock-row { grid-template-columns: 28px 1fr auto auto; }
  .stock-row .rec { display: none; }
}

/* ── TYPING CURSOR for AI text ── */
.typing::after { content: '|'; animation: blink .7s infinite; color: var(--accent); }
@keyframes blink { 0%,100%{opacity:1}50%{opacity:0} }

/* ── TOOLTIP ── */
.tooltip { position: relative; }
.tooltip-text { visibility: hidden; position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%); background: var(--surface3); color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 11px; white-space: nowrap; z-index: 50; border: 1px solid var(--border2); }
.tooltip:hover .tooltip-text { visibility: visible; }

/* ── ERROR BANNER ── */
.error-banner { background: rgba(255,61,90,.1); border: 1px solid rgba(255,61,90,.25); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12px; color: var(--red); margin-bottom: 10px; display: none; }

/* news ticker */
.ticker-wrap { overflow: hidden; background: var(--surface2); border-bottom: 1px solid var(--border); padding: 8px 0; }
.ticker-content { display: flex; gap: 48px; animation: ticker 40s linear infinite; white-space: nowrap; font-size: 12px; font-family: 'Space Mono', monospace; color: var(--muted); padding-left: 100%; }
@keyframes ticker { from{transform:translateX(0)}to{transform:translateX(-100%)} }
.ticker-content span { color: var(--text); }
.ticker-sep { color: var(--accent); }
