/* ===========================================================
   Design tokens
   =========================================================== */
:root {
  --bg: #12151c;
  --surface: #1b2029;
  --surface-raised: #212734;
  --surface-hover: #262d3b;
  --border: #2a3140;
  --border-soft: #232a37;

  --text: #e7eaf0;
  --text-muted: #8892a6;
  --text-faint: #5b6478;

  --positive: #4fd1a5;
  --positive-dim: #2a5c4d;
  --negative: #f0665a;
  --negative-dim: #5c332e;
  --accent: #e8b85c;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

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

::selection { background: var(--accent); color: #12151c; }

a { color: inherit; }

button, select, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.muted { color: var(--text-muted); }

.hero .eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cash-flow-toggle {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 11px;
}
.cash-flow-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.cash-flow-form input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
}
.cash-flow-form input#cashFlowAmount { width: 220px; }
.cash-flow-form input#cashFlowNote { width: 200px; }

/* ===========================================================
   Shell / status bar
   =========================================================== */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 28px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand .mark { color: var(--accent); }

.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.pulse-dot.live {
  background: var(--positive);
  box-shadow: 0 0 0 0 rgba(79, 209, 165, 0.6);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 209, 165, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(79, 209, 165, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 165, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .pulse-dot.live { animation: none; }
}

.status-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-indicator {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--radius-sm);
}
.status-indicator:hover { background: var(--surface-raised); }
.status-indicator .status-caret {
  font-size: 10px;
  color: var(--text-faint);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.status-indicator.open .status-caret { transform: rotate(180deg); }

.error-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 420px;
  max-width: min(420px, 90vw);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.7);
  cursor: default;
}
.status-indicator.open .error-dropdown { display: block; }
.error-dropdown-head {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
}
.error-archive-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.error-archive-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text-faint); }
.error-archive-btn:disabled { opacity: 0.5; cursor: default; }
.error-dropdown-list {
  max-height: 340px;
  overflow-y: auto;
}
.error-dropdown-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.error-dropdown-row:last-child { border-bottom: none; }
.error-dropdown-row .error-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.error-dropdown-row .error-row-source { color: var(--negative); }
.error-dropdown-row .error-row-message {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.spacer { flex: 1; }

.eastern-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.mode-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.mode-toggle button.active {
  background: var(--surface-raised);
  color: var(--text);
}
.mode-toggle button:hover:not(.active) { color: var(--text); }

canvas { display: block; width: 100%; height: 100%; }

/* ===========================================================
   Hero / portfolio value
   =========================================================== */
.hero { margin-bottom: 40px; }

.hero-top {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 4px;
}

.hero-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.01em;
}

.hero-delta {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 2px 0;
}

.scope-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  background: rgba(79, 209, 165, 0.15);
  color: var(--positive);
  vertical-align: middle;
}
.scope-badge.backtest {
  background: rgba(232, 184, 92, 0.15);
  color: var(--accent);
}

.hero-chart {
  height: 260px;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 8px 24px -16px rgba(0, 0, 0, 0.5);
}

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

.chart-tooltip {
  display: none;
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
.chart-tooltip .tt-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.chart-tooltip .tt-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 1px;
}

/* Multi-series tooltip (summary.js's attachMultiLineHover) — one row
   per series (live/backtest/SPY), unlike the hero chart's single value. */
.chart-tooltip .tt-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.chart-tooltip .tt-row + .tt-row { margin-top: 3px; }
.chart-tooltip .tt-row .legend-dot { flex-shrink: 0; }
.chart-tooltip .tt-row .tt-date { margin-top: 0; margin-left: auto; padding-left: 8px; }

/* ===========================================================
   Tab separation — backtest-only content stays off the live tab
   =========================================================== */
.shell:not([data-mode="backtest"]) #backtestSection {
  display: none;
}
/* Deposits/withdrawals are only a live-account concept — a backtest's
   starting_cash already IS its baseline, nothing to record against it. */
