:root {
  --bg: #f4f7f9;
  --card: #ffffff;
  --text: #222;
  --muted: #6b7280;
  --primary: #0d6efd;
  --primary-700: #0b5ed7;
  --border: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
}

/* Dark mode */
.dark {
  --bg: #0e1116;
  --card: #151922;
  --text: #e5e7eb;
  --muted: #9aa3b2;
  --primary: #60a5fa;
  --primary-700: #3b82f6;
  --border: #1f2530;
  --shadow: 0 2px 16px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; gap: 10px; }

.container {
  display: grid;
  gap: 20px;
  grid-template-columns: 300px 1fr;
  padding: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.list-section { position: sticky; top: 64px; height: calc(100dvh - 84px); }
.list-header { margin-bottom: 10px; }
.list-header input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}

.list { overflow: auto; max-height: calc(100% - 44px); border-radius: 10px; }
.list-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.list-item:hover { background: rgba(0,0,0,.04); }
.dark .list-item:hover { background: rgba(255,255,255,.04); }

.badge { font-size: 12px; opacity: .85; }
.symbol { font-weight: 700; }
.name { font-size: 12px; color: var(--muted); }

.main { display: grid; gap: 20px; }
.chart-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

.btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--primary);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; color: var(--text); }

.range-btn.active { background: var(--primary-700); }

.chart-wrap { position: relative; height: 360px; }
.peak-low { margin-top: 10px; font-size: 14px; color: var(--muted); }

.details-header { display: flex; align-items: baseline; gap: 10px; }
.details-header h2 { margin: 0; }
.muted { color: var(--muted); }
.summary { line-height: 1.5; }

.details-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 320px;
}

.field { display: grid; gap: 6px; }
.field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
}

.portfolio { border-left: 1px dashed var(--border); padding-left: 16px; }
.portfolio-metrics p { margin: 8px 0; }

.pill { padding: 2px 8px; border-radius: 999px; }
.green { color: var(--green); }
.red { color: var(--red); }

.footer { padding: 20px; text-align: center; color: var(--muted); }

/* Responsive */
@media (max-width: 980px) {
  .container { grid-template-columns: 1fr; }
  .list-section { position: static; height: auto; }
  .details-grid { grid-template-columns: 1fr; }
  .portfolio { border-left: none; padding-left: 0; border-top: 1px dashed var(--border); padding-top: 16px; }
}
