:root {
  color-scheme: dark;
  --bg: #060713;
  --panel: #10111c;
  --panel-soft: #171827;
  --panel-deep: #0b0c16;
  --text: #f5f7ff;
  --muted: #a7adbe;
  --line: rgba(255, 255, 255, 0.11);
  --strong: #22d3ee;
  --strong-dark: #06b6d4;
  --violet: #8b5cf6;
  --accent: #fb7185;
  --ok: #34d399;
  --cut: #f59e0b;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 66% 18%, rgba(91, 33, 182, 0.22), transparent 32%),
    radial-gradient(circle at 20% 8%, rgba(34, 211, 238, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter,
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 305px) minmax(0, 1fr);
  gap: 14px;
  max-width: 1720px;
  margin: 0 auto;
}

.panel,
.controls-panel,
.preview-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.controls-panel {
  padding: 14px;
  height: fit-content;
  position: sticky;
  top: 14px;
  background: linear-gradient(180deg, #11131f 0%, #0b0c15 100%);
}

.brand-row,
.section-head,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

p,
small,
label span,
.metric span,
td,
th,
li {
  font-size: 12px;
}

button,
input,
select {
  font-size: 13px;
}

p,
small,
label span,
.metric span {
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.status-pill.ok {
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--ok);
  background: rgba(52, 211, 153, 0.1);
}

.status-pill.error {
  border-color: rgba(214, 69, 69, 0.28);
  color: var(--accent);
  background: rgba(214, 69, 69, 0.08);
}

.form-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 5px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 7px 9px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--strong);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}

.file-drop {
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px dashed rgba(34, 211, 238, 0.34);
  background: rgba(34, 211, 238, 0.06);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--strong), var(--violet));
  color: #fff;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.primary-button,
.secondary-button,
.report-link {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--muted);
  white-space: nowrap;
}

.preview-toggle input {
  width: 16px;
  height: 16px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover,
.secondary-button:hover,
.report-link:hover {
  border-color: rgba(34, 211, 238, 0.45);
}

.compact-button {
  min-height: 32px;
  padding-inline: 10px;
}

.zoom-label {
  min-width: 46px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.measure-label {
  min-width: 72px;
  color: #e0faff;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.primary-button {
  flex: 1;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  color: #fff;
}

.primary-button:hover {
  filter: brightness(1.08);
}

.secondary-button,
.report-link {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  color: var(--text);
}

.secondary-button.active {
  border-color: rgba(34, 211, 238, 0.65);
  background: rgba(34, 211, 238, 0.14);
  color: #e0faff;
}

.report-link.disabled {
  pointer-events: none;
  color: var(--muted);
  background: var(--panel-soft);
}

.main-panel {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 8px;
}

.summary-note {
  margin: -2px 0 0;
  padding: 7px 10px;
  border: 1px solid rgba(34, 211, 238, 0.24);
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.07);
  color: #c7d2fe;
  font-size: 12px;
  line-height: 1.4;
}

.side-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.side-summary-grid .metric {
  padding: 8px 9px;
  box-shadow: none;
}

.side-summary-grid .metric strong {
  font-size: 22px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1;
  color: #ffffff;
}

.reliability-metric strong {
  font-size: 18px;
}

.reliability-metric small {
  display: block;
  margin-top: 5px;
  line-height: 1.45;
}

.reliability-metric.ok {
  border-color: rgba(52, 211, 153, 0.32);
}

.reliability-metric.review {
  border-color: rgba(245, 158, 11, 0.35);
}

.reliability-metric.needs_calibration {
  border-color: rgba(251, 113, 133, 0.35);
}

.side-status {
  margin-top: 12px;
  padding: 10px;
  box-shadow: none;
}

.side-status strong {
  font-size: 17px;
}

.side-status small {
  font-size: 12px;
}

.preview-wrap {
  padding: 12px;
  background: #0d0e19;
}

.section-head {
  margin-bottom: 8px;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080a14;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

canvas.dragging {
  cursor: grabbing;
}

canvas.measuring {
  cursor: crosshair;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.6fr);
  gap: 20px;
}

.review-details {
  padding: 0;
  overflow: hidden;
}

.review-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  list-style: none;
}

.review-details summary::-webkit-details-marker {
  display: none;
}

.review-details summary span {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.review-details summary small {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.review-details summary::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--strong);
  font-size: 20px;
  line-height: 1;
}

.review-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.review-details[open] summary::after {
  content: "-";
}

.review-details .details-grid {
  padding: 14px;
}

.ignored-panel {
  grid-column: 1 / -1;
}

.spec-panel .table-scroll {
  max-height: 220px;
}

.prominent-spec {
  padding: 12px;
  border-color: rgba(34, 211, 238, 0.26);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.08), rgba(16, 17, 28, 0.96));
}

.prominent-spec .section-head {
  margin-bottom: 8px;
}

.prominent-spec h2 {
  font-size: 17px;
}

.prominent-spec p {
  margin-top: 3px;
  font-size: 12px;
}

.prominent-spec .table-scroll {
  max-height: none;
  margin-top: 0;
  border-radius: 8px;
}

.prominent-spec table {
  min-width: 760px;
}

.prominent-spec th {
  padding: 8px 10px;
  font-size: 12px;
}

.prominent-spec td {
  padding: 9px 10px;
  font-size: 14px;
  vertical-align: middle;
}

.prominent-spec td:first-child {
  color: var(--strong-dark);
  font-size: 17px;
  font-weight: 800;
}

.prominent-spec td:nth-child(n + 2) {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.prominent-spec td:nth-child(5),
.prominent-spec td:nth-child(6) {
  color: var(--accent);
}

.compact-table table {
  min-width: 520px;
}

.details-grid .panel {
  padding: 12px;
  min-width: 0;
}

.message-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.message-list li + li {
  margin-top: 8px;
}

.table-scroll {
  margin-top: 12px;
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #171827;
  color: var(--muted);
  font-weight: 600;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td,
.selected-row td {
  background: rgba(34, 211, 238, 0.09);
}

.ignored-row td {
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
}

.tag.whole {
  color: var(--ok);
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.25);
}

.tag.cut {
  color: var(--cut);
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.24);
}

@media (max-width: 960px) {
  .app-shell {
    padding: 12px;
  }

  .workspace,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .section-head,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .report-link {
    width: 100%;
  }
}
