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

:root {
  --bg: #0b0e13;
  --bg2: #11151d;
  --bg3: #161b26;
  --border: #1e2535;
  --text: #e2e8f0;
  --muted: #64748b;
  --green: #00c47a;
  --red: #f03e5f;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #a855f7;
  --font-mono: 'DM Mono', monospace;
  --font-display: 'Syne', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.1em;
  color: var(--green);
}

.logo span { color: var(--text); }

.nav-tabs { display: flex; gap: 4px; }

.nav-tab {
  padding: 6px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.nav-tab:hover { color: var(--text); background: var(--bg3); }
.nav-tab.active { color: var(--green); background: rgba(0,196,122,0.1); }

.indices { display: flex; gap: 20px; margin-left: auto; }

.index-item { display: flex; flex-direction: column; align-items: flex-end; }
.index-name { font-size: 10px; color: var(--muted); }
.index-price { font-size: 12px; font-weight: 500; }
.index-change { font-size: 10px; }

.up { color: var(--green); }
.down { color: var(--red); }

/* LAYOUT */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 200px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section h4 {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 8px;
}

.filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: all 0.15s;
}

.filter-btn:hover { color: var(--text); background: var(--bg3); }
.filter-btn.active { color: var(--text); background: var(--bg3); border-left: 2px solid var(--green); }

.sentiment-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* MAIN CONTENT */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}

.btn {
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { border-color: var(--green); color: var(--green); }
.btn.primary { background: rgba(0,196,122,0.15); border-color: var(--green); color: var(--green); }
.btn.primary:hover { background: rgba(0,196,122,0.25); }
.btn.danger { background: rgba(240,62,95,0.1); border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(240,62,95,0.2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.active { background: rgba(0,196,122,0.2); border-color: var(--green); color: var(--green); }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(0,196,122,0.3);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-text { font-size: 11px; color: var(--muted); margin-left: auto; }

/* TABLE */
.table-wrap { flex: 1; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(30,37,53,0.5);
  cursor: pointer;
  transition: background 0.1s;
}

tbody tr:hover { background: var(--bg2); }

td {
  padding: 9px 12px;
  white-space: nowrap;
  vertical-align: middle;
}

.asset-cell { display: flex; flex-direction: column; }
.asset-ticker { font-weight: 500; font-size: 13px; }
.asset-name { font-size: 10px; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

.signal-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.signal-BUY { background: rgba(0,196,122,0.15); color: var(--green); }
.signal-SELL { background: rgba(240,62,95,0.15); color: var(--red); }
.signal-HOLD { background: rgba(100,116,139,0.15); color: var(--muted); }
.signal-WATCH { background: rgba(245,158,11,0.15); color: var(--yellow); }

.sentiment-bar-wrap { width: 80px; }
.sentiment-bar-bg { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.sentiment-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

.sentiment-BULLISH .sentiment-bar-fill { background: var(--green); }
.sentiment-BEARISH .sentiment-bar-fill { background: var(--red); }
.sentiment-NEUTRAL .sentiment-bar-fill { background: var(--muted); }

.verdict-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }

/* DRAWER */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 400px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.drawer-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.drawer-close:hover { color: var(--text); }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.stat-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 15px; font-weight: 500; }

.sparkline-wrap { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.sparkline-wrap h4 { font-size: 11px; color: var(--muted); margin-bottom: 10px; }

canvas { display: block; }

.analysis-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.analysis-box h4 { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.analysis-text { font-size: 12px; color: var(--text); line-height: 1.7; }

/* TRADER PAGE */
.trader-body {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  flex: 1;
  overflow: hidden;
}

.panel {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title { font-family: var(--font-display); font-size: 13px; font-weight: 600; }
.panel-subtitle { font-size: 10px; color: var(--muted); margin-top: 2px; }

.panel-body { flex: 1; overflow-y: auto; padding: 16px; }

.equity-big { font-family: var(--font-display); font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.equity-sub { font-size: 12px; color: var(--muted); }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }

.metric-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}

.metric-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.metric-value { font-size: 14px; font-weight: 500; margin-top: 2px; }

.positions-list { margin-top: 16px; }
.positions-list h4 { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }

.position-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pos-ticker { font-weight: 500; font-size: 13px; flex: 1; }
.pos-info { font-size: 10px; color: var(--muted); }
.pos-pnl { font-size: 12px; font-weight: 500; }

.close-pos-btn {
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(240,62,95,0.3);
  background: rgba(240,62,95,0.08);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.close-pos-btn:hover { background: rgba(240,62,95,0.2); }

/* LOG */
.log-panel { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.log-entries { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.log-entry {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.log-entry-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.log-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.log-tag-BUY { background: rgba(0,196,122,0.15); color: var(--green); }
.log-tag-CLOSE { background: rgba(240,62,95,0.15); color: var(--red); }
.log-tag-HOLD { background: rgba(100,116,139,0.15); color: var(--muted); }
.log-tag-MACRO { background: rgba(168,85,247,0.15); color: var(--purple); }
.log-tag-SYS { background: rgba(59,130,246,0.15); color: var(--blue); }

.log-ticker { font-weight: 600; font-size: 14px; }
.log-time { font-size: 10px; color: var(--muted); margin-left: auto; }
.log-reasoning { font-size: 12px; color: var(--muted); line-height: 1.6; }

.log-meta { display: flex; gap: 16px; margin-top: 8px; font-size: 10px; }
.log-meta-item { display: flex; flex-direction: column; gap: 1px; }
.log-meta-label { color: var(--muted); }
.log-meta-value { font-weight: 500; }

/* RIGHT PANEL */
.right-panel { display: flex; flex-direction: column; overflow: hidden; }

.watchlist-section { flex-shrink: 0; }

.watchlist-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(30,37,53,0.5);
  gap: 8px;
}

.wl-ticker { font-weight: 500; flex: 1; }
.wl-price { font-size: 12px; }
.wl-change { font-size: 11px; min-width: 60px; text-align: right; }

.equity-curve-section {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.equity-curve-section h4 { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 12px; }
