:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #11161d;
  --panel-2: #161d26;
  --line: #252d38;
  --text: #ecf1f8;
  --muted: #8b97a8;
  --gold: #f5c84b;
  --green: #33d69f;
  --red: #ff6678;
  --blue: #76a9ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.panel-head,
.leader-row,
.metric,
.battle-card,
.detail-chip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

h3 {
  margin: 22px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-strip span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #0d1117;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.target-card {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #0c1016;
}

.target-card.warn {
  border-color: rgba(245, 200, 75, 0.45);
  background: rgba(245, 200, 75, 0.08);
}

.target-card.ok {
  border-color: rgba(51, 214, 159, 0.28);
}

.target-card label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.target-card strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.target-card small {
  color: var(--muted);
}

.metric {
  min-height: 84px;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.metric label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.metric small {
  color: var(--muted);
}

.arena-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.panel-head {
  min-height: 68px;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 420px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.live-dot,
.rank-badge {
  border-radius: 6px;
  padding: 6px 9px;
  background: rgba(245, 200, 75, 0.12);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.leaderboard {
  padding: 10px;
}

.leader-row {
  width: 100%;
  min-height: 82px;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0c1016;
  color: inherit;
  cursor: pointer;
}

.leader-row.active {
  border-color: rgba(245, 200, 75, 0.72);
  background: rgba(245, 200, 75, 0.08);
}

.leader-left {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
}

.place {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--gold);
  font-weight: 900;
}

.strategy-name {
  font-weight: 800;
}

.strategy-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.leader-pnl {
  text-align: right;
}

.status-badge {
  display: block;
  margin-bottom: 6px;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 900;
}

.status-badge.warn {
  background: rgba(245, 200, 75, 0.12);
  color: var(--gold);
}

.status-badge.ok {
  background: rgba(51, 214, 159, 0.12);
  color: var(--green);
}

.pnl {
  font-weight: 900;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.battle-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.battle-card {
  min-height: 114px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(180deg, #121923, #0d1117);
}

.battle-card.legacy {
  opacity: 0.72;
}

.battle-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(0, 1.18fr);
  gap: 14px;
}

.detail-panel,
.history-panel {
  padding-bottom: 14px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 14px;
}

.detail-chip {
  min-height: 62px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #0c1016;
}

.detail-chip span,
td small {
  color: var(--muted);
  font-size: 11px;
}

.detail-chip strong {
  font-size: 16px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.signal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0c1016;
}

.signal-top,
.signal-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.signal-score {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  padding: 0 14px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.side {
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
}

.side.long {
  background: rgba(51, 214, 159, 0.12);
  color: var(--green);
}

.side.short {
  background: rgba(255, 102, 120, 0.12);
  color: var(--red);
}

.side.flat {
  background: rgba(139, 151, 168, 0.14);
  color: var(--muted);
}

.empty {
  color: var(--muted);
}

@media (max-width: 1020px) {
  .metrics,
  .target-grid,
  .arena-grid,
  .battle-row,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .signal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .status-strip,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }
}