.shell:not([data-mode="live"]) .cash-flow-toggle {
  display: none;
}
/* Strategy Allocation (the per-strategy $ donut) is per-account, live-
   only — /api/strategy-allocation is hardcoded to mode="live" (see its
   own docstring), so this would show stale data from whichever
   account was last viewed if left visible in backtest mode. */
.shell:not([data-mode="live"]) #strategyAllocationSection {
  display: none;
}
/* "Stop new trades" only means something for a real account placing
   real orders — a backtest has nothing live to stop. */
.shell:not([data-mode="live"]) .trading-halt-toggle {
  display: none;
}
/* Export CSV only makes sense against a specific, fixed backtest run —
   live's equity curve keeps growing, so there's no stable file to hand
   back. */
.shell:not([data-mode="backtest"]) .export-equity-csv {
  display: none;
}
/* The after-tax overlay is a backtest-only "what if" simulation, same
   scoping reason as the Export CSV button above. */
.shell:not([data-mode="backtest"]) .after-tax-toggle {
  display: none;
}
.after-tax-toggle {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}
.after-tax-toggle input {
  cursor: pointer;
}
/* ===========================================================
   Login gate — shared by /nathan and /friends (see auth-gate.js)
   =========================================================== */
/* !important is deliberate here, not sloppy — .hidden is a utility
   class meant to unconditionally hide whatever it's applied to; without
   it, any component rule with equal-or-later specificity (e.g.
   .logout-link's own `display: block`) silently wins the cascade and
   the element stays visible despite having .hidden applied (confirmed:
   exactly this happened to #logoutLink). */
.hidden { display: none !important; }

.login-card {
  max-width: 360px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.login-card label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.login-card input[type="password"] {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  box-sizing: border-box;
}
.login-card button {
  margin-top: 16px;
  width: 100%;
  background: var(--accent);
  color: #12151c;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.login-error {
  color: #f0665a;
  font-size: 12px;
  margin-top: 10px;
  min-height: 14px;
}

/* Full-viewport centering wrapper for pages that gate their ENTIRE
   content (the /nathan dashboard) rather than sitting in an already-
   narrow, already-centered layout (/friends' own .friends-shell). */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  padding: 20px;
}
.auth-gate-overlay .login-card { width: 100%; }

/* Base look — friends.html overrides this (block, centered, margin)
   to fit its narrow centered layout; here it's sized for sitting
   inline in the dashboard's statusbar next to the mode toggle. */
.logout-link {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  white-space: nowrap;
  flex-shrink: 0;
}
.logout-link:hover { color: var(--text); }

/* ===========================================================
   Summary tab / friends page — shared blocks (see summary.js)
   =========================================================== */
.summary-block { margin-bottom: 28px; }
.summary-block .eyebrow { margin-bottom: 12px; }
.summary-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.summary-block-head .eyebrow { margin-bottom: 0; }

.chart-footnote {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}

.range-picker {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.range-picker button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.range-picker button.active { background: var(--surface-raised); color: var(--text); }
.range-picker button:hover:not(.active) { color: var(--text); }

.summary-legend {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.summary-chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  height: 220px;
}
.summary-chart-wrap canvas { width: 100%; height: 100%; display: block; }
.summary-chart-wrap.small { height: 140px; }

.summary-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 640px) {
  .summary-two-col { grid-template-columns: 1fr; }
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
}
.donut {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  flex-shrink: 0;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 18px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 18px));
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text);
}
/* Two donuts side by side (one per live account) inside the SAME
   Market Allocation card, not two separate cards — see summary.js's
   renderAllocation. */
