:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-2: #5b6675;
  --line: #e3e8ef;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #e7f6ec;
  --bad: #dc2626;
  --bad-bg: #fdeaea;
  --warn: #d97706;
  --warn-bg: #fff4e0;
  --accent: #7c3aed;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
header.app {
  background: linear-gradient(120deg, #1e3a8a, #2563eb);
  color: #fff; padding: 16px 24px; box-shadow: var(--shadow);
}
header.app h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
header.app p { margin: 4px 0 0; font-size: 12.5px; opacity: .9; }
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 16px;
  padding: 16px; max-width: 1400px; margin: 0 auto; align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; }
.card h2 .tag { font-size: 11px; font-weight: 600; color: var(--brand); background: #eaf1ff;
  padding: 2px 8px; border-radius: 999px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field .hint { font-size: 10.5px; color: #97a1b0; }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  background: #fff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #2563eb22; }
.row-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s; width: 100%;
}
.btn:hover { background: var(--brand-d); }
.btn.secondary { background: #eef2f7; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #e3e9f2; }

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; }
.kv .item { display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px dashed #eef1f5; }
.kv .item .k { color: var(--ink-2); font-size: 12.5px; }
.kv .item .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.kv .item .v small { font-weight: 500; color: var(--ink-2); margin-left: 2px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1200px) { .charts { grid-template-columns: 1fr; } }
.chart-box { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fcfdff; }
.chart-box .ct { font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 4px 6px; }

table.motors { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.motors th, table.motors td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.motors th { background: #f3f6fb; color: var(--ink-2); font-weight: 700; position: sticky; top: 0; }
table.motors td.name, table.motors th.name { text-align: left; font-weight: 700; }
table.motors tr.sel { background: #eaf1ff; }
table.motors tr.qual:hover { cursor: pointer; background: #f0f5ff; }
table.motors tr.fail { color: #9aa4b2; }
.mono { font-variant-numeric: tabular-nums; }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.detail-grid .d { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.detail-grid .d .t { font-size: 11px; color: var(--ink-2); }
.detail-grid .d .n { font-size: 13px; font-weight: 700; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }
.empty { color: var(--ink-2); padding: 20px; text-align: center; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* Report */
#report { display: none; }
#report.show { display: block; }
.report-doc { background: #fff; padding: 24px; border: 1px solid var(--line); border-radius: 10px; }
.report-doc h3 { margin: 18px 0 8px; font-size: 15px; border-left: 4px solid var(--brand); padding-left: 8px; }
.report-doc table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
.report-doc th, .report-doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.report-doc th { background: #f3f6fb; }
.report-meta { color: var(--ink-2); font-size: 12px; }

@media print {
  body * { visibility: hidden; }
  #report, #report * { visibility: visible; }
  #report { position: absolute; left: 0; top: 0; width: 100%; }
  .noprint { display: none !important; }
}
