:root {
  /* Dark Theme (default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a1f2e;
  --bg-card-hover: #222838;
  --bg-glass: rgba(26, 31, 46, 0.7);
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 199, 255, 0.2);
  --header-bg: rgba(10, 14, 23, 0.8);
  --hover-bg: rgba(255,255,255,0.04);
  --portfolio-bg: rgba(255,255,255,0.02);
  --table-hover: rgba(255,255,255,0.02);
  --table-border: rgba(255,255,255,0.03);
  --scrollbar-thumb: rgba(255,255,255,0.08);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);

  --text-primary: #f0f4ff;
  --text-secondary: #8b95a9;
  --text-muted: #4a5568;

  --accent: #00c7ff;
  --accent-glow: rgba(0, 199, 255, 0.15);
  --accent-gradient: linear-gradient(135deg, #00c7ff, #7b61ff);
  --profit: #00e68a;
  --profit-bg: rgba(0, 230, 138, 0.1);
  --loss: #ff4d6a;
  --loss-bg: rgba(255, 77, 106, 0.1);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Layout */
  --sidebar-w: 240px;
  --header-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

/* ═══════════════════════════════════════════════
   Light Theme (from landing page)
   ═══════════════════════════════════════════════ */

[data-theme="light"] {
  --bg-primary: #f0f7ff;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.6);
  --border: rgba(0, 120, 220, 0.1);
  --border-accent: rgba(0, 120, 220, 0.25);
  --header-bg: rgba(240, 247, 255, 0.85);
  --hover-bg: rgba(0, 120, 220, 0.04);
  --portfolio-bg: rgba(0, 120, 220, 0.03);
  --table-hover: rgba(0, 120, 220, 0.03);
  --table-border: rgba(0, 120, 220, 0.06);
  --scrollbar-thumb: rgba(0, 120, 220, 0.15);
  --shadow: 0 8px 32px rgba(0, 80, 180, 0.08);

  --text-primary: #1a2d4a;
  --text-secondary: #5a7294;
  --text-muted: #8da2be;

  --accent: #0077dd;
  --accent-glow: rgba(0, 119, 221, 0.1);
  --accent-gradient: linear-gradient(135deg, #0099ff, #6c5ce7);
  --profit: #10b981;
  --profit-bg: rgba(16, 185, 129, 0.1);
  --loss: #ef4444;
  --loss-bg: rgba(239, 68, 68, 0.1);
}

/* Light-theme specific overrides */
[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #e8f0fe, #f0f7ff);
  border-right: 1px solid rgba(0, 120, 220, 0.08);
}

[data-theme="light"] .stat-card,
[data-theme="light"] .card {
  box-shadow: 0 2px 12px rgba(0, 80, 180, 0.06);
  border: 1px solid rgba(0, 120, 220, 0.08);
}

[data-theme="light"] .input-wrap {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 120, 220, 0.15);
}

[data-theme="light"] .network-badge {
  background: rgba(0, 119, 221, 0.08);
  color: #0077dd;
}

[data-theme="light"] .side-badge.long {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

[data-theme="light"] .side-badge.short {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

[data-theme="light"] .action-tab.active {
  background: #0077dd;
}

[data-theme="light"] .nav-item:hover,
[data-theme="light"] .nav-item.active {
  background: rgba(0, 119, 221, 0.08);
}

[data-theme="light"] .wallet-modal {
  box-shadow: 0 16px 48px rgba(0, 80, 180, 0.15);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════ */

.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

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

.sidebar-logo .logo-img {
  width: 36px; height: 36px;
  border-radius: 10px;
  object-fit: contain;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo .version {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

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

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

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

.vault-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 230, 138, 0.06);
  border: 1px solid rgba(0, 230, 138, 0.15);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--profit);
}

.vault-status .pulse {
  width: 8px; height: 8px;
  background: var(--profit);
  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 Content
   ═══════════════════════════════════════════════ */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* Header */
.header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.header-left h2 {
  font-size: 18px;
  font-weight: 600;
}

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

.network-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(0, 199, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 199, 255, 0.2);
}

.connect-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.connect-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0, 199, 255, 0.3); }
.connect-btn.connected { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.connect-btn.connected .wallet-dot { width: 8px; height: 8px; background: var(--profit); border-radius: 50%; }

/* Theme Toggle */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.3s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: rotate(30deg);
}

/* Content area */
.content { padding: 32px; }

/* ═══════════════════════════════════════════════
   Stats Cards
   ═══════════════════════════════════════════════ */

.stats-grid {
  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;
  transition: all 0.3s;
}

.stat-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-value.accent { color: var(--accent); }
.stat-value.profit { color: var(--profit); }
.stat-value.loss { color: var(--loss); }

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.stat-change.up { color: var(--profit); background: var(--profit-bg); }
.stat-change.down { color: var(--loss); background: var(--loss-bg); }

/* ═══════════════════════════════════════════════
   Card Containers
   ═══════════════════════════════════════════════ */

.cards-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

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

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

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ═══════════════════════════════════════════════
   NAV Chart
   ═══════════════════════════════════════════════ */

.chart-container {
  width: 100%;
  height: 260px;
  position: relative;
}

.chart-canvas {
  width: 100%;
  height: 100%;
}

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

.period-tab {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  background: none;
  border: none;
  font-family: var(--font);
}

.period-tab:hover { color: var(--text-secondary); }
.period-tab.active { color: var(--accent); background: var(--accent-glow); }

/* ═══════════════════════════════════════════════
   Trades Table
   ═══════════════════════════════════════════════ */

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

.trades-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.trades-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--table-border);
  font-family: var(--font-mono);
  font-weight: 400;
}

