/* === BACKTEST PAGE === */

/* Disclaimer banner */
.backtest-disclaimer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  margin-bottom: 16px;
  color: var(--fg-muted);
}

.backtest-disclaimer svg {
  color: var(--fg-dim);
  flex-shrink: 0;
}

.backtest-disclaimer span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

/* Season selector */
.season-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.season-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  color: var(--fg-dim);
  text-decoration: none;
  transition: all 0.15s;
}

.season-btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.season-btn--active { color: var(--fg); border-color: var(--fg-dim); background: #1a1a1a; }

/* Metric cards */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  padding: 16px;
}

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

.metric-card-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.metric-card-val {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
}

.val-pos { color: var(--fg) !important; }
.val-neg { color: var(--fg-dim) !important; }

.sparkline-wrap {
  height: 32px;
  margin-bottom: 8px;
}

.clv-trend-spark {
  display: block;
  margin: 4px 0 2px 0;
  width: 100%;
  height: 22px;
}

.roi-indicator { margin-bottom: 8px; }

.roi-bar-wrap {
  position: relative;
  height: 4px;
  background: var(--bg-border);
  margin-bottom: 6px;
}

.roi-zero-line {
  position: absolute;
  left: 50%;
  top: -2px;
  width: 1px;
  height: 8px;
  background: var(--fg-dim);
}

.roi-bar-fill {
  height: 100%;
  transition: width 0.5s;
}

.roi-pos { background: var(--fg-muted); }
.roi-neg { background: var(--fg-dim); }

.roi-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* Units bar */
.units-bar-wrap { margin-bottom: 8px; }

.units-bar {
  height: 4px;
  background: var(--bg-border);
  display: flex;
  overflow: hidden;
  margin-bottom: 6px;
}

.units-bar-win { background: var(--fg-muted); }
.units-bar-loss { background: var(--fg-darkest); }

.units-legend {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-dim);
}

.units-win-label { color: var(--fg-muted); }
.units-loss-label { color: var(--fg-dim); }

/* CLV breakdown */
.clv-breakdown { margin-bottom: 8px; }

.clv-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--bg-border-subtle);
}

.clv-row:last-child { border-bottom: none; }

.clv-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

.clv-val {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-muted);
}

.metric-card-footer {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

.metric-trend { }
.trend-pos { color: var(--fg-muted); }
.trend-neg { color: var(--fg-dim); }

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  padding: 20px;
}

.chart-card--wide {
  grid-column: 1 / -1;
}

.chart-header {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--bg-border);
  padding-bottom: 12px;
}

.chart-title {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.chart-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

.chart-body {
  height: 180px;
  position: relative;
}

.chart-card--wide .chart-body { height: 220px; }

/* Breakdown table */
.breakdown-wrap {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  margin-bottom: 20px;
  overflow: hidden;
}

.breakdown-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--bg-border);
  background: var(--bg);
}

.breakdown-table { width: 100%; }

.breakdown-row {
  display: grid;
  grid-template-columns: 1.2fr 60px 50px 50px 50px 80px 1.4fr 80px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--bg-border);
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  gap: 8px;
}

.breakdown-row:last-child { border-bottom: none; }

.breakdown-row--head {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: var(--bg);
}

.breakdown-row--total {
  background: #111111;
  border-top: 1px solid var(--bg-border);
}

.bd-col { color: var(--fg-muted); }
.bd-col--cat { color: var(--fg); font-weight: 600; }

.bd-pos { color: var(--fg); font-weight: 600; }
.bd-neg { color: var(--fg-dim); }
.bd-clv { color: var(--fg-muted); }

/* Notes section */
.notes-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notes-block {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  padding: 16px 20px;
}

.notes-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.notes-body {
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .report-card-tiles { grid-template-columns: repeat(2, 1fr); }
  .breakdown-row { grid-template-columns: 1fr 60px 50px 50px 50px 80px; }
  .breakdown-row .bd-col:nth-child(n+7) { display: none; }
}

@media (max-width: 600px) {
  .metric-cards { grid-template-columns: 1fr; }
  .season-selector { flex-wrap: wrap; }
}

/* Compact metric card variant */
.metric-card--compact {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  padding: 12px 14px;
}

.metric-card--compact .metric-card-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 6px;
}

.metric-card--compact .metric-card-val {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 4px;
}

.metric-card--compact .metric-card-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}

/* Signal badges */
.signal-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  border-radius: 2px;
}

