/* ---------- Trader Pro — design system ---------- */
:root {
  --font-sans: 'Inter Tight', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Surface scale (dark pro, default) */
  --bg: oklch(0.17 0.008 260);
  --bg-1: oklch(0.21 0.009 260);
  --bg-2: oklch(0.25 0.010 260);
  --bg-3: oklch(0.29 0.011 260);
  --line: oklch(0.32 0.012 260);
  --line-soft: oklch(0.26 0.010 260 / 0.6);

  --fg: oklch(0.96 0.005 260);
  --fg-1: oklch(0.82 0.008 260);
  --fg-2: oklch(0.62 0.010 260);
  --fg-3: oklch(0.46 0.010 260);

  --pos: oklch(0.76 0.14 155);
  --pos-soft: oklch(0.76 0.14 155 / 0.16);
  --neg: oklch(0.68 0.14 25);
  --neg-soft: oklch(0.68 0.14 25 / 0.16);
  --warn: oklch(0.80 0.12 75);
  --warn-soft: oklch(0.80 0.12 75 / 0.16);
  --info: oklch(0.74 0.10 240);
  --info-soft: oklch(0.74 0.10 240 / 0.16);

  --r-sm: 4px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --row-h: 36px;
  --nav-h: 56px;
  --sub-h: 48px;

  --shadow: 0 1px 0 0 oklch(1 0 0 / 0.02) inset, 0 1px 2px oklch(0 0 0 / 0.3);
}

/* Editorial / light */
body[data-theme="editorial"] {
  --bg: oklch(0.98 0.005 80);
  --bg-1: oklch(0.96 0.006 80);
  --bg-2: oklch(0.93 0.007 80);
  --bg-3: oklch(0.90 0.008 80);
  --line: oklch(0.85 0.010 80);
  --line-soft: oklch(0.90 0.008 80);
  --fg: oklch(0.20 0.010 260);
  --fg-1: oklch(0.38 0.010 260);
  --fg-2: oklch(0.54 0.010 260);
  --fg-3: oklch(0.66 0.010 260);
  --pos: oklch(0.52 0.14 155);
  --pos-soft: oklch(0.52 0.14 155 / 0.14);
  --neg: oklch(0.54 0.16 25);
  --neg-soft: oklch(0.54 0.16 25 / 0.14);
  --warn: oklch(0.62 0.14 75);
  --warn-soft: oklch(0.62 0.14 75 / 0.14);
  --info: oklch(0.52 0.12 240);
  --info-soft: oklch(0.52 0.12 240 / 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "ss02";
  letter-spacing: -0.005em;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line); }

