:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --soft: #eef3f7;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d6dde5;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --warning: #b45309;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary-dark); text-decoration: none; }
code { background: #eef2f7; padding: 0.15rem 0.35rem; border-radius: 4px; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: #0b1220;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-title { font-weight: 700; font-size: 18px; }
.brand-sub { color: #c7d2fe; font-size: 12px; margin-top: 4px; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { color: #fff; opacity: .92; }
.page { max-width: 1320px; margin: 0 auto; padding: 18px; }
.panel, .panel-soft, .panel.narrow {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
}
.panel { margin-bottom: 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.lead { color: var(--muted); margin: 6px 0 0; }
.narrow { max-width: 680px; margin: 20px auto; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
}
textarea { resize: vertical; }
.readonly-line {
  grid-column: span 2;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.block {
  grid-column: span 2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fbfdff;
}
.block h2, .panel-soft h2 { margin: 0 0 10px; font-size: 17px; }
.muted-inline {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 500;
}
.declaration-block {
  padding: 14px;
  min-height: 360px;
}
.declaration-block .declarations { gap: 8px; }
.declaration-block .decl-item { padding: 7px 10px; font-size: 13px; }
.declaration-block .decl-item span { line-height: 1.3; }
.risk-preview {
  margin-top: 12px;
  padding: 12px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.risk-preview-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}
.risk-preview-sections {
  display: grid;
  gap: 8px;
}
.risk-preview-section {
  padding: 9px 10px;
  border: 1px solid #d7dde7;
  border-radius: 7px;
  background: #ffffff;
}
.risk-preview-section-title {
  margin: 0 0 4px;
  font-size: 12.8px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}
.risk-preview-section p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.photo-block {
  padding: 10px 12px;
  min-height: 116px;
}
.photo-block input[type="file"] { padding: 8px 10px; font-size: 14px; }
.photo-block .mini-note { padding: 8px 10px; font-size: 12px; }
.signature-block { padding: 14px; }
.agreement-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.check-password-toggle { align-items: flex-start; }
.check-password-toggle input { width: auto; margin-top: 3px; }
.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}
.checks.inline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check-inline { display: block; margin: 0; }
.decl-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.35;
}
.decl-item input { width: auto; margin-top: 3px; }
.declarations { display: grid; gap: 10px; }
.service-list {
  display: grid;
  gap: 12px;
}
.service-item {
  display: grid;
  grid-template-columns: 34px 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #fff;
}
.service-item input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--primary);
}
.service-item:has(input:checked) {
  border-color: #99f6e4;
  background: #f0fdfa;
}
.service-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
}
.service-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.service-icon-blue { color: #0f7bd6; background: #e0f2fe; }
.service-icon-green { color: #10b981; background: #dcfce7; }
.service-icon-orange { color: #ea580c; background: #ffedd5; }
.service-icon-purple { color: #6d28d9; background: #ede9fe; }
.service-icon-teal { color: #0f766e; background: #ccfbf1; }
.service-icon-red { color: #dc2626; background: #fee2e2; }
.service-icon-gray { color: #6b7280; background: #f3f4f6; }
.service-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.service-copy strong {
  font-size: 15px;
  line-height: 1.3;
}
.service-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.accessory-notice {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
}
.accessory-block {
  background: #ffffff;
}
.inline-detail {
  margin: 0 12px 2px 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.appearance-list .service-item {
  grid-template-columns: 34px 52px minmax(0, 1fr);
}
.accessory-notice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.radio-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.radio-card input { width: auto; margin-top: 4px; }
.warning {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}
.hidden { display: none; }
.signature-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  min-height: 180px;
}
.signature-wrap canvas {
  display: block;
  width: 100%;
  height: 180px;
  touch-action: none;
}
.scan-field { gap: 8px; }
.serial-compact input {
  max-width: 460px;
}
.block .checks + .checks {
  margin-top: 10px;
}
.scan-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}
.scan-row input {
  flex: 1 1 220px;
  min-width: 0;
}
.scan-trigger {
  min-height: 44px;
  flex: 0 0 auto;
}
.serial-status {
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.serial-status.error {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}
.scan-trigger[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}
.signature-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
  text-decoration: none;
}
.primary { background: var(--primary); color: #fff; }
.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.danger { background: var(--danger); color: #fff; }
.filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.filters input, .filters select { min-width: 0; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { color: var(--muted); margin-top: 6px; }
.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.list-tight { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list-tight li { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid #eef2f7; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th { background: #f8fafc; position: sticky; top: 0; }
.muted { color: var(--muted); font-size: 12px; margin-top: 4px; }
.fault-description {
  min-width: 180px;
  max-width: 320px;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
}
.row-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 220px;
  align-items: center;
}
.row-actions a {
  white-space: nowrap;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 14px;
  margin: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.wrap { word-break: break-word; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.photo-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.photo-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.photo-open:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.photo-grid figcaption {
  font-size: 12px;
  color: var(--muted);
  padding: 8px;
}
.upload-box, .inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.upload-compact {
  display: grid;
  gap: 10px;
}
.mini-note {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.inline-note {
  padding: 7px 10px;
  margin: 0;
}
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 18px;
  background: rgba(15, 23, 42, 0.88);
}
.photo-lightbox.is-open {
  display: grid;
}
.photo-lightbox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.photo-lightbox-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.photo-lightbox-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.photo-lightbox-image {
  align-self: center;
  justify-self: center;
  max-width: 100%;
  max-height: calc(100vh - 92px);
  object-fit: contain;
  background: #fff;
}
.lightbox-open {
  overflow: hidden;
}
.signature-image { max-width: 280px; border: 1px solid var(--line); background: #fff; padding: 6px; border-radius: 10px; }
.privacy-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}
.signature-note,
.block-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 12.5px;
}
.signature-note {
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.block-note {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}
.declaration-summary {
  margin: 0;
  padding-left: 20px;
  line-height: 1.6;
  color: var(--text);
}
.declaration-summary li + li {
  margin-top: 8px;
}
.workflow-form {
  display: grid;
  gap: 12px;
}
.workflow-form input {
  width: 100%;
}
.workflow-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.workflow-buttons .primary,
.workflow-buttons .secondary {
  min-height: 44px;
}
.notice, .hint {
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.flash-stack { display: grid; gap: 10px; margin-bottom: 14px; }
.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.flash.success { border-color: #86efac; background: #f0fdf4; color: #166534; }
.flash.error { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.log-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.log-list li { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; display: grid; gap: 4px; }
.qr { width: 120px; height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 4px; border-radius: 8px; }

@media (max-width: 960px) {
  .page {
    max-width: 480px;
    padding: 12px;
  }
  .mobile-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .form-grid, .form-grid.wide, .detail-grid, .grid-two, .stats, .filters, .photo-grid, .checks, .checks.inline {
    grid-template-columns: 1fr;
  }
  .span-2, .readonly-line { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .agreement-row { grid-template-columns: 1fr; }
  .panel, .panel-soft, .panel.narrow, .block {
    width: 100%;
  }
  .block {
    padding: 12px;
  }
  .service-item {
    grid-template-columns: 30px 48px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 8px;
  }
  .inline-detail {
    margin: 0;
  }
  .signature-wrap {
    width: 100%;
    min-height: 220px;
    border-radius: 12px;
  }
  .signature-wrap canvas { height: 220px; }
  .scan-row {
    flex-direction: column;
  }
  .scan-trigger {
    width: 100%;
  }
  .serial-compact input {
    max-width: none;
  }
  .serial-status {
    font-size: 12px;
  }
  .declaration-block { min-height: 0; }
  .declaration-block .decl-item { font-size: 12px; }
  .photo-block { min-height: 0; }
  .photo-block .mini-note { font-size: 12px; }
  .signature-actions {
    margin-top: 12px;
  }
  .signature-actions .secondary {
    width: 100%;
    min-height: 44px;
  }
  .actions .primary {
    width: 100%;
    min-height: 44px;
  }
  .workflow-buttons {
    flex-direction: column;
  }
  .workflow-buttons .primary,
  .workflow-buttons .secondary {
    width: 100%;
  }
  .row-actions {
    min-width: 0;
  }
}
