:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #5d6675;
  --line: #d8dee8;
  --soft: #f8fafc;
  --accent: #2d6cdf;
  --ok: #278a65;
  --warn: #b98522;
  --danger: #c84f4f;
  --shadow: 0 10px 24px rgba(25, 36, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.lab-topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.lab-topbar h1,
.panel-title h2,
.metric-section h2 {
  margin: 0;
  font-weight: 900;
}

.lab-topbar h1 {
  font-size: 25px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.terminal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.status-ok {
  border-color: rgba(39, 138, 101, 0.38);
  color: var(--ok);
}

.terminal-link {
  color: var(--accent);
}

.strategy-shell {
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 340px;
  grid-template-rows: minmax(610px, auto) auto;
  gap: 12px;
  min-height: calc(100vh - 82px);
  padding: 12px;
}

.strategy-sidebar,
.signal-board,
.rule-panel,
.metrics-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.strategy-sidebar,
.signal-board,
.rule-panel {
  padding: 14px;
  min-height: 0;
}

.panel-title,
.board-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.strategy-list {
  display: grid;
  gap: 8px;
  max-height: calc(100% - 52px);
  overflow: auto;
}

.strategy-item {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.strategy-item.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.strategy-name {
  font-size: 17px;
  font-weight: 900;
}

.strategy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.refresh-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 900;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-card,
.rule-card div,
.metric-board div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.summary-card span,
.rule-card dt,
.metric-board dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.summary-card strong,
.rule-card dd,
.metric-board dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.signal-table-wrap {
  max-height: calc(100% - 106px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.signal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.signal-table th,
.signal-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.signal-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.signal-code {
  font-size: 16px;
  font-weight: 900;
}

.level-badge {
  display: inline-flex;
  min-width: 46px;
  justify-content: center;
  border-radius: 7px;
  padding: 3px 7px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.level-S3 {
  background: var(--accent);
}

.level-S4,
.level-S5 {
  background: var(--danger);
}

.level-S1,
.level-S2,
.level-S6 {
  background: var(--warn);
}

.level-S0 {
  background: var(--muted);
}

.rule-card,
.metric-board {
  display: grid;
  gap: 8px;
  margin: 0;
}

.metrics-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 150px minmax(170px, 0.8fr) minmax(280px, 1.05fr) minmax(190px, 0.8fr) minmax(300px, 1.25fr) minmax(200px, 0.85fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
}

.metric-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.metric-board {
  grid-template-columns: 1fr;
}

.metric-section p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.factor-note,
.factor-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.factor-line {
  margin-top: 6px;
}

.factor-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 210px;
  overflow: auto;
}

.backtest-board {
  margin-top: 10px;
}

.backtest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.backtest-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--soft);
}

.backtest-grid dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.backtest-grid dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
}

.backtest-caveat {
  max-height: 52px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.calibration-board {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.calibration-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.calibration-stats div,
.calibration-row,
.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.calibration-stats div {
  padding: 8px;
}

.calibration-stats dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.calibration-stats dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.calibration-table,
.review-queue {
  display: grid;
  gap: 6px;
  max-height: 106px;
  overflow: auto;
}

.calibration-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--ink);
  cursor: default;
  text-align: left;
}

.calibration-row span,
.review-item strong {
  font-size: 12px;
  font-weight: 900;
}

.calibration-row b {
  font-size: 12px;
  font-weight: 900;
}

.calibration-row em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.calibration-board h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
}

.review-item {
  padding: 7px;
}

.review-item span {
  display: inline-block;
  margin-left: 6px;
  color: var(--warn);
  font-size: 11px;
  font-weight: 900;
}

.review-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.priority-high {
  box-shadow: inset 3px 0 0 var(--danger);
}

.coverage-board {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.coverage-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--soft);
}

.coverage-gate strong {
  min-width: 0;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.coverage-gate span {
  border-radius: 6px;
  padding: 3px 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.coverage-gate.is-blocked span {
  background: var(--danger);
}

.coverage-gate.is-ready span {
  background: var(--ok);
}

.coverage-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.coverage-metrics div,
.coverage-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--soft);
}

.coverage-metrics dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.coverage-metrics dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.coverage-list {
  display: grid;
  gap: 6px;
  max-height: 92px;
  overflow: auto;
}

.coverage-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.coverage-list b {
  font-size: 12px;
  font-weight: 900;
}

.coverage-list span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.import-gate,
.quality-gate,
.effectiveness-gate,
.stability-gate {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.import-gate > div,
.quality-gate > div,
.effectiveness-gate > div,
.stability-gate > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.import-gate span,
.import-gate em,
.quality-gate span,
.quality-gate em,
.effectiveness-gate span,
.effectiveness-gate em,
.stability-gate span,
.stability-gate em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.import-gate strong,
.quality-gate strong,
.effectiveness-gate strong,
.stability-gate strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.import-gate p,
.quality-gate p,
.effectiveness-gate p,
.stability-gate p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.import-gate dl,
.quality-gate dl,
.effectiveness-gate dl,
.stability-gate dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.import-gate dl div,
.quality-gate dl div,
.effectiveness-gate dl div,
.stability-gate dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px;
  background: var(--soft);
}

.import-gate.is-blocked {
  box-shadow: inset 3px 0 0 var(--warn);
}

.import-gate.is-ready {
  box-shadow: inset 3px 0 0 var(--ok);
}

.quality-gate.is-blocked {
  box-shadow: inset 3px 0 0 var(--warn);
}

.quality-gate.is-ready {
  box-shadow: inset 3px 0 0 var(--ok);
}

.effectiveness-gate.is-blocked {
  box-shadow: inset 3px 0 0 var(--danger);
}

.effectiveness-gate.is-ready {
  box-shadow: inset 3px 0 0 var(--ok);
}

.stability-gate.is-blocked {
  box-shadow: inset 3px 0 0 var(--danger);
}

.stability-gate.is-ready {
  box-shadow: inset 3px 0 0 var(--ok);
}

.coverage-action {
  max-height: 48px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.factor-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.factor-card-head,
.factor-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.factor-card-head strong {
  font-size: 16px;
  font-weight: 900;
}

.factor-stock-name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.factor-score-row {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.factor-score-row span,
.factor-grid em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.factor-score-row b {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.factor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.factor-grid span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
}

.factor-grid b {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .lab-topbar,
  .strategy-shell,
  .metrics-panel {
    display: block;
    height: auto;
    min-height: 0;
  }

  .lab-topbar > *,
  .strategy-shell > *,
  .metrics-panel > * {
    margin-bottom: 12px;
  }

  .summary-cards,
  .metric-board,
  .factor-board,
  .backtest-grid,
  .calibration-stats,
  .coverage-metrics {
    grid-template-columns: 1fr;
  }

  .signal-table-wrap {
    max-height: 520px;
  }
}
