* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: #f7f8fa;
  color: #1f2328;
}
header {
  background: #fff;
  border-bottom: 1px solid #d0d7de;
  padding: 12px 24px 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.title-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.muted { color: #6e7781; font-size: 12px; }
.user-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}
.user-chip.role-admin  { background: #d8b8ff; color: #6639ba; }
.user-chip.role-viewer { background: #ddf4ff; color: #0969da; }
.small { font-size: 11px; }
.tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: #57606a;
  border-radius: 6px 6px 0 0;
}
.tab-btn:hover { background: #f6f8fa; }
.tab-btn.active {
  background: #f7f8fa;
  border-color: #d0d7de;
  color: #0969da;
  font-weight: 600;
}
.badge {
  display: inline-block;
  margin-left: 4px;
  background: #ddf4ff;
  color: #0969da;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
}
main { padding: 16px 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.portfolio-summary {
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.portfolio-summary strong { color: #0969da; }

.cluster-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.cluster-card {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 14px;
}
.cluster-card h3 {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
}
.cluster-meta {
  font-size: 12px;
  color: #57606a;
  margin-bottom: 8px;
}
.cluster-desc {
  font-size: 13px;
  background: #f6f8fa;
  padding: 8px 10px;
  border-left: 3px solid #0969da;
  margin: 6px 0 10px 0;
  border-radius: 0 4px 4px 0;
}
.cluster-desc .key { font-weight: 600; color: #0969da; margin-right: 6px; }
.cluster-desc.manual { border-left-color: #d29922; }
.cluster-desc .tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  background: #d0d7de;
  color: #24292f;
}
.cluster-desc.manual .tag { background: #fae3a0; }
.cluster-desc.empty { background: #fff8c5; border-left-color: #d29922; color: #57606a; }

.cluster-positions {
  margin: 8px 0;
  padding: 8px 10px;
  background: #f6f8fa;
  border-radius: 4px;
}
.cluster-positions > .muted { margin-bottom: 6px; display: block; }
.pos-section {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 3px 0;
}
.pos-section .label {
  font-size: 11px;
  font-weight: 600;
  color: #57606a;
  white-space: nowrap;
  min-width: 32px;
}
.pos-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #fff;
  min-width: 32px;
  text-align: center;
  font-weight: 600;
}
.pos-tag small {
  font-weight: 400;
  margin-left: 4px;
  opacity: 0.85;
  font-size: 9px;
}
.empty-pos {
  font-size: 11px;
  color: #6e7781;
  font-style: italic;
  padding: 2px 8px;
}

.plot { width: 100%; height: 360px; }
.trade-chart-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #d0d7de;
}
.trade-label { margin-right: 12px; }
.trade-plot { height: 360px; }
.trade-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
.trade-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #57606a;
}
.trade-ctrl select,
.trade-ctrl input[type="date"] {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  background: #fff;
}
.trade-reset {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  background: #f6f8fa;
  cursor: pointer;
}
.trade-reset:hover { background: #eaeef2; }
.cluster-table {
  width: 100%;
  margin-top: 10px;
  font-size: 12px;
  border-collapse: collapse;
}
.cluster-table th, .cluster-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid #eaeef2;
}
.cluster-table th { background: #f6f8fa; font-weight: 500; }
.cluster-table tbody tr { cursor: pointer; }
.cluster-table tbody tr:hover { background: #f0f6ff; }
.cluster-table .fp { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.cluster-table .num { text-align: right; font-family: ui-monospace, monospace; }
.cluster-table .pos { color: #1a7f37; }
.cluster-table .neg { color: #cf222e; }

.strategy-detail {
  margin-top: 8px;
  padding: 10px;
  background: #f6f8fa;
  border-radius: 4px;
}
.strategy-detail .plot { height: 280px; }

form { background: #fff; padding: 16px; border-radius: 6px; border: 1px solid #d0d7de; max-width: 720px; }
form label { display: block; font-size: 12px; color: #57606a; margin-bottom: 12px; }
form input[type=text], form input[type=url], form textarea {
  width: 100%; padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 4px;
  font-size: 13px; margin-top: 4px;
  font-family: inherit;
}
form textarea { font-family: ui-monospace, monospace; font-size: 12px; }
form button[type=submit] {
  background: #1f883d; color: #fff; border: 0; padding: 8px 16px;
  border-radius: 6px; font-size: 13px; cursor: pointer;
}
form button[type=submit]:hover { background: #1a7f37; }
.submit-msg { margin-left: 12px; font-size: 12px; color: #1f883d; }

.review-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.review-controls button {
  background: #f6f8fa; border: 1px solid #d0d7de; padding: 4px 12px;
  border-radius: 4px; font-size: 12px; cursor: pointer;
}
.job-card {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}
.job-header {
  padding: 10px 14px;
  background: #f6f8fa;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid #d0d7de;
  user-select: none;
}
.job-toggle {
  background: transparent;
  border: 1px solid #d0d7de;
  color: #57606a;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.job-toggle:hover {
  background: #fff;
  border-color: #0969da;
  color: #0969da;
}
.job-header .state {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.state.queued           { background: #ddf4ff; color: #0969da; }
.state.processing       { background: #fff8c5; color: #9a6700; }
.state.ready_for_review { background: #ffebcc; color: #b35900; }   /* 还有 pending → 醒目橙 */
.state.all_decided      { background: #eaeef2; color: #57606a; }   /* 全决定（混合 apply+reject） */
.state.all_applied      { background: #dafbe1; color: #1a7f37; }   /* 全 apply 完 */
.state.all_rejected     { background: #f6f8fa; color: #6e7781; }   /* 全 reject */
.state.applied          { background: #d8b8ff; color: #6639ba; }
.state.failed           { background: #ffebe9; color: #cf222e; }
.cand-count-mini {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-right: 3px;
  font-weight: 600;
}
.cand-count-mini.pending  { background: #fff4d6; color: #b35900; }
.cand-count-mini.applied  { background: #dafbe1; color: #1a7f37; }
.cand-count-mini.rejected { background: #eaeef2; color: #6e7781; }
.job-body { padding: 12px 14px; display: none; }
.job-body.open { display: block; }
.candidate-card {
  border: 1px solid #eaeef2;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
  border-left: 4px solid #fb8500;  /* pending 默认橙色左边 */
}
.candidate-card.state-pending  { border-left-color: #fb8500; background: #fff8c5; }
.candidate-card.state-applied  { border-left-color: #1a7f37; background: #f6f8fa; opacity: 0.85; }
.candidate-card.state-rejected { border-left-color: #6e7781; background: #f6f8fa; opacity: 0.55; }
.cand-state-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: 8px;
  vertical-align: middle;
}
.cand-state-badge.pending  { background: #fb8500; color: #fff; }
.cand-state-badge.applied  { background: #1a7f37; color: #fff; }
.cand-state-badge.rejected { background: #6e7781; color: #fff; }
.candidate-card h4 { margin: 0 0 4px 0; font-size: 13px; }
.candidate-card .meta { font-size: 11px; color: #57606a; }
.candidate-card pre {
  background: #f6f8fa;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  overflow-x: auto;
  margin: 6px 0;
  max-height: 220px;
}
.candidate-card .verdict {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
}
.verdict.novel     { background: #dafbe1; color: #1a7f37; }
.verdict.duplicate { background: #ffebe9; color: #cf222e; }
.verdict.unsure    { background: #fff8c5; color: #9a6700; }
.smoke-ok { color: #1a7f37; font-weight: 600; }
.smoke-fail { color: #cf222e; font-weight: 600; }
.smoke-manual { color: #9a6700; font-weight: 600; background: #fff8c5; padding: 1px 6px; border-radius: 3px; cursor: help; }
.candidate-actions {
  display: flex; gap: 8px; margin-top: 10px;
}
.cand-preview-controls {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin: 8px 0; padding: 6px 8px;
  background: #f6f8fa; border-radius: 4px;
}
.cand-preview-controls label { font-size: 11px; color: #57606a; display: flex; align-items: center; gap: 3px; }
.cand-preview-controls select, .cand-preview-controls input[type=date] {
  font-size: 11px; padding: 2px 5px; border: 1px solid #d0d7de; border-radius: 3px;
  background: #fff; font-family: ui-monospace, monospace;
}
.cand-preview-controls input[type=date] { width: 130px; }
.btn-cand-preview {
  background: #8250df; color: #fff; border: 0;
  padding: 4px 12px; border-radius: 3px; cursor: pointer;
  font-size: 11px;
}
.btn-cand-preview:hover { background: #6639ba; }
.btn-cand-preview:disabled { background: #d0d7de; color: #6e7781; cursor: not-allowed; }
.btn-cand-collapse {
  background: #f6f8fa; color: #57606a; border: 1px solid #d0d7de;
  padding: 3px 10px; border-radius: 3px; cursor: pointer; font-size: 11px;
}
.cand-preview-chart { margin: 6px 0; }
.cand-preview-chart.collapsed { display: none; }
.closest-node-box {
  background: #f6f8fa;
  border-left: 3px solid #0969da;
  padding: 8px 10px;
  margin: 6px 0;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
}
.closest-node-box code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
.btn-apply  { background: #1f883d; color: #fff; border: 0; padding: 5px 14px; border-radius: 4px; cursor: pointer; }
.btn-reject { background: #cf222e; color: #fff; border: 0; padding: 5px 14px; border-radius: 4px; cursor: pointer; }
.btn-disabled { background: #d0d7de; color: #6e7781; cursor: not-allowed; }
.llm-notes {
  background: #ddf4ff;
  border-left: 3px solid #0969da;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 12px;
  color: #24292f;
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
}
.refine-box {
  background: #f6f8fa;
  border: 1px dashed #d0d7de;
  padding: 10px 12px;
  margin: 10px 0;
  border-radius: 4px;
}
.refine-box textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
}
.btn-refine {
  background: #0969da; color: #fff; border: 0;
  padding: 5px 14px; border-radius: 4px; cursor: pointer;
  margin-top: 6px; font-size: 12px;
}
.btn-refine:disabled { background: #57606a; cursor: not-allowed; }
.applied-tag {
  background: #d8b8ff; color: #6639ba;
  padding: 3px 8px; border-radius: 3px; font-size: 11px; font-weight: 600;
}
.rejected-tag {
  background: #d0d7de; color: #6e7781;
  padding: 3px 8px; border-radius: 3px; font-size: 11px;
}
.nodes-controls {
  display: flex; gap: 12px; align-items: center; margin-bottom: 14px;
}
.nodes-controls button {
  background: #f6f8fa; border: 1px solid #d0d7de; padding: 4px 12px;
  border-radius: 4px; font-size: 12px; cursor: pointer;
}
.nodes-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.nodes-stat {
  background: #fff; border: 1px solid #d0d7de; border-radius: 6px;
  padding: 12px 14px; text-align: center;
}
.nodes-stat .num { font-size: 28px; font-weight: 700; }
.nodes-stat .lbl { font-size: 12px; color: #57606a; margin-top: 4px; }
.nodes-stat.ok   { border-left: 4px solid #1a7f37; }
.nodes-stat.warn { border-left: 4px solid #9a6700; }
.nodes-stat.fail { border-left: 4px solid #cf222e; }
.nodes-group { background: #fff; border: 1px solid #d0d7de; border-radius: 6px; margin-bottom: 10px; }
.nodes-group-head {
  padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 13px;
  border-bottom: 1px solid #d0d7de;
}
.nodes-group-head.fail { color: #cf222e; }
.nodes-group-head.warn { color: #9a6700; }
.nodes-group-head.ok   { color: #1a7f37; }
.nodes-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nodes-table th, .nodes-table td {
  text-align: left; padding: 5px 10px; border-bottom: 1px solid #eaeef2;
}
.nodes-table th { background: #f6f8fa; font-weight: 500; }
.nodes-table .status.fail { color: #cf222e; font-weight: 600; }
.nodes-table .status.warn { color: #9a6700; font-weight: 600; }
.nodes-table .status.ok   { color: #1a7f37; }

.nodes-section-h {
  margin: 24px 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #24292f;
  border-bottom: 1px solid #d0d7de;
  padding-bottom: 4px;
}
.bg-group { background: #fff; }
.side-group { background: #fff; margin-bottom: 8px; }
.side-cat-list { padding: 4px 12px 8px 12px; }
.cat-group { margin: 6px 0; background: #f6f8fa; }
.nodes-group-head.side {
  font-size: 13px;
  font-weight: 700;
  border-left: 4px solid;
  padding-left: 12px;
}
.nodes-group-head.side.right_side { border-left-color: #cf222e; color: #cf222e; }
.nodes-group-head.side.left_side  { border-left-color: #1f883d; color: #1f883d; }
.nodes-group-head.side.time_based { border-left-color: #9a6700; color: #9a6700; }
.nodes-group-head.cat { font-size: 12px; padding: 6px 12px; font-weight: 500; }
.bg-node-list { padding: 8px 12px; }
.bg-node-row {
  padding: 8px 0;
  border-bottom: 1px dashed #eaeef2;
}
.bg-node-row:last-child { border-bottom: none; }
.bg-node-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.bg-node-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: #f6f8fa; padding: 1px 6px; border-radius: 3px;
}
.node-badge {
  display: inline-block; width: 18px; text-align: center; font-size: 12px;
}
.node-badge.ok   { color: #1a7f37; }
.node-badge.warn { color: #9a6700; cursor: help; }
.node-badge.fail { color: #cf222e; cursor: help; }
.bg-node-desc {
  font-size: 12px; color: #57606a; margin: 4px 0 6px 26px;
}
.node-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.node-controls label {
  font-size: 11px;
  color: #57606a;
  display: flex;
  align-items: center;
  gap: 3px;
}
.node-controls select, .node-controls input[type=date] {
  font-size: 11px;
  padding: 2px 5px;
  border: 1px solid #d0d7de;
  border-radius: 3px;
  background: #fff;
  font-family: ui-monospace, monospace;
}
.node-controls select { min-width: 56px; }
.node-controls input[type=date] { width: 130px; }
.btn-load-signal {
  background: #ddf4ff; color: #0969da; border: 1px solid #54aeff;
  padding: 3px 10px; border-radius: 3px; cursor: pointer;
  font-size: 11px;
}
.btn-load-signal:hover { background: #b6e3ff; }
.btn-load-signal:disabled { background: #d0d7de; color: #6e7781; cursor: not-allowed; }
.btn-collapse-signal {
  background: #f6f8fa; color: #57606a; border: 1px solid #d0d7de;
  padding: 3px 10px; border-radius: 3px; cursor: pointer;
  font-size: 11px;
}
.btn-collapse-signal:hover { background: #eaeef2; color: #24292f; }
.bg-node-chart { margin: 8px 0 6px 26px; min-height: 0; }
.bg-node-chart.collapsed { display: none; }

.error-block {
  background: #ffebe9; border: 1px solid #ffcecb; padding: 10px;
  border-radius: 4px; font-family: ui-monospace, monospace; font-size: 11px;
  white-space: pre-wrap; max-height: 240px; overflow: auto;
}

/* ── 组合 tab ──────────────────────────────────────────── */
.portfolio-intro {
  margin: 8px 0 12px;
  padding: 8px 12px;
  background: #ddf4ff;
  border-left: 3px solid #0969da;
  border-radius: 3px;
}
.portfolio-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.portfolio-controls fieldset {
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 10px 12px 12px;
  background: #f6f8fa;
}
.portfolio-controls legend {
  font-size: 12px;
  color: #0969da;
  font-weight: 600;
  padding: 0 4px;
}
.portfolio-controls label {
  display: flex; flex-direction: column;
  font-size: 11px; color: #57606a; margin-top: 6px;
}
.portfolio-controls select,
.portfolio-controls input[type="range"] {
  font-size: 12px; padding: 3px 4px; margin-top: 2px;
}
.portfolio-controls input[type="range"] { padding: 0; }
.manual-row { margin-top: 8px; padding-top: 6px; border-top: 1px dashed #d0d7de; }
.w-display { font-weight: 600; color: #0969da; font-size: 12px; margin-left: 6px; }
.portfolio-actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 14px;
}
#run-portfolio {
  background: #0969da; color: white; border: 0; border-radius: 3px;
  padding: 8px 18px; cursor: pointer; font-size: 13px; font-weight: 600;
}
#run-portfolio:hover { background: #0860c8; }
#run-portfolio:disabled { background: #8c959f; cursor: not-allowed; }
.btn-secondary {
  background: #f6f8fa; color: #24292f; border: 1px solid #d0d7de;
  border-radius: 3px; padding: 7px 12px; cursor: pointer; font-size: 12px;
}
.btn-secondary:hover { background: #eaeef2; }

.schedule-row {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 0 10px; border-top: 1px solid #d0d7de;
  margin-top: 4px;
}
.schedule-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; }
.schedule-time { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.schedule-time input[type="time"] { width: 90px; padding: 4px 6px; font-size: 12px; border: 1px solid #d0d7de; border-radius: 3px; }
#save-schedule { font-size: 11px; padding: 4px 10px; }

.portfolio-main-plot { min-height: 600px; margin-bottom: 18px; }
.portfolio-chart-controls {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.portfolio-chart-controls .control-label {
  font-size: 13px; display: flex; align-items: center; gap: 4px;
}
.portfolio-chart-controls input[type="date"] {
  padding: 3px 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px;
}
.portfolio-chart-controls .btn-sm { padding: 4px 12px; font-size: 12px; }
.portfolio-monthly-plot { min-height: 240px; margin: 14px 0; }

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.metric-card {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-left: 3px solid #57606a;
  border-radius: 3px;
  padding: 10px 14px;
}
.metric-card.pos { border-left-color: #1f883d; }
.metric-card.neg { border-left-color: #cf222e; }
.metric-card.neutral { border-left-color: #6e7781; }
.metric-label { color: #57606a; font-size: 11px; margin-bottom: 4px; }
.metric-val { font-size: 18px; font-weight: 600; color: #24292f; }

.portfolio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 14px 0;
}
.section-h {
  font-size: 14px; color: #24292f;
  margin: 0 0 10px; padding-bottom: 4px;
  border-bottom: 2px solid #0969da;
}

.cross-weights { margin-bottom: 12px; }
.cross-bar-row {
  display: grid;
  grid-template-columns: 48px 1fr 60px;
  gap: 8px; align-items: center;
  margin-bottom: 6px; font-size: 12px;
}
.cross-label { color: #57606a; }
.cross-bar {
  background: #eaeef2; height: 16px; border-radius: 8px; overflow: hidden;
}
.cross-bar-fill { height: 100%; transition: width .25s; }
.cross-bar-fill.trend { background: #0969da; }
.cross-bar-fill.reversal { background: #d29922; }
.cross-bar-fill.fundamental { background: #1f883d; }
.cross-val { text-align: right; font-weight: 600; color: #24292f; font-variant-numeric: tabular-nums; }

.cluster-search-row {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 4px;
}
.cluster-search-input {
  padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px;
  font-size: 13px; width: 200px;
}
.cluster-highlight {
  outline: 3px solid #0969da;
  outline-offset: 2px;
  transition: outline 0.3s;
}

.weight-block { margin: 6px 0; }
.weight-block summary {
  cursor: pointer; padding: 6px 8px;
  background: #f6f8fa; border-radius: 3px; font-size: 12px;
}
.weight-table {
  width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px;
}
.weight-table th, .weight-table td {
  padding: 4px 8px; border-bottom: 1px solid #eaeef2;
  text-align: left;
}
.weight-table th { background: #f6f8fa; color: #57606a; font-weight: 600; }
.weight-sub td { padding-left: 24px !important; background: #fcfdfe; }

.weight-matrix-wrap {
  margin: 8px 0; overflow-x: auto;
}
.weight-matrix-title {
  font-size: 11px; font-weight: 600; color: #57606a; margin-bottom: 4px;
}
.weight-matrix {
  border-collapse: collapse; font-size: 11px;
}
.weight-matrix th, .weight-matrix td {
  padding: 3px 6px; border: 1px solid #eaeef2; white-space: nowrap;
  text-align: right; min-width: 52px;
}
.weight-matrix th {
  background: #f6f8fa; color: #57606a; font-weight: 600; font-size: 10px;
}
.matrix-row-label {
  text-align: left; font-weight: 500; max-width: 120px; overflow: hidden;
  text-overflow: ellipsis;
}
.matrix-cell { font-variant-numeric: tabular-nums; }

.exposure-table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
.exposure-table th { background: #f6f8fa; color: #57606a; font-weight: 600;
  text-align: left; padding: 4px 6px; }
.exposure-table td { padding: 3px 6px; border-bottom: 1px solid #eaeef2; }
.exp-sym { font-weight: 600; font-family: ui-monospace, monospace; }
.exp-bar-cell { width: 50%; }
.exp-bar { height: 12px; border-radius: 6px; }
.exp-bar.long { background: #1f883d; }
.exp-bar.short { background: #cf222e; }

.returns-table {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px;
}
.returns-table th, .returns-table td {
  padding: 6px 10px; border-bottom: 1px solid #eaeef2;
  text-align: left; font-variant-numeric: tabular-nums;
}
.returns-table th { background: #f6f8fa; color: #57606a; font-weight: 600; }
.portfolio-yearly { margin-top: 14px; }

.num.pos { color: #1f883d; }
.num.neg { color: #cf222e; }

.direction-section { margin-top: 22px; }
.direction-section .section-h span { font-weight: normal; margin-left: 8px; }
.direction-plot { min-height: 420px; }

/* 三方向 NAV 对比 */
.dir-nav-table, .corr-table { border-collapse: collapse; font-size: 13px; width: 100%; max-width: 600px; }
.dir-nav-table th, .corr-table th { background: #f6f8fa; color: #57606a; font-weight: 600; padding: 4px 10px; text-align: right; }
.dir-nav-table th:first-child, .corr-table th:first-child { text-align: left; }
.dir-nav-table td, .corr-table td { padding: 3px 10px; text-align: right; border-top: 1px solid #eee; }
.dir-nav-table td:first-child, .corr-table td:first-child { text-align: left; }
.corr-table td.num.pos-high { color: #cf222e; font-weight: 600; }
.corr-table td.num.pos-mid { color: #d29922; font-weight: 600; }
.corr-table td.num.diag { color: #57606a; }
.corr-table td.num.neg { color: #1f883d; }

/* ② 方向内聚合（含 Pool A/B 拆分）*/
.direction-fieldset {
  grid-column: 1 / -1;   /* 跨满 3 列 */
  background: #f6f8fa !important;
}
.direction-shared {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #d0d7de;
  margin-bottom: 12px;
}
.direction-subblock {
  background: white;
  border: 1px solid #d0d7de;
  border-left: 3px solid #0969da;
  border-radius: 3px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.direction-subblock:last-child { margin-bottom: 0; border-left-color: #d29922; }
.dir-header {
  font-size: 12px; font-weight: 600; color: #24292f;
  margin-bottom: 8px;
}
.dir-row {
  display: grid;
  grid-template-columns: 1fr 1fr 90px 90px;
  gap: 12px;
  margin-bottom: 8px;
}
.cap-toggle {
  display: block; margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed #b1c5d6;
  font-size: 12px; cursor: pointer; color: #24292f;
}
.cap-toggle input { vertical-align: middle; margin-right: 4px; }
.picker-hint { padding: 4px 0; }
.sat-cluster-picker {
  margin-top: 4px; max-height: 160px; overflow-y: auto;
  padding: 4px; background: #fafbfc; border: 1px solid #d0d7de; border-radius: 3px;
}
.sat-row {
  display: grid !important;
  grid-template-columns: 18px 80px 1fr 30px;
  gap: 4px; align-items: center;
  padding: 2px 4px; font-size: 11px; cursor: pointer;
}
.sat-row:hover { background: #f6f8fa; }
.sat-row.low-freq { background: #fff8c5; }
.sat-row.low-freq:hover { background: #fae3a0; }
.sat-ckey { font-family: ui-monospace, monospace; font-size: 11px; color: #24292f; }
.sat-freq { font-variant-numeric: tabular-nums; color: #57606a; }

/* 交易文件生成 */
.trade-gen-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.trade-gen-result {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  padding: 12px;
  max-height: 500px;
  overflow-y: auto;
}
.trade-gen-path {
  font-size: 12px;
  margin-bottom: 8px;
  color: #57606a;
}
.trade-gen-path code {
  font-size: 11px;
  background: #fff;
  padding: 2px 6px;
  border: 1px solid #d0d7de;
  border-radius: 3px;
}
.trade-gen-table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}
.trade-gen-table th {
  background: #eaeef2;
  color: #57606a;
  font-weight: 600;
  padding: 4px 10px;
  text-align: right;
}
.trade-gen-table th:first-child { text-align: left; }
.trade-gen-table td {
  padding: 3px 10px;
  text-align: right;
  border-top: 1px solid #eee;
  font-variant-numeric: tabular-nums;
}
.trade-gen-table td:first-child {
  text-align: left;
  font-weight: 600;
}

/* pipeline status banner (顶部 daily 校验报告) */
.pipeline-status-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  background: linear-gradient(to right, #f8fafd 0%, #fff 100%);
  border: 1px solid #c5d4e3;
  border-radius: 6px;
  font-size: 0.85em;
}
.pipeline-status-banner.empty {
  display: none;
}
.pipeline-status-banner .ps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pipeline-status-banner .ps-title {
  font-weight: 600;
  font-size: 1em;
}
.pipeline-status-banner .ps-toggle {
  cursor: pointer;
  color: #555;
  font-size: 0.9em;
  user-select: none;
}
.pipeline-status-banner .ps-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 16px;
  font-variant-numeric: tabular-nums;
}
.pipeline-status-banner .ps-kv .label {
  color: #777;
  font-size: 0.85em;
}
.pipeline-status-banner .ps-kv .val {
  font-weight: 600;
}
.pipeline-status-banner .ps-kv .behind {
  color: #d97706;
}
.pipeline-status-banner .ps-kv .miss {
  color: #c00;
}
.pipeline-status-banner .ps-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
}
.pipeline-status-banner .ps-section-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #444;
}
.pipeline-status-banner.collapsed .ps-detail {
  display: none;
}
.pipeline-status-banner.collapsed .ps-summary {
  display: block;
}
.pipeline-status-banner .ps-summary {
  display: none;
  color: #555;
}

/* exposure latest date badge */
.exposure-date-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-left: 8px;
  background: #e3f2fd;
  color: #0d47a1;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── 策略健康检测 tab ─────────────────────────────────── */
.health-intro {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f7f9fc;
  border-left: 3px solid #aac;
  border-radius: 4px;
}
.health-section {
  margin-bottom: 24px;
  padding: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.health-section-title {
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
}

/* Walk-forward status panel */
.wf-status-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 24px;
  padding: 10px 12px;
  background: #f8fafd;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.wf-status-panel .kv-label { color: #777; font-size: 0.85em; }
.wf-status-panel .kv-value { font-weight: 600; }
.wf-status-panel .kv-eligible-yes { color: #0a8a30; }
.wf-status-panel .kv-eligible-no  { color: #888; }
.wf-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#wf-msg.error { color: #c00; }
#wf-msg.success { color: #0a8a30; }
.wf-history { margin-top: 10px; }
.wf-history summary { cursor: pointer; color: #555; font-size: 0.9em; }
.wf-history-list { margin-top: 8px; font-size: 0.85em; color: #555; }
.wf-history-entry {
  padding: 6px 8px;
  border-left: 2px solid #cbd5e1;
  margin-bottom: 6px;
  background: #f8fafd;
}
.wf-dryrun-output {
  margin-top: 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.wf-dryrun-pre {
  background: #0f172a;
  color: #c0d3ec;
  font-family: ui-monospace, monospace;
  font-size: 0.78em;
  line-height: 1.4;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  max-height: 400px;
  white-space: pre;
}

/* Direction summary grid */
.health-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.health-direction-card {
  padding: 12px;
  background: #f8fafd;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.health-direction-card h3 {
  margin: 0 0 8px;
  font-size: 1em;
  color: #333;
}
.health-direction-card .lifecycle-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.health-direction-card .avg-fresh {
  margin-top: 8px;
  color: #555;
  font-size: 0.9em;
}

/* Lifecycle state badges */
.lifecycle-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.lifecycle-GREEN              { background: #d4f5dc; color: #086626; }
.lifecycle-YELLOW             { background: #fef3c7; color: #92400e; }
.lifecycle-RED                { background: #fee2e2; color: #991b1b; }
.lifecycle-INSUFFICIENT_DATA  { background: #e5e7eb; color: #555;    }
.lifecycle-pill.muted { opacity: 0.4; }

/* Health table */
.health-table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9em;
}
.health-table-wrap {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}
.health-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.health-table th,
.health-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}
.health-table th {
  background: #f8fafd;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
.health-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.health-table tr.row-RED    { background: #fff5f5; }
.health-table tr.row-YELLOW { background: #fffbeb; }
.health-table tr.row-GREEN  { background: #f5fffa; }
.health-table tr:hover { background: #eef4ff; cursor: default; }
.health-table .fp-mono { font-family: ui-monospace, monospace; font-size: 0.85em; }

