:root {
  --bg: #070a0e;
  --panel: #0c1117;
  --panel-2: #111820;
  --panel-3: #151e27;
  --line: #1c2731;
  --line-strong: #2a3946;
  --text: #dce7ef;
  --muted: #7e93a4;
  --dim: #556776;
  --accent: #3ce0c5;
  --accent-2: #ffb454;
  --danger: #ff5d5d;
  --radius: 10px;
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(1200px 600px at 75% -10%, rgba(60, 224, 197, 0.05), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(255, 180, 84, 0.04), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

#app { height: 100%; display: flex; flex-direction: column; }

/* ---------------- top bar ---------------- */

.topbar {
  height: 62px;
  flex: 0 0 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 13, 18, 0.85);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(60, 224, 197, 0.5);
  border-radius: 9px;
  color: var(--accent);
  font-size: 17px;
  box-shadow: 0 0 18px rgba(60, 224, 197, 0.15) inset;
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-text h1 span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.badge {
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.badge.accent { border-color: rgba(60, 224, 197, 0.35); color: var(--accent); background: rgba(60, 224, 197, 0.06); }
.badge.online { border-color: rgba(60, 224, 197, 0.35); color: var(--accent); background: rgba(60, 224, 197, 0.06); }
.badge.offline { border-color: rgba(255, 180, 84, 0.3); color: var(--accent-2); background: rgba(255, 180, 84, 0.06); }

.btn {
  height: 30px;
  padding: 0 13px;
  border: 1px solid rgba(60, 224, 197, 0.4);
  border-radius: 7px;
  background: rgba(60, 224, 197, 0.1);
  color: var(--accent);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { background: rgba(60, 224, 197, 0.18); border-color: rgba(60, 224, 197, 0.65); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.ghost { border-color: var(--line-strong); background: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); background: rgba(255, 255, 255, 0.03); }

.icon-btn {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

/* ---------------- workspace ---------------- */

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 372px; }

.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(35, 70, 90, 0.15), transparent 70%),
    #080c11;
}

#scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.hud { position: absolute; pointer-events: none; z-index: 2; }
.hud-tl { top: 14px; left: 14px; display: flex; flex-wrap: wrap; gap: 6px; }

.hud-chip {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid rgba(42, 57, 70, 0.8);
  border-radius: 7px;
  background: rgba(8, 12, 17, 0.72);
  backdrop-filter: blur(6px);
  font-size: 11px;
}

.hud-chip span { color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.hud-chip b { color: var(--text); font-family: var(--mono); font-weight: 500; }

.hud-tr { top: 16px; right: 16px; color: var(--dim); font-size: 11px; letter-spacing: 0.02em; }
.hud-bl { left: 14px; bottom: 14px; }

.legend {
  width: 152px;
  padding: 9px 10px;
  border: 1px solid rgba(42, 57, 70, 0.8);
  border-radius: 8px;
  background: rgba(8, 12, 17, 0.72);
  backdrop-filter: blur(6px);
}

.legend-title { color: var(--muted); font-size: 10.5px; letter-spacing: 0.04em; }

.legend-bar {
  height: 7px;
  margin: 6px 0 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #000014, #2a0a5e 20%, #7a1f6e 40%, #c43c39 60%, #f27c21 78%, #f9c932 90%, #fcffa4);
}

.legend-scale { display: flex; justify-content: space-between; color: var(--dim); font-size: 10px; }

/* ---------------- camera / metrics strip ---------------- */

.inspect {
  flex: 0 0 auto;
  display: flex;
  gap: 16px;
  align-items: stretch;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 18, 24, 0.7), rgba(9, 13, 18, 0.95));
}

.cam-card {
  flex: 0 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.card-head .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(60, 224, 197, 0.7);
}

.card-head .muted {
  margin-left: auto;
  padding-left: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-frame {
  position: relative;
  width: 280px;
  height: 210px;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  border: 1px solid #1b2530;
}

#cam-canvas { display: block; width: 100%; height: 100%; }

.cam-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 38%, rgb(0 0 0 / var(--vig, 0.3)) 100%),
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 100% 33.333%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 33.333% 100%;
}

.metrics {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  align-content: center;
}