.donut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.donut-col { flex: 1; min-width: 220px; }
.donut-caption {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.exposure-stat {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  margin-bottom: 10px;
}

/* ===========================================================
   Section headers
   =========================================================== */
.section { margin-bottom: 40px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head .controls { display: flex; gap: 8px; }

/* ===========================================================
   Strategy tiles (signature element: allocation ring + sparkline)
   =========================================================== */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.strategy-tile {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.strategy-tile:hover {
  border-color: var(--border);
  background: var(--surface-raised);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.6);
}

.tile-top { display: flex; align-items: center; gap: 12px; }

.allocation-ring { flex-shrink: 0; }

.tile-name-block { min-width: 0; }
.tile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-alloc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.tile-pnl {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
}

.tile-sparkline { height: 40px; }

.tile-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* ===========================================================
   Trades table
   =========================================================== */
.filters {
  display: flex;
  gap: 8px;
}
.filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.6);
}

.table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.6);
}
.stats-table th, .stats-table td {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
  white-space: nowrap;
}
.stats-table tr:last-child th, .stats-table tr:last-child td { border-bottom: none; }
.stats-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
}
.stats-table thead th {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  border-bottom: 1px solid var(--border-soft);
}
.stats-table thead th:first-child { text-align: left; }
.stats-table td.value { font-weight: 600; }

.trades-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.trade-row {
  cursor: pointer;
  transition: background 0.1s;
}
.trade-row:hover { background: var(--surface-raised); }
.trade-row td {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.trade-row td.sym { font-family: var(--font-body); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge.open { background: rgba(232, 184, 92, 0.15); color: var(--accent); }
.badge.closed { background: rgba(139, 146, 166, 0.15); color: var(--text-muted); }
.badge.buy { background: rgba(79, 209, 165, 0.15); color: var(--positive); }
.badge.sell { background: rgba(240, 102, 90, 0.15); color: var(--negative); }

.chevron { color: var(--text-faint); transition: transform 0.15s; display: inline-block; }
.trade-row.expanded .chevron { transform: rotate(90deg); }

.trade-detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--border-soft);
}
.trade-detail {
  padding: 16px 20px;
  background: var(--bg);
  display: none;
}
.trade-detail.open { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.detail-stat .label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.detail-stat .value {
  font-family: var(--font-mono);
  font-size: 14px;
  margin-top: 2px;
}

.timeline {
  border-left: 2px solid var(--border);
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline-item { position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -18.5px;
  top: 4px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.timeline-item.action-buy::before { background: var(--positive); }
.timeline-item.action-sell::before { background: var(--negative); }
.timeline-item.action-rank::before { background: var(--accent); }
.timeline-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.timeline-reason { font-size: 12.5px; margin-top: 2px; }
.timeline-action {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-right: 6px;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ===========================================================
   Backtest panel
   =========================================================== */
.backtest-panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 8px 24px -18px rgba(0, 0, 0, 0.6);
}

.bt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.bt-field { display: flex; flex-direction: column; gap: 6px; }
.bt-field label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bt-field input, .bt-field .chip-select {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.bt-checkbox-field {
  flex-direction: row-reverse;
  align-items: center;
  gap: 8px;
}
.bt-checkbox-field input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.bt-checkbox-field label { cursor: pointer; }
.bt-coverage-note {
  font-size: 11px;
  color: var(--accent);
  width: 100%;
  order: 999;
}

.bt-field-wide { flex-basis: 100%; }
.bt-field-sublabel { text-transform: none; letter-spacing: normal; color: var(--text-faint); }
.bt-alloc-reset {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  text-decoration: underline;
}
.bt-alloc-list { display: flex; gap: 8px; flex-wrap: wrap; }
.bt-alloc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
}
.bt-alloc-row .bt-alloc-name { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.bt-alloc-row input {
  width: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-align: right;
}
.bt-alloc-row input.bt-alloc-changed { border-color: var(--accent); color: var(--accent); }
.bt-alloc-row .bt-alloc-pct { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }

.chip-select { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-raised);
  transition: all 0.15s;
}
.chip.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 184, 92, 0.1);
}

.btn-primary {
  background: var(--accent);
  color: #12151c;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-faint); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.runs-list { display: flex; flex-direction: column; gap: 8px; }
.run-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
}
.run-item:hover { background: var(--surface-raised); }
.run-item.selected { border-color: var(--accent); background: rgba(232, 184, 92, 0.06); }
.run-timing { white-space: nowrap; flex-shrink: 0; }

.btn-pin-run {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.35;
  filter: grayscale(1);
  flex-shrink: 0;
}
.btn-pin-run:hover { opacity: 0.7; }
.btn-pin-run.pinned { opacity: 1; filter: none; }

.btn-benchmark {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.6;
  cursor: pointer;
  opacity: 0.55;
  flex-shrink: 0;
  white-space: nowrap;
}
.btn-benchmark:hover:not(:disabled) { opacity: 0.85; border-color: var(--accent); }
.btn-benchmark.active { opacity: 1; border-color: var(--accent); color: var(--accent); cursor: default; }
.btn-benchmark:disabled { cursor: default; }
.run-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}
.run-status.running { background: rgba(232, 184, 92, 0.15); color: var(--accent); }
.run-status.completed { background: rgba(79, 209, 165, 0.15); color: var(--positive); }
.run-status.failed { background: rgba(240, 102, 90, 0.15); color: var(--negative); }
.run-status.cancelled { background: rgba(139, 146, 166, 0.15); color: var(--text-muted); }

