:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9dee7;
  --line-soft: #ecf0f5;
  --text: #111827;
  --muted: #5f6b7a;
  --blue: #1d4ed8;
  --green: #15803d;
  --red: #b91c1c;
  --amber: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-header {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 84px;
  padding: 18px 28px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  margin: 0 0 6px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 20px 28px 40px;
}

.report-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.report-links a,
button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.report-links a,
button {
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.report-links a:hover,
button:hover {
  background: #eef4ff;
  border-color: #b9c7ee;
  text-decoration: none;
}

.toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 210px minmax(220px, 1fr) 180px 140px;
  margin-bottom: 16px;
}

label {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  gap: 5px;
}

select,
input {
  background: #ffffff;
  color: var(--text);
  min-height: 36px;
  padding: 7px 9px;
}

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

.kpi,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi {
  padding: 14px 16px;
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}

.kpi strong {
  display: block;
  font-size: 26px;
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
}

.panel-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.curve-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.job-box {
  background: #f8fafc;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.job-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-track {
  background: #e5eaf1;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: #1d4ed8;
  height: 100%;
  transition: width 200ms ease;
  width: 0;
}

.panel-head p,
.panel > p {
  color: var(--muted);
  margin: 5px 0 0;
}

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.metric-list {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: 140px minmax(0, 1fr);
  margin: 12px 0 0;
}

.metric-list dt {
  color: var(--muted);
}

.metric-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.chart {
  background: #fbfcfe;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  display: block;
  height: auto;
  width: 100%;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
}

.gridline {
  stroke: #e7ebf1;
  stroke-width: 1;
}

.axis-line {
  stroke: #bcc5d2;
  stroke-width: 1;
}

.chart-point {
  cursor: pointer;
  fill: #2563eb;
  opacity: 0.72;
}

.chart-point:hover {
  opacity: 1;
}

.equity-line {
  fill: none;
  stroke-width: 2.5;
}

.median-line {
  stroke: #1d4ed8;
}

.mean-line {
  stroke: #15803d;
}

.selection-line {
  stroke: #c2410c;
}

.research-line {
  stroke: #be123c;
}

.v2-line {
  stroke: #0f766e;
}

.v2-table-wrap {
  margin-bottom: 12px;
  max-height: 310px;
}

.v2-chart {
  max-height: 300px;
}

.v2-candidate-row {
  cursor: pointer;
}

.v2-pipeline-status {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 360px) 48px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.v2-pipeline-copy {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: baseline;
}

.v2-pipeline-copy strong {
  white-space: nowrap;
}

.v2-pipeline-copy span {
  color: #667085;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-pipeline-progress {
  height: 8px;
  overflow: hidden;
  background: #e5e7eb;
}

.v2-pipeline-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: #0f766e;
  transition: width 180ms ease;
}

.v2-pipeline-status[data-status="failed"] .v2-pipeline-progress span {
  background: #b91c1c;
}

.v2-pipeline-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.v2-paper-box {
  border-bottom: 1px solid #e5e7eb;
}

.v2-paper-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px 4px;
}

.v2-paper-head span {
  color: #667085;
}

.status-paper_candidate {
  background: #dcfce7;
  color: #166534;
}

.status-research_shadow {
  background: #fef3c7;
  color: #92400e;
}

.status-audit-passed {
  background: #dcfce7;
  color: #166534;
}

.status-audit-drifted {
  background: #fee2e2;
  color: #991b1b;
}

.status-audit-not_audited {
  background: #e5e7eb;
  color: #475467;
}

@media (max-width: 760px) {
  .v2-pipeline-status {
    grid-template-columns: 1fr 44px;
  }

  .v2-pipeline-copy {
    grid-column: 1 / -1;
  }
}

.v2-candidate-row:hover,
.active-row {
  background: #eef7f6;
}

.status-eligible {
  background: #dcfce7;
  color: #166534;
}

.status-blocked_data {
  background: #fee2e2;
  color: #991b1b;
}

.status-research {
  background: #fef3c7;
  color: #92400e;
}

.status-paper {
  background: #dbeafe;
  color: #1e40af;
}

.benchmark-line {
  stroke: #667085;
  stroke-dasharray: 5 5;
}

.chart-legend {
  fill: #0f766e;
  font-size: 12px;
}

.benchmark-legend {
  fill: #667085;
}

.zero-line {
  stroke: #667085;
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.table-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  max-height: 620px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 920px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 9px;
  text-align: right;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475467;
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 1;
}

td:first-child,
td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
th:first-child,
th:nth-child(2),
th:nth-child(3),
th:nth-child(4) {
  text-align: left;
}

.status-pill {
  background: #f2f4f7;
  border-radius: 999px;
  color: #344054;
  display: inline-flex;
  max-width: 160px;
  overflow: hidden;
  padding: 3px 8px;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.pos {
  color: var(--green);
}

.neg {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.excerpt {
  color: #243043;
  line-height: 1.8;
  max-width: 1100px;
  white-space: pre-wrap;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  height: 220px;
  justify-content: center;
}

@media (max-width: 900px) {
  .app-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .shell {
    padding: 16px;
  }

  .toolbar,
  .kpi-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