.trades-table tr:hover td {
  background: var(--table-hover);
}

.pair-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-family: var(--font);
}

.pair-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--hover-bg);
}

.side-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.side-badge.long { color: var(--profit); background: var(--profit-bg); }
.side-badge.short { color: var(--loss); background: var(--loss-bg); }

.pnl-cell { font-weight: 600; }
.pnl-cell.profit { color: var(--profit); }
.pnl-cell.loss { color: var(--loss); }

.tx-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.tx-link:hover { opacity: 1; text-decoration: underline; }

/* ═══════════════════════════════════════════════
   Deposit / Withdraw Panel
   ═══════════════════════════════════════════════ */

.action-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.action-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: var(--font);
}

.action-tab:hover { color: var(--text-secondary); }
.action-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.action-form { padding: 20px; }

.input-group {
  margin-bottom: 16px;
}

.input-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-label .balance-hint {
  color: var(--accent);
  cursor: pointer;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within { border-color: var(--accent); }

.input-wrap input {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  outline: none;
}

.input-wrap input::placeholder { color: var(--text-muted); }

.input-suffix {
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.max-btn {
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--accent-glow);
  color: var(--accent);
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}

.conversion-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.submit-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  margin-top: 8px;
}

.submit-btn.deposit {
  background: var(--accent-gradient);
  color: #000;
}

.submit-btn.withdraw {
  background: linear-gradient(135deg, #ff4d6a, #ff8f3f);
  color: #000;
}

.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ═══════════════════════════════════════════════
   Portfolio Section
   ═══════════════════════════════════════════════ */

.portfolio-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.portfolio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--portfolio-bg);
  border-radius: var(--radius-sm);
}

.portfolio-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portfolio-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.portfolio-icon.chiller { background: var(--accent-glow); }
.portfolio-icon.sol { background: rgba(123, 97, 255, 0.15); }

.portfolio-name { font-size: 13px; font-weight: 600; }
.portfolio-sub { font-size: 11px; color: var(--text-muted); }
.portfolio-value { text-align: right; }
.portfolio-amount { font-size: 14px; font-weight: 600; font-family: var(--font-mono); }
.portfolio-usd { font-size: 11px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════
   Pages (hidden by default)
   ═══════════════════════════════════════════════ */

.page { display: none; }
.page.active { display: block; }

/* ═══════════════════════════════════════════════
   Wallet Modal
   ═══════════════════════════════════════════════ */

.wallet-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
}

.wallet-modal-overlay.show {
  display: flex;
}

.wallet-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow);
  animation: scaleIn 0.25s ease;
  overflow: hidden;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wallet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.wallet-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.wallet-modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.wallet-modal-close:hover {
  background: var(--loss-bg);
  color: var(--loss);
  border-color: var(--loss);
}

.wallet-modal-body {
  padding: 12px;
}

.wallet-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  color: var(--text-primary);
}

.wallet-option:hover {
  background: var(--hover-bg);
  border-color: var(--border-accent);
}

.wallet-option-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wallet-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
}

.wallet-icon.phantom, .wallet-icon.solflare, .wallet-icon.backpack { background: none; }
.wallet-icon svg { width: 40px; height: 40px; }
.wallet-icon.demo-icon { background: var(--accent-glow); }

.wallet-option-name {
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.wallet-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
}

.wallet-detect {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.wallet-detect.detected {
  color: var(--profit);
  background: var(--profit-bg);
}

.wallet-detect.not-detected {
  color: var(--text-muted);
  background: var(--hover-bg);
}

.wallet-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

.wallet-option.demo {
  opacity: 0.7;
}

.wallet-option.demo:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
  .content { padding: 16px; }
  .menu-toggle { display: flex; }
}

/* ═══════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-card, .card { animation: fadeInUp 0.4s ease forwards; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* 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;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(0, 230, 138, 0.3); }
.toast.error { border-color: rgba(255, 77, 106, 0.3); }

/* Theme transition */
body, .sidebar, .header, .stat-card, .card, .toast, .input-wrap, .nav-item {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
