/* BETS results report — StockCharts-like sheets on a neutral desk; A4 portrait when printed. */
:root {
  --ink: #111;
  --muted: #666;
  --rule: #c8c8c8;
  --desk: #e9eaec;
  --paper: #fff;
  --pos: #00872a;
  --neg: #d40000;
  --accent: #1f3f8f;
  --head: #f2f2f2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 13px/1.4 Arial, Helvetica, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: baseline; gap: 14px;
  padding: 8px 18px; background: #1d2733; color: #fff;
}
.topbar .brand { color: #fff; font-weight: bold; font-size: 15px; }
.topbar-sub { color: #b7c0cc; font-size: 12px; }
.topbar nav { margin-left: auto; }
.topbar nav a { color: #cfe0ff; }

main { padding: 18px 12px 60px; }
.sheet {
  max-width: 1000px; margin: 0 auto 22px; padding: 22px 26px;
  background: var(--paper); box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.sheet.results { max-width: 1240px; }
.sheet h2 { margin: 0 0 12px; font-size: 19px; }
.sheet h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #333; }

/* Cover */
.cover .cover-kicker { color: var(--accent); font-weight: bold; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.cover h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 10px; }
.cover .lead { font-size: 15px; color: #333; max-width: 820px; }
.cover-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.cover ul { margin: 0; padding-left: 18px; }
.cover li { margin: 3px 0; }
.legend-box { margin-top: 16px; padding: 10px 14px; background: #f7f7f7; border: 1px solid var(--rule); }
.legend-box h3 { margin-top: 0; }
.legend-items { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.legend-items span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 18px; height: 12px; border: 1px solid #bbb; }
.fineprint { font-size: 11px; color: var(--muted); margin-top: 14px; }

/* Filters + results table */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 10px; background: #f4f5f7; border: 1px solid var(--rule); }
.filter { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); }
.filter select, .filter input { font: 13px Arial, sans-serif; padding: 3px 4px; border: 1px solid #aaa; background: #fff; min-width: 120px; }
.filter.grow { flex: 1; min-width: 180px; }
.countline { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0 6px; }
.button { display: inline-block; padding: 5px 10px; border: 1px solid var(--accent); border-radius: 3px; background: #fff; }
.hindsight { margin: 6px 0; padding: 6px 10px; background: #fff6d6; border: 1px solid #e8cf70; font-size: 12px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.results-table th { background: var(--head); border-bottom: 1px solid #999; text-align: left; padding: 5px 6px; font-weight: bold; white-space: nowrap; }
.results-table th.test-col { background: #eaf0e6; }
.results-table th a { color: var(--ink); }
.results-table th.active a { color: var(--accent); }
.results-table td { padding: 4px 6px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.results-table tbody tr[data-href] { cursor: pointer; }
.results-table tbody tr:hover { background: #f1f6ff; }
.results-table td.strategy a { font-weight: bold; font-family: Arial, sans-serif; }
.results-table.compact { font-size: 10.5px; }
.results-table.compact td { padding: 2px 4px; }
.study { display: inline-block; min-width: 22px; padding: 0 4px; border-radius: 2px; color: #fff; font-weight: bold; font-size: 11px; text-align: center; }
.study.s1 { background: #4a4a4a; } .study.s2 { background: #2c5f9e; } .study.s3 { background: #7a4b9c; }
.badge { margin-left: 3px; font-size: 10px; color: #7a5a00; background: #fff1c2; padding: 0 3px; border-radius: 2px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.pager { display: flex; justify-content: space-between; margin-top: 10px; }

/* Result sheet */
.sheet-nav { max-width: 1000px; margin: 0 auto 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-nav span a, .sheet-nav button { margin-left: 10px; }
.sheet.result { padding: 14px 18px; }
.quote { border: 1px solid #8c8c8c; font-size: 11.5px; }
.q-top { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 6px; border-bottom: 1px solid #ccc; gap: 10px; }
.q-ticker { font-size: 18px; font-weight: bold; margin-right: 4px; }
.q-name { font-size: 12.5px; }
.q-date { color: #333; font-size: 11.5px; white-space: nowrap; }
.q-body { display: grid; grid-template-columns: 2fr 1.35fr 1fr .85fr 1.1fr; gap: 0 14px; padding: 4px 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px; line-height: 1.5; }
.kv span { color: #222; white-space: nowrap; }
.kv b { text-align: left; overflow-wrap: anywhere; }
.q-col.metric .kv b { text-align: right; white-space: nowrap; }
.q-big { text-align: right; border-left: 1px solid #ddd; padding-left: 10px; }
.q-big-label { color: #333; }
.q-big-value { font-size: 22px; font-weight: bold; color: #333; }
.q-big-value.pos { color: var(--pos); } .q-big-value.neg { color: var(--neg); }
.q-bench { font-size: 11px; }
.q-bench span { display: block; white-space: nowrap; }
.stage-tabs { display: flex; gap: 2px; margin: 8px 0 0; border-bottom: 1px solid #8c8c8c; }
.stage-tabs .tab { padding: 4px 12px; border: 1px solid #8c8c8c; border-bottom: none; background: #eee; color: #333; font-weight: bold; font-size: 12px; }
.stage-tabs .tab.active { background: #fff; color: #000; position: relative; top: 1px; }
.stage-tabs .tab.disabled { color: #aaa; font-weight: normal; }
.chart-host { margin-top: 6px; }
.sharpchart { width: 100%; height: auto; display: block; }
.chart-note { font-size: 10.5px; color: var(--muted); margin: 4px 0 8px; }
.sheet-cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: start; }
.metrics { width: 100%; border-collapse: collapse; font-size: 12px; }
.metrics th, .metrics td { padding: 3px 6px; border-bottom: 1px solid #e3e3e3; }
.metrics th { background: var(--head); text-align: left; }
.metrics tr.sep td { border-top: 1px solid #999; }
.selection p { margin: 4px 0; font-size: 12px; }
.trades-title { margin-top: 14px; }
.trades-wrap { max-height: 380px; overflow: auto; border: 1px solid #ddd; }
.trades { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.trades th { position: sticky; top: 0; background: var(--head); text-align: left; padding: 3px 6px; border-bottom: 1px solid #999; white-space: nowrap; }
.trades td { padding: 2px 6px; border-bottom: 1px solid #eee; }
.trades tr:hover { background: #eef4ff; }
.trades td.buy { color: var(--pos); font-weight: bold; }
.trades td.sell { color: var(--neg); font-weight: bold; }
.trades td.cash { color: #555; font-weight: bold; }
.sheet-foot { margin-top: 8px; font-size: 10px; color: #999; text-align: right; }

@media screen and (max-width: 760px) {
  .cover-grid, .sheet-cols { grid-template-columns: 1fr; }
  .q-body { grid-template-columns: 1fr 1fr; }
  .results-table { display: block; overflow-x: auto; }
}

@page { size: A4 portrait; margin: 9mm; }
@media print {
  body { background: #fff; font-size: 10.5px; }
  .no-print, .topbar { display: none !important; }
  main { padding: 0; }
  .sheet { max-width: none; margin: 0; padding: 0; box-shadow: none; break-after: page; }
  .sheet.result { padding: 0; }
  .trades-wrap { max-height: none; overflow: visible; border: none; }
  .trades th { position: static; }
  .results-table tbody tr:hover, .trades tr:hover { background: none; }
  .quote, .chart-host, .metrics, .sheet-cols { break-inside: avoid; }
  .quote { font-size: 9.5px; }
  .q-ticker { font-size: 15px; }
  .q-body { grid-template-columns: 1.9fr 1.45fr 1.05fr .8fr 1fr; gap: 0 8px; }
  .q-big-value { font-size: 17px; }
  .q-bench { font-size: 9px; }
  .chart-host { margin-top: 3px; }
  .chart-note { font-size: 8.5px; margin: 2px 0 4px; }
  .sheet-cols { gap: 12px; }
  .metrics { font-size: 9.5px; }
  .metrics th, .metrics td { padding: 1px 4px; }
  .selection p { font-size: 9.5px; }
  .sheet h3 { margin: 6px 0 3px; font-size: 10px; }
  .trades { font-size: 9px; }
  .trades td { padding: 1px 4px; }
  .sheet-foot { font-size: 8px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