/* App shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Top nav */
.nav {
  height: var(--nav-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 20px; gap: 24px;
  position: sticky; top: 0; z-index: 20;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  color: var(--fg); text-decoration: none;
}
.nav-brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--pos), var(--info));
  position: relative;
}
.nav-brand-mark::after {
  content: ""; position: absolute; inset: 4px;
  background: var(--bg); border-radius: 3px;
}
.nav-tabs { display: flex; gap: 2px; margin-left: 12px; }
.nav-tab {
  padding: 6px 12px; border-radius: 6px;
  color: var(--fg-2); font-size: 13px;
  cursor: pointer; border: none; background: transparent;
  font-family: inherit; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.nav-tab:hover { background: var(--bg-2); color: var(--fg-1); }
.nav-tab.active { background: var(--bg-2); color: var(--fg); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.clock {
  font-family: var(--font-mono); font-size: 12px; color: var(--fg-2);
  padding: 6px 10px; border: 1px solid var(--line-soft); border-radius: 6px;
  display: flex; align-items: center; gap: 8px;
}
.clock-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 8px var(--pos); }
.clock-dot.closed { background: var(--fg-3); box-shadow: none; }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: transparent; border: 1px solid var(--line-soft);
  color: var(--fg-1); border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.theme-toggle:hover { background: var(--bg-1); border-color: var(--line); color: var(--fg); }
.theme-toggle .icon-sun { display: none; }
body[data-theme="editorial"] .theme-toggle .icon-moon { display: none; }
body[data-theme="editorial"] .theme-toggle .icon-sun { display: inline; }

/* Account switcher */
.acct {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line-soft); border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--fg-1);
  min-width: 180px;
  background: transparent;
  font-family: inherit;
}
.acct:hover { border-color: var(--line); background: var(--bg-1); }
.acct-label { color: var(--fg-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.acct-num { font-family: var(--font-mono); color: var(--fg); }
.acct-caret { margin-left: auto; color: var(--fg-3); }
.acct-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px;
  min-width: 280px; box-shadow: 0 8px 24px oklch(0 0 0 / 0.4);
  padding: 6px; z-index: 30;
  display: none;
}
.acct-menu.open { display: block; }
.acct-opt {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 10px; border-radius: 6px; cursor: pointer;
  gap: 16px; text-decoration: none; color: var(--fg-1);
}
.acct-opt:hover { background: var(--bg-2); color: var(--fg); }
.acct-opt.active { background: var(--bg-2); color: var(--fg); }
.acct-opt-meta { display: flex; flex-direction: column; gap: 2px; }
.acct-opt-label { font-size: 13px; color: var(--fg); }
.acct-opt-num { font-family: var(--font-mono); font-size: 11px; color: var(--fg-2); }

/* Subheader */
.subhead {
  height: var(--sub-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  position: sticky; top: var(--nav-h); z-index: 15;
}
.subhead h1 {
  margin: 0; font-size: 14px; font-weight: 500;
  color: var(--fg-1); letter-spacing: -0.01em;
}
.subhead-sep { width: 1px; height: 20px; background: var(--line); }
.crumb { font-size: 12px; color: var(--fg-2); }
.subhead-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Page body */
.page { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

/* Cards */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-hd {
  padding: 14px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
  gap: 16px;
}
.card-hd > div:first-child { min-width: 0; flex: 1; }
.card-title { font-size: 12px; font-weight: 500; color: var(--fg-2); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.card-sub { font-size: 12px; color: var(--fg-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { padding: 16px; }
.card-body--tight { padding: 0; }

/* Stat block */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 11px; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-val { font-family: var(--font-mono); font-size: 22px; color: var(--fg); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-family: var(--font-mono); font-size: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--line-soft); background: transparent;
  color: var(--fg-1); font-size: 12px; font-family: inherit;
  cursor: pointer; letter-spacing: -0.005em;
  text-decoration: none;
}
.btn:hover { background: var(--bg-2); border-color: var(--line); color: var(--fg); }
.btn.active { background: var(--bg-2); color: var(--fg); border-color: var(--line); }
.btn--primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn--primary:hover { background: var(--fg-1); color: var(--bg); }

/* Pills & badges */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.02em;
  background: var(--bg-2); color: var(--fg-1); border: 1px solid var(--line-soft);
}
.pill--pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.pill--neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill--info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill--ghost { background: transparent; color: var(--fg-2); }

/* Chip row */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* Table */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-family: inherit; }
.tbl thead th {
  position: sticky; top: 0; background: var(--bg-1);
  font-size: 10px; font-weight: 500; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 0 12px; height: var(--row-h);
  font-size: 13px; color: var(--fg-1);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.tbl tbody tr:hover td { background: var(--bg-2); }
.tbl .ta-r { text-align: right; }
.tbl .ta-c { text-align: center; }

/* Grid helpers */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .g-4, .g-5 { grid-template-columns: repeat(2, 1fr); } }

*:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; border-radius: 4px; }

/* Utility */
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.hsep { height: 1px; background: var(--line-soft); margin: 12px 0; }

/* Section header */
.section-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
}
.section-title {
  font-size: 11px; color: var(--fg-2); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 500;
}

/* Flash / alerts */
.flash {
  padding: 10px 14px; margin: 12px 20px 0;
  border-radius: var(--r);
  font-size: 13px;
  border: 1px solid var(--line-soft);
  background: var(--bg-1);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.flash--notice { border-color: var(--pos-soft); color: var(--pos); background: var(--pos-soft); }
.flash--alert { border-color: var(--neg-soft); color: var(--neg); background: var(--neg-soft); }
.flash-close {
  background: transparent; border: none; color: inherit;
  cursor: pointer; font-size: 16px; line-height: 1;
}

/* Connect card (not-authed state) */
.connect-card {
  max-width: 480px; margin: 60px auto;
  padding: 40px; text-align: center;
}
.connect-card h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.connect-card p { margin: 0 0 20px; color: var(--fg-2); font-size: 13px; }

/* Sparkline */
.spark { display: block; }