.metric { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.metric span { display: block; margin-bottom: 4px; color: var(--dim); font-size: 10.5px; letter-spacing: 0.03em; }
.metric b {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric b em { color: var(--muted); font-style: normal; font-size: 10.5px; }
.metric.good b { color: var(--accent); }
.metric.warn b { color: var(--accent-2); }
.metric.bad b { color: var(--danger); }

/* ---------------- side panel ---------------- */

.panel {
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 18, 24, 0.9), rgba(9, 13, 18, 0.98));
  padding: 4px 18px 30px;
  scrollbar-width: thin;
  scrollbar-color: #24323e transparent;
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #24323e; border-radius: 8px; }

.group { padding: 18px 0 16px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }

.group h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
}

.group h2 .idx { color: var(--accent); font-family: var(--mono); font-size: 10px; letter-spacing: 0; }

.field { display: block; margin-bottom: 13px; }

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.field > span b { color: var(--text); font-family: var(--mono); font-size: 11.5px; font-weight: 500; }

select {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

select:focus { border-color: rgba(60, 224, 197, 0.55); box-shadow: 0 0 0 2px rgba(60, 224, 197, 0.1); }

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: #22303b; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0a1015;
  box-shadow: 0 0 8px rgba(60, 224, 197, 0.5);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: #22303b; }
input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0a1015;
}

.check { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; color: var(--muted); font-size: 11.5px; cursor: pointer; }
.check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.hint {
  margin: 12px 0 0;
  padding: 10px 11px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--dim);
  font-size: 10.8px;
  line-height: 1.65;
}

.hidden { display: none !important; }

/* ---------------- IES ---------------- */

.ies-field .ies-row { display: flex; gap: 8px; align-items: stretch; }

.file-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-btn input { display: none; }

.text-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  font: 11px var(--mono);
  outline: none;
}
.text-input:focus { border-color: rgba(60, 224, 197, 0.55); }

.unit-select {
  width: 62px;
  height: 30px;
  flex: 0 0 62px;
  padding: 0 5px;
  font-size: 11px;
}

#ies-plot {
  flex: 1;
  min-width: 0;
  height: 96px;
  border-radius: 6px;
  background: #0a1015;
}

/* ---------------- sub group ---------------- */

.sub-group {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
}

.slot-row { display: flex; gap: 6px; margin-bottom: 13px; }
.slot-row select { flex: 1; }
.slot-row .mini-btn { height: 32px; width: 32px; flex: 0 0 32px; font-size: 14px; }

.sub-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.aux-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.extra-card { margin-bottom: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.extra-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.extra-head .check { margin: 0; }
.extra-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.extra-grid label { display: flex; flex-direction: column; gap: 3px; min-width: 0; color: var(--dim); font-size: 9.5px; }
.extra-grid label span { display: flex; justify-content: space-between; gap: 6px; }
.extra-grid label b { color: var(--muted); font-family: var(--mono); font-weight: 400; }
.extra-grid select { height: 26px; padding: 0 5px; font-size: 10.5px; }
.extra-grid input[type="range"] { height: 14px; }

.catalog-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.file-inline { display: inline-flex; align-items: center; height: 24px; }
.file-inline input { display: none; }
.hint.compact { margin-top: 8px; padding: 7px 9px; }

.btn.wide { width: 100%; height: 32px; margin: 2px 0 10px; }

.result-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}
.result-line b { color: var(--text); font-weight: 500; }

/* ---------------- selection ---------------- */

.selection-list { display: flex; flex-direction: column; gap: 8px; }

.sel-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-2);
}
.sel-item.pass { border-left-color: var(--accent); }
.sel-item.fail { border-left-color: var(--danger); opacity: 0.82; }

.sel-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.sel-head b { flex: 1; min-width: 0; font-size: 10.8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-rank {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border-radius: 4px;
  background: rgba(60, 224, 197, 0.12);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9.5px;
}
.sel-score { color: var(--accent); font-family: var(--mono); font-size: 11px; }

.sel-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 2px 8px;
  color: var(--dim);
  font-size: 9.5px;
}
.sel-grid b { color: var(--muted); font-family: var(--mono); font-weight: 400; }

.sel-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 7px 0; }
.tag {
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
}
.tag.good { border-color: rgba(60, 224, 197, 0.35); color: var(--accent); }
.tag.bad { border-color: rgba(255, 93, 93, 0.35); color: var(--danger); }

.sel-apply { width: 100%; height: 24px; }

/* ---------------- collapsible groups ---------------- */

.group > h2 { cursor: pointer; user-select: none; }
.group > h2::after {
  content: '▾';
  margin-left: auto;
  color: var(--dim);
  font-size: 10px;
  transition: transform 0.15s;
}
.group.collapsed > h2::after { transform: rotate(-90deg); }
.group.collapsed > *:not(h2) { display: none !important; }

