:root {
  --navy: #0b1f3a;
  --navy-2: #0e2748;
  --ink: #0a0e17;
  --row: #ffffff;
  --row-alt: #f4f7fb;
  --line: #1b2a3f;
  --green: #0a7d3b;
  --green-bg: #e3f6e8;
  --red: #b3261e;
  --red-bg: #fbe6e4;
  --muted: #5b6b80;
  --accent: #2563eb;
  --yellow: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--navy);
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 20px 60px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.topbar .sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: #9fb2cd;
}
.controls { display: flex; align-items: center; gap: 10px; }
.dp {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #9fb2cd;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dp select, .btn {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.16);
  background: var(--navy-2);
  color: #fff;
  cursor: pointer;
}
.btn { transition: background 0.15s; }
.btn:hover { background: #16315c; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: #1d4ed8; }

/* ---------- Bias bar ---------- */
.bias-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--navy-2);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}
.bias-badge {
  font-weight: 800;
  font-size: 15px;
  padding: 7px 16px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.bias-badge.BULLISH { background: var(--green-bg); color: var(--green); }
.bias-badge.BEARISH { background: var(--red-bg); color: var(--red); }
.bias-badge.NEUTRAL { background: #eef2f7; color: var(--muted); }
.bias-meta { color: #cdd9e8; font-size: 13px; }
.bias-meta .dot { margin: 0 6px; color: #5b6b80; }
.bias-meta b { color: #fff; font-family: "JetBrains Mono", monospace; }

/* ---------- Dashboard table ---------- */
.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--row);
}
.oi-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  min-width: 920px;
}
.oi-table th, .oi-table td {
  border: 1px solid #d6deea;
  padding: 7px 9px;
  text-align: right;
  white-space: nowrap;
}
.oi-table th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  text-align: center;
  position: sticky;
  top: 0;
}
.oi-table th.sub { font-size: 11px; font-weight: 500; }
.oi-table th.c-entity, .oi-table td.c-entity {
  text-align: left;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 2;
}
.oi-table td { font-variant-numeric: tabular-nums lining-nums; }
.oi-table tr.inst-head td {
  background: #1b3358;
  color: #fff;
  font-weight: 700;
  text-align: left;
  letter-spacing: 0.02em;
  font-size: 12px;
  text-transform: uppercase;
}
.oi-table tr.total-row td { background: #eef2f7; font-weight: 700; }
.oi-table td.c-entity { background: #f4f7fb; color: var(--ink); font-weight: 600; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.act-long.added, .act-short.closed { color: var(--green); font-weight: 600; }
.act-long.closed, .act-short.added { color: var(--red); font-weight: 600; }
.val-sm { color: var(--muted); font-size: 11px; }

/* ---------- Participant summary panel ---------- */
.summary-wrap {
  margin-top: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--row);
  overflow: hidden;
  max-width: 460px;
}
.summary-wrap .panel-title {
  background: var(--navy);
  color: #fff;
  margin: 0;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
}
.summary-wrap .panel-sub {
  font-weight: 400;
  color: #9fb2cd;
  font-size: 11px;
  margin-left: 6px;
}
.summary-table { min-width: 0; font-size: 13px; }
.summary-table th, .summary-table td { text-align: right; }
.summary-table th:first-child, .summary-table td:first-child { text-align: left; }

/* ---------- Backtest ---------- */
.bt {
  margin-top: 26px;
  background: var(--navy-2);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 18px;
}
.bt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bt h2 { margin: 0; color: #fff; font-size: 18px; font-weight: 800; }
.bt-desc { color: #9fb2cd; font-size: 12px; margin: 8px 0 14px; max-width: 900px; line-height: 1.5; }

.stats {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
.stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat .lbl { color: #9fb2cd; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .val { color: #fff; font-size: 17px; font-weight: 700; font-family: "JetBrains Mono", monospace; }
.stat .val.good { color: #34d399; }
.stat .val.bad { color: #f87171; }

.verdict {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  display: none;
}
.verdict.show { display: block; }
.verdict.win { background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }
.verdict.lose { background: rgba(239,68,68,0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

.chart-wrap {
  margin-top: 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 14px;
  height: 280px;
}

.trades-wrap { margin-top: 20px; }
.trades-wrap h3 { color: #fff; font-size: 14px; margin: 0 0 8px; }
.trades {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.trades th, .trades td {
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 8px;
  text-align: right;
  color: #cdd9e8;
}
.trades th { background: rgba(255,255,255,0.05); color: #fff; text-align: center; font-weight: 600; }
.trades td:first-child, .trades th:first-child { text-align: left; }
.trades-wrap { max-height: 380px; overflow: auto; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08); }

.notes { margin-top: 16px; color: #9fb2cd; font-size: 12px; }
.notes summary { cursor: pointer; color: #cdd9e8; font-weight: 600; }
.notes ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }

.disclaimer {
  margin-top: 24px;
  font-size: 11px;
  color: #6b7c93;
  line-height: 1.6;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 12px;
}
.disclaimer b { color: #9fb2cd; }

.toast {
  position: fixed;
  top: 14px;
  right: 18px;
  background: #1b3358;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar h1 { font-size: 16px; }
}