.signal-bet   { background: rgba(255,255,255,0.15); color: var(--fg); }
.signal-lean  { background: rgba(255,255,255,0.08); color: var(--fg-muted); }
.signal-pass  { background: rgba(255,255,255,0.04); color: var(--fg-dim); }

/* Edge value coloring */
.proj-edge-val { color: var(--fg); font-weight: 600; }
.proj-edge-neg { color: var(--fg-dim); }

/* Result badges */
.result-w { color: var(--fg); font-weight: 700; }
.result-l { color: var(--fg-dim); font-weight: 700; }
.result-p { color: var(--fg-dim); }

/* Filter bar */
.perf-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  margin-right: 4px;
}

.filter-btn {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { color: var(--fg); border-color: var(--fg-dim); }
.filter-btn--active { color: var(--fg); border-color: var(--fg-dim); background: #1a1a1a; }

/* Performance table */
.perf-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
}

.perf-table th {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--bg-border);
  text-align: left;
  white-space: nowrap;
}

.perf-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bg-border-subtle);
  color: var(--fg-muted);
}

.perf-table tr:last-child td { border-bottom: none; }
.perf-table tr:hover td { background: #0d0d0d; }

.col-date { white-space: nowrap; }
.col-game { color: var(--fg); font-weight: 600; }
.col-edge { text-align: right; }
.col-conf { text-align: right; }
.col-score { text-align: right; }
.col-res { text-align: center; }
.col-line { text-align: right; }
.col-pnl { text-align: right; }

/* === 2023/2024 Season Report Card === */
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-border);
  padding: 20px;
  margin-bottom: 16px;
}

.report-card-verdict {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.report-card-body {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-muted);
  line-height: 1.5;
  max-width: 720px;
}

.report-card-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.report-card-trend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-border-subtle);
}

.report-card-trend-chip {
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid var(--bg-border);
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}

.thresholds-used-block {
  margin: 12px 0 0;
  padding: 12px 16px;
  background: #0d0d0d;
  border: 1px solid var(--bg-border);
}
.thresholds-used-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  margin-bottom: 6px;
}
.thresholds-used-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.threshold-val {
  font-size: 11px;
  color: var(--fg);
}
.threshold-sep { color: var(--fg-dim); }
.thresholds-used-note {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: 4px;
}

/* === CLV-by-tier attribution panel === */
/* Comparison bar — scaled to capture_rate_pct, no zero-line marker
   (capture rate has no natural "zero" the way signed ROI does). */
.tier-bar-wrap {
  margin: 4px 0 0;
}

.tier-bar-track {
  position: relative;
  height: 4px;
  background: var(--bg-border);
  overflow: hidden;
}

.tier-bar-fill {
  height: 100%;
  transition: width 0.5s;
}

.tier-pos { background: var(--fg-muted); }
.tier-neg { background: var(--fg-dim); }

/* Tier filter chip set (BET / LEAN / PASS / All Tiers) — scopes the whole
   /backtest page via ?tier=. Sits next to the season selector.
   Reuses the .filter-btn look from .perf-filter-bar above so existing
   spacing/typography rules carry over. */
.tier-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -4px;
}

/* Phase-model explainer — clickable metric-card-label buttons on the
   2023/2024 Season Report comparison row open a same-page modal that
   renders the underlying factor list from lib/model/phases-config.js. */
.metric-card-label--clickable {
  cursor: pointer;
  color: var(--fg);
  text-decoration: underline dotted var(--fg-dim);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
}
.metric-card-label--clickable:hover { color: var(--fg); text-decoration: underline dotted var(--fg); }

/* Phase-factor modal body — table of factor name + weight + notes, with
   reduced max-height so long Phase 2 lists stay scrollable inside the
   existing .modal-box. Reuses the .modal-overlay / .modal-box /
   .modal-header / .modal-close / .modal-body classes from betlog.css. */
.phase-factor-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
  display: block;
  max-height: 60vh;
  overflow-y: auto;
}
.phase-factor-table thead,
.phase-factor-table tbody { display: table; width: 100%; }
.phase-factor-table th,
.phase-factor-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--bg-border-subtle);
  vertical-align: top;
  color: var(--fg);
}
.phase-factor-table th {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-size: 10px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}
.phase-factor-name { color: var(--fg); }
.phase-factor-weight { color: var(--fg-muted); white-space: nowrap; }
.phase-factor-notes { color: var(--fg-dim); }
.phase-factor-empty {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  padding: 12px 0;
}
@media (max-width: 900px) {
  #phaseFactorModal .modal-box { width: 95vw; }
}