/* 回测概率 */
.bt-wrap {
  padding: 28px 0 56px;
  background: linear-gradient(180deg, #eef2f7 0%, #f6f8fb 45%, #fff 100%);
  min-height: 70vh;
}

.bt-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.bt-title h1 {
  margin: 0 0 4px;
  font-size: 28px;
  color: #0b3a8c;
}

.bt-title p {
  margin: 0;
  color: #6b7c8f;
  font-size: 14px;
}

.bt-member {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
}

.bt-member em {
  font-style: normal;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.bt-member em.ok { background: #e8f5e9; color: #2e7d32; }
.bt-member em.warn { background: #fff3e0; color: #e65100; }

.bt-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  padding: 10px;
  background: #fff;
  border: 1px solid #d9e2ef;
  border-radius: 10px;
}

.bt-type-tabs a {
  padding: 8px 14px;
  border-radius: 6px;
  color: #334;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.bt-type-tabs a:hover { background: #f0f5fb; }
.bt-type-tabs a.active {
  background: #c62828;
  color: #fff;
}

.bt-gate {
  background: #fff;
  border: 1px solid #d9e2ef;
  border-radius: 12px;
  padding: 48px 28px;
  text-align: center;
  max-width: 640px;
  margin: 24px auto;
}

.bt-gate h2 { margin: 0 0 10px; color: #0b3a8c; }
.bt-gate p { color: #6b7c8f; margin: 0 0 22px; }
.bt-gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.bt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 10px;
}

.bt-toolbar label {
  font-size: 13px;
  color: #456;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bt-toolbar select {
  padding: 6px 10px;
  border: 1px solid #c5d2e4;
  border-radius: 4px;
}

.bt-hint {
  font-size: 12px;
  color: #99a;
  margin-left: auto;
}

.bt-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 10px;
}

.bt-filter-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bt-filter-item label,
.bt-filter-name {
  font-size: 12px;
  font-weight: 700;
  color: #345;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bt-filter-item select {
  width: 100%;
  padding: 2px 4px;
  border: 1px solid #c5d2e4;
  border-radius: 4px;
  font-size: 12px;
  background: #fafcfe;
  height: 26px;
  box-sizing: border-box;
}

.bt-filter-item.selecting select,
.bt-filter-item.active select {
  border-color: #f0b25a;
  background: #fff8ef;
}

.bt-table-wrap {
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 10px;
  overflow: auto;
  max-height: 68vh;
  box-shadow: 0 4px 18px rgba(15, 45, 90, 0.04);
}

.bt-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bt-table th,
.bt-table td {
  border-bottom: 1px solid #e8eef6;
  border-right: 1px solid #eef2f7;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.bt-table th {
  background: #f5f8fc;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  color: #234;
}

.bt-table th .rate {
  display: block;
  color: #c62828;
  font-size: 12px;
  font-weight: 800;
  margin-top: 2px;
}

.bt-table .col-issue,
.bt-table .col-date,
.bt-table .col-nums {
  text-align: left;
}

.bt-table .nums {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.3px;
}

.bt-ball {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-right: 3px;
  background: #e53935;
  color: #fff;
}

.bt-ball.blue {
  background: #1e88e5;
}

.bt-ok {
  background: #e8f5e9;
  color: #1b5e20;
  font-weight: 700;
}

.bt-bad {
  color: #999;
  font-weight: 600;
}

.bt-cell-detail {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  user-select: none;
}
.bt-cell-detail:hover {
  filter: brightness(0.96);
  outline: 1px solid rgba(30, 100, 180, 0.25);
}

.bt-subnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.bt-subnav a {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #d0dbeb;
  background: #fff;
  color: #334;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.bt-subnav a.active,
.bt-subnav a:hover {
  background: #0b3a8c;
  border-color: #0b3a8c;
  color: #fff;
}
.bt-subnav-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #0b3a8c;
  background: #e8f0fe;
  color: #0b3a8c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.bt-subnav-btn:hover {
  background: #0b3a8c;
  color: #fff;
}

.bt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
}
.bt-layout-full {
  grid-template-columns: 1fr;
}
.bt-main { min-width: 0; }
.bt-side {
  position: sticky;
  top: 72px;
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 10px;
  padding: 12px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}
.bt-side h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: #0b3a8c;
}
.bt-side-tip {
  margin: 0 0 10px;
  font-size: 12px;
  color: #8a97a8;
}
.bt-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  grid-template-columns: none;
}
.bt-filters-modal {
  display: grid;
  /* 勾选 + 名称一行，下拉在下；略加宽避免名字竖排/截断 */
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  max-height: min(58vh, 520px);
  overflow: auto;
  overflow-x: hidden;
  padding: 2px 2px 6px;
  margin: 0 0 8px;
  -webkit-overflow-scrolling: touch;
}
.bt-filters-modal .bt-filter-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 6px 5px;
  background: #f8fafc;
  min-width: 0;
  min-height: 0;
}
.bt-filters-modal .bt-filter-item.active {
  border-color: #90caf9;
  background: #e3f2fd;
}
.bt-filter-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  margin: 0;
  min-height: 18px;
  max-height: 20px;
}
.bt-filter-top input[type="checkbox"] {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  align-self: center;
}
.bt-filters-modal .bt-filter-name,
.bt-filters-modal .bt-filter-item label {
  display: block;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: #345;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  writing-mode: horizontal-tb;
  word-break: keep-all;
}
.bt-filters-modal .bt-filter-item select {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 2px 4px;
  margin: 0;
  height: 26px;
  line-height: 1.2;
}

