:root {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #182032;
  --border: #243047;
  --text: #e6edf7;
  --muted: #8b9bb4;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand h1 { font-size: 17px; font-weight: 600; }
.subtitle { color: var(--muted); font-size: 12px; }

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

select, .btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-ok { background: rgba(34, 197, 94, 0.16); color: var(--green); }
.badge-warn { background: rgba(245, 158, 11, 0.16); color: var(--amber); }
.badge-err { background: rgba(239, 68, 68, 0.16); color: var(--red); }
.badge-info { background: rgba(56, 189, 248, 0.16); color: var(--accent); }
.badge-muted { background: rgba(139, 155, 180, 0.16); color: var(--muted); }

.meta-text { color: var(--muted); font-size: 12px; }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 24px; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.pos { color: var(--green); }
.neg { color: var(--red); }

.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; }
}

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

.card-header h2 { font-size: 15px; font-weight: 600; }

.window-pills { display: flex; gap: 4px; }
.window-pills button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.window-pills button:hover { color: var(--text); }
.window-pills button.active {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--border);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;
  background: rgba(11, 15, 23, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

#equity-chart { width: 100%; height: 100%; display: block; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(18, 24, 38, 0.96);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10;
}
.hidden { display: none; }

.live-feed {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-item {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
}
.feed-item.type-equity_alert { border-left-color: var(--amber); }
.feed-item.type-fill { border-left-color: var(--green); }
.feed-item.type-order_update { border-left-color: #a855f7; }
.feed-item.type-fund_flow { border-left-color: #38bdf8; }

.feed-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.tabs button.active {
  background: var(--surface-2);
  color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.flow-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.flow-summary { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(36, 48, 71, 0.7);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
tr:hover td { background: rgba(255, 255, 255, 0.02); }

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

code.hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}