/* ---------------- scenario ---------------- */

.scenario-row { display: flex; gap: 8px; }
.scenario-row select { flex: 1; }
.scenario-row .btn { height: 32px; flex: 0 0 auto; }

/* ---------------- camera overlays ---------------- */

.scalebar {
  position: absolute;
  left: 10px;
  bottom: 9px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d7e6ef;
  font: 10px var(--mono);
  text-shadow: 0 1px 2px #000;
}
.scalebar i { display: block; height: 5px; border: 1px solid #d7e6ef; border-top: 0; }
.cam-fov-label {
  position: absolute;
  right: 9px;
  bottom: 8px;
  z-index: 2;
  color: #9fb4c2;
  font: 10px var(--mono);
  text-shadow: 0 1px 2px #000;
}

/* ---------------- histogram ---------------- */

.hist-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10.5px;
}
.hist-head b { margin-left: auto; color: var(--dim); font-family: var(--mono); font-weight: 400; font-size: 10px; }
#hist-canvas { display: block; width: 100%; height: 44px; margin-top: 5px; border-radius: 4px; background: #080d12; }
.mini-btn {
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------- diagnosis ---------------- */

.diagnosis { display: flex; flex-direction: column; gap: 7px; }
.diag-item {
  display: flex;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel-2);
}
.diag-dot { width: 6px; height: 6px; margin-top: 4px; flex: 0 0 6px; border-radius: 50%; background: var(--muted); }
.diag-item b { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; }
.diag-item p { margin: 0; color: var(--dim); font-size: 10.3px; line-height: 1.5; }
.diag-item.good { border-left-color: var(--accent); }
.diag-item.good .diag-dot { background: var(--accent); }
.diag-item.warn { border-left-color: var(--accent-2); }
.diag-item.warn .diag-dot { background: var(--accent-2); }
.diag-item.bad { border-left-color: var(--danger); }
.diag-item.bad .diag-dot { background: var(--danger); }