.bt-cond-modal {
  width: min(920px, 100%);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  padding: 16px 18px 14px;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}
.bt-cond-head h3 {
  margin: 0 0 4px;
}
.bt-cond-tip {
  margin: 0 0 10px;
  font-size: 12px;
  color: #6b7c8f;
  line-height: 1.5;
}
.bt-cond-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.bt-cond-count {
  font-size: 12px;
  color: #567;
  margin-left: auto;
}
.bt-cond-actions {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid #e8eef5;
}

.bt-hscroll-top {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100%;
  height: 14px;
  margin-bottom: 2px;
  border: 1px solid #d0dbeb;
  border-radius: 6px 6px 0 0;
  background: #f5f8fc;
  -webkit-overflow-scrolling: touch;
}
.bt-hscroll-top .bt-hscroll-spacer {
  height: 1px;
  pointer-events: none;
}
.bt-table-wrap {
  max-height: calc(30 * 2.35em + 52px);
  overflow: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 0 0 10px 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.bt-main > .bt-table-wrap:first-child,
.bt-main > .bt-hscroll-top + .bt-table-wrap {
  border-radius: 0 0 10px 10px;
}
.draws-table-wrap {
  max-height: none;
}

.bt-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}
.bt-page-btn {
  border: 1px solid #b8c7db;
  background: #f5f8fc;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.bt-page-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bt-page-info { font-size: 13px; color: #567; }

.bt-gen-box {
  background: #fff;
  border: 1px solid #d0dbeb;
  border-radius: 10px;
  padding: 12px;
  margin-top: 8px;
}
.bt-gen-meta {
  font-size: 13px;
  color: #456;
  margin-bottom: 8px;
  line-height: 1.5;
}
.bt-gen-list {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
  background: #f7f9fc;
  padding: 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 保存的条件 / 历史命中 */
.bt-saved-modal,
.bt-hit-modal {
  width: min(860px, 100%);
  max-width: calc(100vw - 24px);
}
.bt-saved-table-wrap,
.bt-hit-table-wrap {
  max-height: min(52vh, 480px);
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.bt-saved-table,
.bt-hit-table {
  width: 100%;
  min-width: 640px;
}
.bt-saved-table th,
.bt-saved-table td,
.bt-hit-table th,
.bt-hit-table td {
  font-size: 12px;
  padding: 7px 8px;
  white-space: nowrap;
}
.bt-saved-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.bt-saved-actions .sk-btn,
.bt-hit-table .sk-btn {
  padding: 4px 8px;
  font-size: 12px;
}
.bt-hit-row {
  cursor: pointer;
}
.bt-hit-row:hover {
  background: #f0f5fb;
}
.bt-detail-hit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 46vh;
  overflow: auto;
}
.bt-detail-hit-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-bottom: 1px solid #eef2f7;
  font-size: 12px;
}
.bt-detail-hit-list .ok { color: #1b5e20; font-weight: 700; }
.bt-detail-hit-list .bad { color: #c62828; font-weight: 600; }

@media (max-width: 960px) {
  .bt-layout { grid-template-columns: 1fr; }
  .bt-side { position: static; max-height: none; }
  .bt-filters-modal { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); }
}

.bt-table .empty {
  text-align: center;
  color: #99a;
  padding: 36px 8px;
}

.sk-btn {
  border: 1px solid #b8c7db;
  background: #f5f8fc;
  color: #234;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.sk-btn:hover { filter: brightness(0.97); }
.sk-primary {
  background: #c62828;
  border-color: #b71c1c;
  color: #fff;
}

/* 历史数据弹窗 */
.bt-hist-modal {
  width: min(1100px, 100%);
  max-width: calc(100vw - 24px);
  min-width: 0;
  overflow: hidden;
}
/* flex 子项默认 min-width:auto 会撑破容器，导致无法横向滚动 */
.bt-cond-modal > *,
.bt-hist-modal > * {
  min-width: 0;
  max-width: 100%;
}
.bt-hist-limit-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #345;
}
.bt-hist-limit-label select {
  padding: 4px 8px;
  border: 1px solid #c5d2e4;
  border-radius: 4px;
  font-size: 13px;
}
.bt-hist-modal .bt-hscroll-top {
  flex-shrink: 0;
  border-radius: 8px 8px 0 0;
  max-width: 100%;
}
.bt-hist-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0 !important;
  max-width: 100%;
  width: 100%;
  max-height: min(58vh, 560px);
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 0 0 8px 8px;
  margin-bottom: 4px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.bt-hist-table {
  min-width: max-content;
  width: max-content;
  margin: 0;
}
.bt-hist-table th,
.bt-hist-table td {
  font-size: 12px;
  padding: 6px 8px;
}
.bt-hist-table .col-issue {
  min-width: 7.5em;
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
}
.bt-hist-table .col-date {
  min-width: 7em;
  position: sticky;
  left: 7.5em;
  z-index: 1;
  background: #fff;
}
.bt-hist-table .col-nums {
  min-width: 11em;
  position: sticky;
  left: 14.5em;
  z-index: 1;
  background: #fff;
  box-shadow: 2px 0 4px rgba(15, 45, 90, 0.06);
}
.bt-hist-table thead .col-issue,
.bt-hist-table thead .col-date,
.bt-hist-table thead .col-nums {
  z-index: 3;
  background: #f5f8fc;
}
.bt-hist-val {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Consolas, monospace;
}

/* 命中详情弹窗 */
.bt-detail-modal {
  width: min(420px, 100%);
}
.bt-detail-dl {
  margin: 0 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bt-detail-dl > div {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  line-height: 1.45;
}
.bt-detail-dl dt {
  margin: 0;
  color: #6b7c8f;
  font-weight: 600;
}
.bt-detail-dl dd {
  margin: 0;
  color: #234;
  font-weight: 600;
}
.bt-detail-hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: #7a8a9a;
}
.bt-detail-val {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: #0b3a8c;
}
.bt-detail-result {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
}
.bt-detail-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: #f5f8fc;
  border-radius: 6px;
  font-size: 12px;
  color: #567;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .bt-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .bt-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bt-title h1 { font-size: 22px; }
  .bt-hint { margin-left: 0; width: 100%; }
}
