

/* ---------- Responsive tuning ---------- */

@media (max-width: 991.98px) {
  html body .navbar-compact {
    min-height: 50px;
  }

  html body .dashboard-shell-card .summary-strip__value {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
  }

  html body .dashboard-shell-card .summary-strip__item--asset .summary-strip__value {
    font-size: clamp(1.25rem, 3.4vw, 1.7rem);
  }

  html body .dashboard-shell-card .summary-strip__returns-line {
    font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  }
}

@media (min-width: 992px) and (max-width: 1279.98px) {
  html body .table-wrap > table[data-table-id="backtestsList"],
  html body .table-wrap > table[data-table-id="strategiesList"],
  html body .table-wrap > table[data-table-id="weeklyStrategyReport"] {
    min-width: 1180px;
  }
}

@media (max-width: 1199.98px) {
  html body .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767.98px) {
  html body table.table thead th {
    font-size: 0.66rem;
  }

  html body table.table tbody td {
    padding: 0.48rem 0.55rem;
    font-size: 0.8rem;
  }

  html body .login-card .card-body {
    padding: 1.4rem 1.2rem;
  }

  html body .card > .card-header,
  html body .card .card-header {
    padding: 0.62rem 0.75rem;
  }

  html body .card > .card-body {
    padding: 0.75rem 0.75rem;
  }

  /* Stack card headers so long notes never squeeze the title */
  html body .dashboard-panel-card > .card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.5rem;
    min-height: 0;
  }

  html body .dashboard-panel-card > .card-header > .card-subtitle {
    flex: 1 0 100%;
    margin-top: 0;
  }

  html body .card-header.tool-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.45rem;
    min-height: 0;
  }

  html body .card-header.tool-header > .section-actions {
    width: 100%;
    justify-content: flex-start;
  }

  html body .card-header .section-heading {
    white-space: nowrap;
  }

  html body .card-header .section-actions {
    width: auto;
    justify-content: flex-end;
  }

  html body .card-header .section-actions .btn {
    flex: 0 0 auto;
    width: auto;
    min-height: 32px;
  }

  /* Account metrics wrap into a readable grid instead of horizontal overflow */
  html body .positions-account-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  html body .positions-account-item {
    border-right: 0;
    border-bottom: 1px solid #f1f4f8;
  }

  html body .positions-account-item:nth-child(odd) {
    border-right: 1px solid #f1f4f8;
  }

  html body .positions-account-item:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  html[data-theme="dark"] body .positions-account-item,
  html[data-theme="dark"] body .positions-account-item:nth-child(odd) {
    border-color: rgba(148, 163, 184, 0.10);
  }

  /* Keep the combined asset card from overlapping its two columns */
  html body .summary-strip__asset-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 0.75rem;
  }

  html body .summary-strip__asset-left .metric-tile__sub {
    white-space: normal;
  }

  html body .summary-strip__asset-right .summary-strip__value {
    font-size: 1.25rem;
  }

  html body .summary-strip__asset-right .summary-strip__label {
    font-size: 0.64rem;
  }

  html body .summary-strip__nav-item,
  html body .summary-strip__nav-sep {
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ---------- Fixed-layout tables (no horizontal scrollbar) ---------- */

.table-wrap--fit {
  overflow-x: hidden;
}

table.table.table-fit {
  table-layout: fixed;
  width: 100%;
}

table.table.table-fit th,
table.table.table-fit td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.table.table-fit td > span,
table.table.table-fit td > div {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.table.table-fit td .job-type-label {
  display: block;
  max-width: 100%;
}

table.table.table-fit td .btn {
  padding: 0.18rem 0.42rem;
  font-size: 0.75rem;
  line-height: 1.25;
}

/* workerJobs column budget: 任务队列 10 列按比例分配，永不超出容器宽度 */
table.table.table-fit > thead > tr > th:nth-child(1) { width: 4%; }
table.table.table-fit > thead > tr > th:nth-child(2) { width: 11.5%; }
table.table.table-fit > thead > tr > th:nth-child(3) { width: 8%; }
table.table.table-fit > thead > tr > th:nth-child(4) { width: 12%; }
table.table.table-fit > thead > tr > th:nth-child(5) { width: 12%; }
table.table.table-fit > thead > tr > th:nth-child(6) { width: 12%; }
table.table.table-fit > thead > tr > th:nth-child(7) { width: 11.5%; }
table.table.table-fit > thead > tr > th:nth-child(8) { width: 10.5%; }
table.table.table-fit > thead > tr > th:nth-child(9) { width: 9.5%; }
table.table.table-fit > thead > tr > th:nth-child(10) { width: 9%; }

/* 中等宽度下隐藏开始/结束时间，避免时间列被压缩到不可读 */
@media (max-width: 1279.98px) {
  table.table.table-fit th:nth-child(5),
  table.table.table-fit td:nth-child(5),
  table.table.table-fit th:nth-child(6),
  table.table.table-fit td:nth-child(6) {
    display: none;
  }

  table.table.table-fit > thead > tr > th:nth-child(1) { width: 6%; }
  table.table.table-fit > thead > tr > th:nth-child(2) { width: 14%; }
  table.table.table-fit > thead > tr > th:nth-child(3) { width: 9%; }
  table.table.table-fit > thead > tr > th:nth-child(4) { width: 17%; }
  table.table.table-fit > thead > tr > th:nth-child(7) { width: 11.5%; }
  table.table.table-fit > thead > tr > th:nth-child(8) { width: 11%; }
  table.table.table-fit > thead > tr > th:nth-child(9) { width: 12%; }
  table.table.table-fit > thead > tr > th:nth-child(10) { width: 12%; }
}

/* 移动端回到卡片流式布局，允许换行 */
@media (max-width: 767.98px) {
  table.table.table-fit {
    table-layout: auto;
  }

  table.table.table-fit th,
  table.table.table-fit td,
  table.table.table-fit td > span,
  table.table.table-fit td > div {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

/* ---------- Trade ticket funds disclosure ---------- */

html body .trade-ticket-funds {
  margin-bottom: 0.65rem;
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: #fbfcfe;
}

html body .trade-ticket-funds > summary {
  padding: 0.52rem 0.65rem;
  color: var(--ui-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

html body .trade-ticket-funds > summary::-webkit-details-marker {
  display: none;
}

html body .trade-ticket-funds > summary::after {
  content: " ›";
  color: var(--ui-subtle);
}

html body .trade-ticket-funds[open] > summary::after {
  content: " ⌄";
}

html body .trade-ticket-funds__body {
  padding: 0 0.65rem 0.6rem;
}

html[data-theme="dark"] body .trade-ticket-funds {
  border-color: var(--ui-border);
  background: #0b1322;
}

/* ---------- Backtest list / detail ---------- */

html body .backtest-run-detail {
  scroll-margin-top: 76px;
}

html body .sort-mark {
  margin-left: 0.18rem;
  color: var(--ui-accent-deep);
  font-size: 0.58rem;
  font-weight: 700;
}

html body .selection-hint {
  color: var(--ui-subtle);
  font-size: 0.72rem;
  white-space: nowrap;
}

html body .quality-cell {
  min-width: 132px;
}

html body .quality-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

html body .backtest-detail-kpis > [class*="col-"] {
  display: flex;
}

html body .backtest-detail-kpi {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  gap: 0.24rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: #ffffff;
}

html body .backtest-detail-kpi__label {
  color: var(--ui-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

html body .backtest-detail-kpi__value {
  color: var(--ui-ink);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

html body .backtest-detail-kpi__hint {
  margin-top: auto;
  color: var(--ui-subtle);
  font-size: 0.66rem;
  line-height: 1.35;
}

html body .backtest-detail-kpi__sep {
  margin: 0 0.25rem;
  color: var(--ui-subtle);
}

html[data-theme="dark"] body .backtest-detail-kpi {
  border-color: var(--ui-border);
  background: #0f1929;
}

html body .quality-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.4rem;
  border: 1px solid #fef3c7;
  border-radius: 999px;
  background: #fffbeb;
  color: #b45309;
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
}

html body .quality-details {
  margin-top: 0;
  font-size: 0.72rem;
}

html body .quality-details > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  color: var(--ui-muted);
  cursor: pointer;
  list-style: none;
}

html body .quality-more {
  color: var(--ui-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

html body .quality-audit {
  font-size: 0.68rem;
  line-height: 1.35;
  white-space: nowrap;
}

/* 回测列表：策略列固定宽度（超长名称换行，最多 2 行）；结果列操作按钮强制单行。
   其余单元格允许自然换行，避免整表过宽产生横向滚动。 */
@media (min-width: 768px) {
  html body table.backtests-list-table .backtest-strategy-name {
    max-width: 11rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  html body table.backtests-list-table > tbody > tr > td.backtest-actions-cell {
    white-space: nowrap;
  }

  html body table.backtests-list-table > tbody > tr > td.backtest-actions-cell .toolbar-row {
    flex-wrap: nowrap;
  }
}

html body .quality-details > summary::-webkit-details-marker {
  display: none;
}

html body .quality-details > summary::after {
  content: " ›";
  color: var(--ui-subtle);
}

html body .quality-details[open] > summary::after {
  content: " ⌄";
}

html body .quality-details__body {
  max-width: 280px;
  margin-top: 0.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ui-muted);
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

html[data-theme="dark"] body .quality-chip {
  border-color: rgba(251, 191, 36, 0.24);
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

html[data-theme="dark"] body .quality-details__body {
  border-color: var(--ui-border);
  background: #0b1322;
}