.snapshot-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.snapshot-actions .muted { color: var(--dim); font-size: 9.5px; }
.snapshot-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.snap-card { padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.snap-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.snap-head b { font-size: 10.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snap-head .icon-btn { width: 18px; height: 18px; font-size: 14px; }
.snap-grid { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 2px 8px; color: var(--dim); font-size: 9.5px; }
.snap-grid b { color: var(--muted); font-family: var(--mono); font-weight: 400; }

/* ---------------- defect result ---------------- */

.result-card {
  margin-top: 4px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.result-head span { color: var(--muted); font-size: 11px; }
.result-head b { font-size: 13px; }

.result-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 9px; }
.result-rows > div { padding: 6px 7px; border-radius: 5px; background: rgba(255, 255, 255, 0.025); }
.result-rows span { display: block; color: var(--dim); font-size: 9.5px; margin-bottom: 2px; }
.result-rows b { font-family: var(--mono); font-size: 11.5px; font-weight: 500; }

.meter { height: 5px; border-radius: 3px; background: #1b2630; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; transition: width 0.2s; }

.result-note { margin: 8px 0 0; color: var(--dim); font-size: 9.8px; line-height: 1.5; }

.tone-good { color: var(--accent); }
.tone-warn { color: var(--accent-2); }
.tone-bad { color: var(--danger); }
.meter i.tone-good { background: var(--accent); }
.meter i.tone-warn { background: var(--accent-2); }
.meter i.tone-bad { background: var(--danger); }

/* ---------------- modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 5, 8, 0.72);
  backdrop-filter: blur(4px);
}

.modal-box {
  width: min(640px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-box.wide { width: min(980px, 100%); }

/* ---------------- purchase import ---------------- */

.purchase-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.purchase-toolbar .muted { color: var(--muted); font-size: 11px; margin-right: auto; }
.check.inline { margin: 0; font-size: 11px; }
.purchase-table { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.p-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.p-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.p-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.p-table tr:last-child td { border-bottom: 0; }
.p-table td b { font-weight: 600; }
.p-table .muted { color: var(--dim); font-size: 10px; }
.p-table .small { font-size: 9.5px; }
.p-table .mono { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.p-table input[type="checkbox"] { accent-color: var(--accent); }
.tag.cat-camera { border-color: rgba(60, 224, 197, 0.35); color: var(--accent); }
.tag.cat-lens { border-color: rgba(110, 170, 255, 0.35); color: #6eaaff; }
.tag.cat-light { border-color: rgba(255, 180, 84, 0.35); color: var(--accent-2); }
.tag.cat-controller { border-color: rgba(200, 140, 255, 0.35); color: #c88cff; }
.tag.cat-accessory { color: var(--dim); }

/* ---------------- multi-view reconstruction ---------------- */

.mv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 14px; }
.mv-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 10.5px;
}
.mv-grid input[type="file"] { max-width: 100%; font-size: 9px; color: var(--dim); }

@media (max-width: 640px) {
  .mv-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------------- photo compare ---------------- */

.photo-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.blend-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; color: var(--muted); font-size: 11px; }
.blend-row input { flex: 1; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo-grid figure { margin: 0; min-width: 0; }
.photo-grid canvas { display: block; width: 100%; height: auto; min-height: 70px; border: 1px solid var(--line); border-radius: 6px; background: #000; }
.photo-grid figcaption { margin-top: 4px; color: var(--dim); font-size: 10px; text-align: center; }
.photo-stats { margin-top: 10px; color: var(--muted); font-family: var(--mono); font-size: 10.5px; line-height: 1.7; }
.photo-stats .muted { color: var(--dim); }

@media (max-width: 640px) {
  .photo-grid { grid-template-columns: 1fr; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.modal-body { padding: 14px; overflow: auto; }

.render-status { margin-bottom: 10px; color: var(--muted); font-family: var(--mono); font-size: 11px; }

#render-image { display: block; width: 100%; border-radius: 7px; background: #000; }
#render-image:not([src]) { display: none; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(520px, 90vw);
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(13, 18, 24, 0.96);
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast.good { border-color: rgba(60, 224, 197, 0.4); color: var(--accent); }
.toast.bad { border-color: rgba(255, 93, 93, 0.4); color: var(--danger); }
.toast.warn { border-color: rgba(255, 180, 84, 0.4); color: var(--accent-2); }

.viewport.drop-active::after {
  content: '松开导入 CAD';
  position: absolute;
  inset: 12px;
  z-index: 6;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: rgba(60, 224, 197, 0.06);
  color: var(--accent);
  font-size: 13px;
  pointer-events: none;
}

/* ---------------- report ---------------- */

.report-root { display: none; }

.rpt {
  max-width: 190mm;
  margin: 0 auto;
  padding: 0;
  color: #111;
  background: #fff;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  line-height: 1.5;
}

.rpt-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #111;
}

.rpt-head h1 { margin: 0; font-size: 20px; letter-spacing: 0.02em; }
.rpt-head p { margin: 3px 0 0; color: #666; font-size: 10.5px; }
.rpt-meta { text-align: right; color: #666; font-size: 10px; white-space: nowrap; }
.rpt-meta b { display: block; color: #111; font-family: var(--mono); font-size: 11px; }

.rpt-section { margin-top: 16px; page-break-inside: avoid; }
.rpt-section h2 { margin: 0 0 7px; font-size: 12.5px; border-left: 3px solid #111; padding-left: 7px; }

.rpt-sub { margin: 10px 0 5px; font-size: 11px; }
.rpt-table { width: 100%; border-collapse: collapse; }
.rpt-table th, .rpt-table td { border: 1px solid #d5d5d5; padding: 4px 7px; text-align: left; vertical-align: top; }
.rpt-table th { width: 120px; background: #f4f4f4; font-weight: 600; white-space: nowrap; }
.rpt-table thead th { width: auto; }

.rpt-figs { display: flex; gap: 12px; align-items: flex-start; }
.rpt-fig { margin: 0; flex: 1; min-width: 0; }
.rpt-fig img { display: block; width: 100%; border: 1px solid #ccc; border-radius: 3px; }
.rpt-fig figcaption { margin-top: 3px; color: #666; font-size: 9.5px; text-align: center; }

.rpt-notes { margin: 0; padding-left: 18px; color: #444; }
.rpt-notes li { margin-bottom: 3px; }

.rpt-foot {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding-top: 8px;
  border-top: 1px solid #bbb;
  color: #777;
  font-size: 9.5px;
}

.rpt-muted { color: #888; }

@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  #app, .modal, .toast { display: none !important; }
  .report-root { display: block !important; }
  @page { size: A4; margin: 12mm; }
}

/* ---------------- responsive ---------------- */

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .stage { min-height: 760px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .inspect { flex-wrap: wrap; }
  .topbar-right .badge { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .brand-text h1 span { display: none; }
  .btn { padding: 0 9px; }
  .stage { min-height: 680px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .cam-frame { width: 220px; height: 165px; }
  .result-rows { grid-template-columns: 1fr 1fr; }
}