.btn-cancel {
  background: transparent;
  color: var(--negative);
  border: 1px solid var(--negative-dim);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-cancel:hover { background: rgba(240, 102, 90, 0.12); border-color: var(--negative); }
.btn-cancel:disabled { opacity: 0.5; cursor: not-allowed; }

/* "Stop new trades" account switch (see ui/static/app.js's
   renderTradingHalt) -- looks like an ordinary .btn-secondary when
   trading is running normally; switches to a solid, hard-to-miss red
   fill once new trades are actually stopped for that account, since
   this is a live-trading safety control, not a cosmetic toggle. */
.btn-halt {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-halt:hover { color: var(--text); border-color: var(--text-faint); }
.btn-halt.active {
  background: var(--negative);
  color: #1a1010;
  border-color: var(--negative);
  font-weight: 600;
}
.btn-halt.active:hover { filter: brightness(1.1); }
.btn-halt:disabled { opacity: 0.5; cursor: not-allowed; }

.bt-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 18px;
}
.bt-progress .run-progress-track { height: 8px; }

.run-progress-track {
  flex: 1 1 80px;
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.run-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.run-progress-label {
  font-size: 11px;
  color: var(--text-faint);
  min-width: 34px;
  text-align: right;
}

footer.credits {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .hero-value { font-size: 32px; }
  .statusbar { flex-wrap: wrap; }
}

/* ===========================================================
   Shared top navigation bar (topnav.js) — injected at the top of
   every page (/, /nathan, /friends, /members, /data-health) for
   consistent cross-page navigation. Its own login control is
   independent of whatever auth-gate a page's own content below it
   uses (e.g. /nathan, /members, /data-health's owner-only gate) —
   this bar's login is always the /friends password specifically.
   =========================================================== */
.topnav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  margin-right: 24px;
}
.topnav-brand .mark { color: var(--accent); }

.topnav-link {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.topnav-link.active { color: var(--text); background: var(--surface-raised); }
.topnav-link:hover:not(.active) { color: var(--text); }

.topnav-login-wrap { position: relative; margin-left: auto; }
.topnav-login-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.topnav-login-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  display: none;
  z-index: 30;
}
.topnav-login-wrap.open .topnav-login-panel { display: block; }
.topnav-login-panel label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.topnav-login-panel input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: var(--bg-input, transparent);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: inherit;
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 10px;
}
.topnav-login-panel button {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #12151c;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.topnav-login-panel button:disabled { opacity: 0.6; cursor: default; }
.topnav-login-error {
  font-size: 11px;
  color: #f0665a;
  margin-top: 8px;
  min-height: 14px;
}
