:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
#app { max-width: 1500px; margin: 0 auto; padding: 12px 16px 60px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; margin-top: 14px;
}
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel h4 { margin: 12px 0 8px; font-size: 13.5px; color: var(--muted); }



.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  color: var(--text); border-radius: 6px; padding: 6px 14px; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 10px; font-size: 13px; }

.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.field input[type=number], .field select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px;
}
.field input:focus, .field select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

.group { margin-bottom: 10px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.group-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.group-head .btn { margin-left: auto; }
.opt {
  display: flex; align-items: center; gap: 6px; padding: 3px 4px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.opt:hover { background: #f0f4ff; }
.opt input { accent-color: var(--primary); }
.opt .desc { color: var(--muted); font-size: 12px; }

table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { border: 1px solid var(--border); padding: 5px 8px; }
table.data th { background: #f0f2f5; cursor: pointer; user-select: none; position: sticky; top: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.best td { background: #ecfdf5; }
tr.worst td { background: #fef2f2; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.chart-box h5 { margin: 4px 6px 8px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.chart { width: 100%; height: 380px; }

.status-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-running { background: #dbeafe; color: #1e40af; }
.status-done { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }

.progress-panel { border-left: 4px solid var(--primary); }
.progress-panel .q { color: var(--muted); margin: 6px 0; }
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: 6px; padding: 10px 12px; margin-top: 8px; white-space: pre-wrap;
}

/* CSV 可编辑表格 */
.csv-table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--border); border-radius: 6px; }
table.editable { border-collapse: collapse; }
table.editable th, table.editable td { border: 1px solid #e5e7eb; padding: 0; }
table.editable th { background: #f0f2f5; font-weight: 500; color: var(--muted); min-width: 46px; text-align: center; position: sticky; }
table.editable th.rowh { left: 0; z-index: 2; }
table.editable thead th { top: 0; z-index: 3; }
table.editable input {
  width: 100%; min-width: 64px; border: none; padding: 5px 7px;
  font-size: 13px; font-variant-numeric: tabular-nums; text-align: right;
  background: transparent;
}
table.editable input:focus { outline: 2px solid #bfdbfe; background: #fff; }

/* 只读表格样式 */
table.readonly { border-collapse: collapse; width: 100%; }
table.readonly th, table.readonly td { border: 1px solid #e5e7eb; padding: 5px 8px; }
table.readonly th { background: #f0f2f5; font-weight: 500; color: var(--muted); min-width: 46px; text-align: center; position: sticky; }
table.readonly th.rowh { left: 0; z-index: 2; }
table.readonly thead th { top: 0; z-index: 3; }
table.readonly td { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; background: #fafbfc; }
table.editable input.invalid { background: #fee2e2; }
table.editable input.empty { background: #fff7ed; }

.steps { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.step .n {
  width: 22px; height: 22px; border-radius: 50%; background: var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
}
.step.on { color: var(--text); font-weight: 600; }
.step.on .n { background: var(--primary); }

.stat-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.stat-card {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px;
  min-width: 150px; background: #fff;
}
.stat-card .k { color: var(--muted); font-size: 12px; }
.stat-card .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

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

/* CSV 梯度对比: 左右分栏对比 */
.lr-compare { display: flex; flex-direction: column; gap: 14px; }
.lr-head, .lr-row {
  display: grid; grid-template-columns: minmax(110px, 160px) 1fr 1fr; gap: 12px;
}
.lr-title {
  grid-column: 2 / 2; font-weight: 600; font-size: 14.5px; color: var(--primary);
  text-align: center; padding-bottom: 2px; border-bottom: 2px solid var(--primary);
}
.lr-title + .lr-title { grid-column: 3 / 3; color: #dc2626; border-color: #dc2626; }
.lr-row { border-top: 1px solid var(--border); padding-top: 10px; align-items: start; }
.lr-label {
  font-weight: 600; font-size: 13px; color: #334155;
  padding-top: 8px; line-height: 1.5;
}
.lr-cell .chart { height: 300px; }
.lr-cell .csv-table-wrap { max-height: 320px; }

/* CSV 梯度对比: 各方向 max INL 柱状图 */
.dir-chart-block { margin: 12px 0 18px; }
.dir-chart-block h4 {
  font-size: 14px; margin: 0 0 4px; color: var(--text); font-weight: 600;
}
.dir-chart {
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; padding: 8px 8px 4px; margin-bottom: 12px;
}
.dir-chart-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 2px 4px 4px; padding-left: 4px;
  border-left: 3px solid var(--primary);
}
