/* Backtest — BTST-style workspace on the shared light chrome. */

.bt-page { background: var(--bg); }
.bt-page .site-footer { margin-top: 48px; }

.bt-cmd {
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.bt-cmd-row {
  max-width: 1480px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
}
.bt-cmd-row .field { min-width: 0; }
.cmd-symbol { width: min(260px, 100%); }
.cmd-strat { width: min(200px, 100%); }
.bt-cmd-row input[type='date'] { width: 148px; }
.cmd-actions { display: flex; gap: 8px; padding-bottom: 1px; }
.cmd-actions .btn { height: 34px; }
.seg-wrap { flex-wrap: wrap; }

.bt-cmd-extra {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 20px 16px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1.2fr) minmax(0, 1.4fr);
  gap: 20px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.bt-cmd-extra fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
.bt-cmd-extra legend { padding: 0; font: 700 11px/1 var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.strat-summary { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.params .field.wide, .params .check { grid-column: 1 / -1; }
.exec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hint { color: var(--faint); font-size: 11.5px; }

.bt-desk {
  max-width: 1480px;
  margin: 0 auto;
  padding: 18px 20px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}
.bt-desk.side-closed { grid-template-columns: 1fr; }
.bt-desk.side-closed .bt-side { display: none; }

.bt-analysis { min-width: 0; display: grid; gap: 12px; }
.bt-sheets { display: grid; gap: 12px; min-width: 0; }
.bt-sheets .panel { min-width: 0; }
.run-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.run-fn { font: 700 11px/1 var(--font-sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.run-head h1 { font-size: clamp(22px, 3vw, 30px); margin-top: 6px; }
.run-sub { margin-top: 6px; color: var(--muted); font-size: 13px; font-family: var(--font-sans); }
.run-sub .num { color: var(--text-2); }
.run-badges { display: flex; gap: 6px; flex-wrap: wrap; }
#notices:empty { display: none; }
#notices { display: grid; gap: 8px; }

.chart-stack { display: grid; gap: 0; border: 1px solid var(--line); }
.chart-stack .panel { border: 0; border-top: 1px solid var(--line); }
.chart-stack .panel:first-child { border-top: 0; }
.chart-panel { overflow: hidden; }
.chart-panel .panel-head { padding: 10px 14px 0; }
.chart { width: 100%; }
.chart-price { height: 420px; }
.chart-equity { height: 220px; }
.chart-dd { height: 140px; }
.sw { display: inline-block; width: 14px; height: 3px; margin: 0 6px 0 10px; vertical-align: 3px; }
.sw:first-child { margin-left: 0; }
.sw-strat { background: #111; }
.sw-bh { background: #8a8a8a; }
.sw-pos { background: #1a3fd1; height: 6px; vertical-align: 1px; }
.sw-dd { background: var(--down); }
.check.sm { font-size: 12.5px; gap: 8px; }
.check.sm input { width: 24px; height: 14px; }
.check.sm input::after { width: 10px; height: 10px; }
.check.sm input:checked::after { transform: translateX(10px); }

.bt-side {
  position: sticky;
  top: 12px;
  border: 1px solid var(--line);
  background: #fff;
  max-height: calc(100vh - var(--header-h) - 24px);
  overflow: auto;
}
.side-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0; z-index: 1;
}
.side-pane { padding: 12px 12px 16px; display: grid; gap: 10px; }
.side-note { font-size: 12px; color: var(--muted); line-height: 1.45; }
.stats.compact { font-size: 12.5px; }
.stats.compact th, .stats.compact td { padding: 6px 6px 6px 0; }
.stats.compact th { border-bottom-color: #000; }
.side-reopen {
  display: none;
  position: fixed; right: 16px; top: 16px; z-index: 20;
}
.bt-desk.side-closed .side-reopen { display: inline-flex; }

.bt-below {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: grid;
  gap: 16px;
}

.heat-wrap { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 3px; width: 100%; font: 500 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.heat th { color: var(--faint); font-weight: 500; padding: 2px 4px; text-align: center; }
.heat th.y { text-align: left; color: var(--muted); }
.heat td { text-align: center; padding: 7px 2px; color: var(--text); min-width: 42px; }
.heat td.empty { background: var(--bg-2); color: transparent; }
.heat td.flat { background: #eee; color: var(--faint); }
.heat td.yr { font-weight: 650; border: 1px solid var(--line-2); }

.stats td:first-child { color: var(--text-2); }
.stats td.r { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stats th.r { text-align: right; }

.trade-bars { height: 150px; position: relative; }
.trade-bars svg { width: 100%; height: 100%; overflow: visible; }
.trade-bars .axis text { fill: var(--faint); font: 500 10px var(--font-mono); }
.trade-bars rect { transition: opacity 0.15s; cursor: pointer; }
.trade-bars rect:hover { opacity: 0.7; }

.trades-wrap { max-height: 440px; overflow: auto; }
.trades thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.trades td { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.trades tbody tr { cursor: pointer; }
.trades .side { font-family: var(--font-sans); font-weight: 600; font-size: 12px; }
.trades .side.long { color: var(--up); }
.trades .side.short { color: var(--down); }
.trades tr.open td { color: var(--muted); font-style: italic; }

.method summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.method summary::-webkit-details-marker { display: none; }
.method summary::after { content: '+'; font: 500 18px/1 var(--font-mono); color: var(--muted); }
.method[open] summary::after { content: '−'; }
.method-body { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding-top: 0; font-size: 13.5px; color: var(--text-2); }
.method h3, .method h4 { font-family: var(--font-sans); font: 700 11px/1 var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 12px 0 10px; }
.method ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; line-height: 1.6; }
.defs { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; line-height: 1.55; }
.defs dt { font-weight: 600; color: var(--text); font-family: var(--font-sans); }
.defs dd { margin: 0; }

.loading .chart-stack, .loading .bt-side { opacity: 0.55; transition: opacity 0.2s; }

@media (max-width: 1080px) {
  .bt-desk { grid-template-columns: 1fr; }
  .bt-side { position: static; max-height: none; }
  .bt-cmd-extra { grid-template-columns: 1fr; }
  .exec-grid { grid-template-columns: 1fr 1fr; }
  .cmd-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 640px) {
  .chart-price { height: 320px; }
  .chart-equity { height: 200px; }
  .method-body { grid-template-columns: 1fr; }
  .cmd-symbol, .cmd-strat { width: 100%; }
}
