:root {
  --bg: #0b0f17;
  --surface: #111827;
  --surface-2: #161f30;
  --border: #233046;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #10b981;
  --red: #f43f5e;
  --amber: #f59e0b;
  --purple: #a78bfa;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  height: 58px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status-pill.status-complete {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.status-pill.status-running {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
}

.universe-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.univ-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.univ-btn.active {
  background: var(--accent);
  color: #082f49;
}

.univ-btn:not(.active):hover {
  color: var(--text);
}

.ghost-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 58px);
  overflow: hidden;
}

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

.sidebar-controls {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

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

.sort-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sort-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

.strategy-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.strat-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 11px;
  margin-bottom: 4px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s, border-color 0.12s;
}

.strat-item:hover {
  background: var(--surface-2);
}

.strat-item.selected {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
}

.strat-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.strat-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strat-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.strat-item-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.detail-panel {
  overflow-y: auto;
  padding: 18px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.badge-accent {
  border-color: rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
}

.badge-amber {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
}

.badge-red {
  border-color: rgba(244, 63, 94, 0.4);
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
}

.badge-green {
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
}

.detail-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 820px;
}

.comparison-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.comp-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}

.comp-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comp-val {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.comp-sub {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.chart-and-pit {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 16px;
  align-items: start;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tf-group {
  display: inline-flex;
  gap: 4px;
}

.tf-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tf-btn.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent);
  color: var(--text);
}

.overlay-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.overlay-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 310px;
  user-select: none;
}

.chart-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.chart-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.jump-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.jump-pill {
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.jump-pill:hover {
  background: rgba(245, 158, 11, 0.22);
}

.pit-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pit-date {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.pit-mode {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.pit-mode.hover {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.pit-mode.pinned {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.pit-nav-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.holdings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 245px;
  overflow-y: auto;
}

.holding-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.holding-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.holding-ticker {
  font-family: var(--mono);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.holding-ticker.cash {
  color: #6ee7b7;
}

.holding-bar-bg {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.holding-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.holding-bar-fill.cash {
  background: var(--green);
}

.holding-bar-fill.delisted {
  background: var(--amber);
}

.holding-total {
  display: flex;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lower-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 8px;
}

.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
}

.stat-value {
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.events-table th, .events-table td {
  text-align: left;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
}

.events-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  padding: 18px 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-body ul {
  padding-left: 18px;
  margin: 10px 0 0;
}

.modal-body li {
  margin-bottom: 8px;
  color: #cbd5e1;
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 280px 1fr; }
  .chart-and-pit { grid-template-columns: 1fr; }
  .lower-grid { grid-template-columns: 1fr; }
}
