:root {
  --bg: #06080f;
  --bg-surface: #0a0d16;
  --bg-card: #0e1220;
  --fg: #e8edf5;
  --fg-muted: #7a8699;
  --accent: #00ff88;
  --accent-dim: rgba(0, 255, 136, 0.12);
  --accent-glow: rgba(0, 255, 136, 0.25);
  --danger: #ff4455;
  --warning: #ffaa00;
  --secondary: #8844ff;
  --border: rgba(255, 255, 255, 0.07);
  --font-head: 'Syne', sans-serif;
  --font-body: 'Manrope', sans-serif;
  --radius: 12px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* NAV */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: rgba(6, 8, 15, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
}
.nav-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.nav-tabs { display: flex; gap: 4px; margin-left: 40px; }
.nav-tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
}
.nav-tab:hover { color: var(--fg); background: var(--bg-card); }
.nav-tab.active { color: var(--accent); background: var(--accent-dim); }
.nav-status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-muted); }
.status-dot.live { background: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }

/* LAYOUT */
.app-layout { padding-top: 56px; min-height: 100vh; display: grid; grid-template-columns: 300px 1fr; grid-template-rows: auto 1fr; gap: 0; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  grid-row: 1 / 3;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar-section { display: flex; flex-direction: column; gap: 8px; }
.sidebar-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 4px; }

/* PORTFOLIO SUMMARY CARD */
.portfolio-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.pnl-total { font-size: 28px; font-weight: 700; font-family: var(--font-head); letter-spacing: -0.03em; }
.pnl-pos { color: var(--accent); }
.pnl-neg { color: var(--danger); }
.pnl-pct { font-size: 13px; color: var(--fg-muted); margin-top: 2px; }

/* VENUES */
.venue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.venue-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}
.badge-hl { background: rgba(0, 255, 136, 0.15); color: var(--accent); }
.badge-aster { background: rgba(136, 68, 255, 0.15); color: var(--secondary); }
.badge-lighter { background: rgba(255, 170, 0, 0.15); color: var(--warning); }
.venue-name { font-weight: 500; font-size: 13px; flex: 1; }
.venue-status { font-size: 11px; color: var(--fg-muted); }

.add-venue-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  width: 100%;
}
.add-venue-btn:hover { border-color: var(--accent); color: var(--accent); }

/* POSITIONS LIST */
.position-item {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.position-header { display: flex; justify-content: space-between; align-items: center; }
.pos-symbol { font-weight: 600; font-size: 13px; }
.pos-side { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 6px; border-radius: 3px; }
.side-long { background: rgba(0, 255, 136, 0.12); color: var(--accent); }
.side-short { background: rgba(255, 68, 85, 0.12); color: var(--danger); }
.pos-pnl { font-size: 13px; font-weight: 600; }
.pos-pnl.pos { color: var(--accent); }
.pos-pnl.neg { color: var(--danger); }
.pos-size { font-size: 11px; color: var(--fg-muted); }
.pos-venue-tag { font-size: 10px; color: var(--fg-muted); background: var(--bg-surface); padding: 1px 6px; border-radius: 3px; }

/* MAIN CONTENT */
.main-content { overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* PANEL */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-family: var(--font-head); font-weight: 600; font-size: 14px; }
.panel-body { padding: 20px; }

/* SKILL CHAT */
.skill-container { display: flex; flex-direction: column; height: calc(100vh - 56px - 48px); }
.messages-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 10px; max-width: 80%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.msg.user .msg-avatar { background: var(--accent-dim); color: var(--accent); }
.msg.assistant .msg-avatar { background: var(--secondary); color: white; }
.msg-content { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.5; }
.msg.user .msg-content { background: var(--accent-dim); color: var(--fg); border: 1px solid rgba(0, 255, 136, 0.2); }
.msg.assistant .msg-content { background: var(--bg-surface); color: var(--fg); border: 1px solid var(--border); }
.msg-content code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.msg-content pre { background: var(--bg); padding: 10px; border-radius: var(--radius-sm); overflow-x: auto; margin-top: 6px; font-size: 12px; }

/* INPUT AREA */
.input-area { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.chat-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  resize: none;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--fg-muted); }
.send-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* WELCOME STATE */
.welcome-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 16px; text-align: center; padding: 40px; }
.welcome-icon { font-size: 48px; }
.welcome-title { font-family: var(--font-head); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.welcome-sub { color: var(--fg-muted); font-size: 14px; max-width: 400px; line-height: 1.6; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.qa-btn {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.qa-btn:hover { border-color: var(--accent); color: var(--accent); }

/* POSITIONS TABLE */
.pos-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pos-table th { text-align: left; padding: 8px 12px; color: var(--fg-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); }
.pos-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pos-table tr:last-child td { border-bottom: none; }
.pos-table tr:hover td { background: var(--bg-surface); }

/* LOADING */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 13px; }

/* CONNECT MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(6, 8, 15, 0.85); z-index: 200; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 420px; max-width: 90vw; }
.modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { color: var(--fg-muted); font-size: 13px; margin-bottom: 20px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--fg-muted); }
.form-input, .form-select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-hint { font-size: 11px; color: var(--fg-muted); margin-top: 4px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.btn-secondary { padding: 9px 20px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--fg); font-size: 13px; cursor: pointer; }
.btn-primary { padding: 9px 20px; background: var(--accent); border: none; border-radius: var(--radius-sm); color: #000; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { opacity: 0.85; }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 300;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.error { border-color: rgba(255, 68, 85, 0.4); }
.toast.success { border-color: rgba(0, 255, 136, 0.4); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 40px 20px; color: var(--fg-muted); }
.empty-state p { margin-bottom: 16px; }

/* Section title */
.section-title { font-family: var(--font-head); font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }

/* Scrollable area for messages */
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }