:root {
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #dc2626;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --shadow: 0 16px 45px rgba(17, 24, 39, 0.14);
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.12), transparent 220px),
    radial-gradient(circle at 12% 18%, rgba(16, 185, 129, 0.16), transparent 260px),
    #eef2f7;
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.phone-frame {
  width: min(430px, calc(100vw - 44px));
  height: min(860px, calc(100vh - 44px));
  min-height: 690px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 24px 46px 1fr 64px;
  border: 2px solid #1f2937;
  border-radius: 16px;
  background: #f8fafc;
  box-shadow: var(--shadow);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: #1f2937;
  font-size: 12px;
  line-height: 1;
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: var(--blue);
  color: #fff;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  display: grid;
  place-items: center;
  color: inherit;
  background: transparent;
  font-size: 28px;
  line-height: 1;
}

.icon-btn:focus-visible,
.tab-btn:focus-visible,
.btn:focus-visible,
.chip:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.screen {
  overflow: auto;
  padding: 12px 14px 18px;
  scroll-behavior: smooth;
}

.screen.with-actions {
  padding-bottom: 96px;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  border-top: 1px solid var(--line);
  background: #fff;
}

.tab-btn {
  border: 0;
  background: transparent;
  color: #6b7280;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  font-size: 12px;
}

.tab-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.tab-btn.is-active {
  color: var(--blue);
  font-weight: 700;
}

.hero-panel,
.section,
.sample-card,
.report-head,
.stats-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hero-panel {
  padding: 14px;
  margin-bottom: 12px;
  border-color: #bfdbfe;
  background:
    linear-gradient(135deg, #eff6ff 0%, #fff 62%),
    #fff;
}

.hero-title {
  margin: 0 0 8px;
  color: var(--blue-deep);
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.quick-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  min-height: 82px;
}

.quick-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
}

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

.stat-box {
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 10px 6px;
  text-align: center;
  min-width: 0;
}

.stat-button {
  width: 100%;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.stat-button:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.stat-button:focus-visible,
.sample-detail-trigger:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: 0;
}

.stat-value {
  display: block;
  color: var(--blue);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.section {
  padding: 12px;
  margin-bottom: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
}

.section-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.form-grid .field.full {
  grid-column: 1 / -1;
}

.export-template-grid {
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label,
.field-label {
  color: #374151;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea,
.search-field {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: 0;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  width: 100%;
}

.inline-field .btn {
  min-width: 58px;
  padding: 0 10px;
}

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

.check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: #374151;
}

.check-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.check-item.is-disabled {
  color: #9ca3af;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.btn {
  border: 0;
  border-radius: 7px;
  min-height: 42px;
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  color: #374151;
  background: #eef2f7;
}

.btn.success {
  background: var(--green);
}

.btn.warn {
  background: var(--orange);
}

.btn.ghost {
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.btn.full {
  width: 100%;
  min-height: 54px;
  margin-top: 8px;
  font-size: 16px;
}

.btn.full-lite {
  width: 100%;
  margin-top: 10px;
}

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.compact-actions {
  margin: 0 0 10px;
}

.search-row {
  display: grid;
  grid-template-columns: 42px 1fr 72px;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 10px;
}

.search-row .icon-btn {
  width: 38px;
  height: 38px;
  color: var(--ink);
  font-size: 18px;
  border-radius: 6px;
  background: #f8fafc;
}

.search-field {
  min-height: 38px;
  border: 0;
  background: #f8fafc;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #4b5563;
  background: #fff;
  font-size: 12px;
}

.chip.is-active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.sample-list {
  display: grid;
  gap: 10px;
}

.sample-card {
  padding: 12px;
}

.sample-detail-trigger {
  border: 1px solid transparent;
  border-radius: 6px;
  margin: -4px -4px 2px;
  padding: 4px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.sample-detail-trigger:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.sample-card.is-muted {
  opacity: 0.68;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sample-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.sample-meta {
  margin: 0;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.7;
}

.tag {
  flex: 0 0 auto;
  border-radius: 6px;
  color: #fff;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.tag.pending,
.tag.archived {
  color: #374151;
  background: #e5e7eb;
}

.tag.testing {
  background: var(--orange);
}

.tag.completed {
  background: var(--green);
}

.card-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  display: block;
  margin-left: auto;
  padding: 6px 0 0;
  font-weight: 800;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.sample-detail {
  display: grid;
  gap: 10px;
}

.sample-detail .section {
  margin-bottom: 0;
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-code {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-info-box {
  margin: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.detail-note {
  margin-top: 12px;
  border-left: 3px solid #94a3b8;
  background: #f8fafc;
  padding: 9px 10px;
}

.detail-note strong {
  font-size: 12px;
}

.detail-note p {
  margin: 4px 0 0;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.test-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.test-summary-list span {
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.detail-result-table {
  min-width: 0;
}

.image-count-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.image-count-grid div {
  min-width: 0;
  border-left: 3px solid #93c5fd;
  background: #f8fafc;
  padding: 8px;
}

.image-count-grid span,
.image-count-grid strong {
  display: block;
}

.image-count-grid span {
  color: var(--muted);
  font-size: 11px;
}

.image-count-grid strong {
  margin-top: 4px;
  font-size: 13px;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.compression-link {
  color: var(--orange);
}

.compression-notice {
  border-color: #93c5fd;
  background: #eff6ff;
}

.compression-notice p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.6;
}

.sample-summary {
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: #eff6ff;
  padding: 10px;
  margin-bottom: 10px;
}

.sample-summary strong {
  color: var(--blue-deep);
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  margin-bottom: 10px;
}

.result-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.unit-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.unit-field span {
  color: var(--muted);
  min-width: 44px;
}

.wear-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.wear-table th,
.wear-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 4px;
  text-align: center;
}

.wear-table th {
  color: #4b5563;
  font-weight: 700;
}

.wear-table input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 4px;
  text-align: center;
}

.wear-table input[readonly] {
  color: var(--blue-deep);
  background: #eff6ff;
  font-weight: 800;
}

.wear-table .row-btn {
  width: auto;
  min-width: 60px;
  padding: 0 8px;
}

.formula-note,
.source-notice {
  margin: 0 0 10px;
  border-left: 3px solid #2563eb;
  background: #eff6ff;
  color: #334155;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.55;
}

.source-notice {
  border-left-color: #d97706;
  background: #fffbeb;
}

.manual-judgement {
  margin-top: 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 10px;
}

.manual-judgement label {
  display: block;
  margin-bottom: 7px;
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

.manual-judgement select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 700;
}

.manual-judgement select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: 0;
}

.data-import-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.data-import-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.import-target-grid {
  margin-bottom: 10px;
}

.data-import-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.judgement-chip {
  min-width: 62px;
  padding: 4px 8px;
  border-radius: 5px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.judgement-chip.passed {
  color: #047857;
  background: #d1fae5;
}

.judgement-chip.failed {
  color: #b91c1c;
  background: #fee2e2;
}

.judgement-chip.pending,
.pending-text {
  color: #92400e;
  background: #fef3c7;
}

.fail {
  color: #b91c1c;
  font-weight: 800;
}

.danger-link {
  color: #b91c1c;
}

.row-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  color: #b91c1c;
  background: #fee2e2;
  font-size: 12px;
  font-weight: 700;
}

.info-row .row-btn {
  width: auto;
  min-width: 42px;
  padding: 0 8px;
  margin-left: 4px;
}

.upload-box {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 84px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #fbfdff;
  color: var(--muted);
  text-align: center;
  padding: 12px;
}

.compact-upload {
  margin-top: 10px;
  min-height: 72px;
  border-color: #93c5fd;
  background: #eff6ff;
  align-items: center;
}

.report-thumb-grid {
  margin-top: 0;
}

.compact-empty {
  padding: 14px 10px;
}

.upload-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.three-cols {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.thumb-item {
  position: relative;
  min-width: 0;
  margin: 0;
}

.thumb-item button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(185, 28, 28, 0.88);
  font-size: 18px;
  line-height: 1;
}

.thumb-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.report-head {
  padding: 14px;
  margin-bottom: 10px;
  text-align: center;
  background: #eaf2ff;
}

.report-document {
  position: relative;
  isolation: isolate;
}

.report-document > :not(.report-watermark) {
  position: relative;
  z-index: 1;
}

.report-watermark {
  position: absolute;
  z-index: 0;
  top: 46%;
  left: 50%;
  width: 90%;
  color: rgba(30, 64, 175, 0.055);
  font-size: 31px;
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, -50%) rotate(-28deg);
  pointer-events: none;
}

.report-signoff {
  margin: 12px 0 4px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #475569;
  font-size: 12px;
}

.report-head h2 {
  margin: 0 0 8px;
  color: var(--blue-deep);
  font-size: 22px;
  letter-spacing: 0;
}

.report-head p {
  margin: 0;
  color: #6b7280;
}

.info-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  margin-bottom: 10px;
}

.info-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  line-height: 1.45;
}

.info-row span:first-child {
  color: var(--muted);
}

.info-row.user-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.info-row.user-row span {
  overflow-wrap: anywhere;
}

.info-row.user-row strong {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 6px;
  font-size: 13px;
}

.result-table th {
  color: #fff;
  background: var(--blue);
  padding: 9px 8px;
  text-align: left;
}

.result-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
}

.pass {
  color: var(--green);
  font-weight: 800;
}

.note-box {
  border: 1px solid #f2c76b;
  border-radius: var(--radius);
  background: #fff7df;
  color: #6b4b00;
  line-height: 1.7;
  padding: 12px;
  margin-bottom: 10px;
}

.stamp-row {
  min-height: 92px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 26px;
}

.stamp {
  width: 88px;
  height: 88px;
  border: 2px dashed #b91c1c;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #b91c1c;
  font-size: 12px;
  transform: rotate(-8deg);
  text-align: center;
  padding: 8px;
}

.stamp span,
.stamp strong {
  display: block;
  line-height: 1.15;
}

.stamp span {
  font-size: 8px;
}

.stamp strong {
  font-size: 12px;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.profile-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.profile-name {
  margin: 0 0 6px;
  font-size: 18px;
}

.profile-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-card {
  margin-top: 18px;
}

body.modal-open {
  overflow: hidden;
}

.modal-layer[hidden] {
  display: none;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
}

.sample-preview-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(430px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.sample-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 12px;
}

.preview-heading-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.preview-heading-main > div {
  min-width: 0;
}

.preview-back {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--blue);
  font-size: 28px;
  line-height: 1;
}

.preview-back:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
  outline: 0;
}

.sample-preview-head span {
  color: var(--muted);
  font-size: 12px;
}

.sample-preview-head h2 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.preview-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-size: 24px;
  line-height: 1;
}

.preview-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
  outline: 0;
}

.sample-preview-content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}

.preview-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.preview-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.preview-info-grid div {
  min-width: 0;
}

.preview-info-grid span,
.preview-info-grid strong {
  display: block;
}

.preview-info-grid span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.preview-info-grid strong {
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.preview-results {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.preview-results h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.preview-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-result-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 4px;
}

.preview-result-table td:nth-child(2),
.preview-result-table td:last-child {
  text-align: right;
}

.preview-empty {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
  padding: 10px;
  font-size: 12px;
}

.sample-preview-footer {
  border-top: 1px solid var(--line);
  background: #f8fafc;
  padding: 12px 14px;
}

.sample-preview-footer .btn {
  width: 100%;
  margin: 0;
}

.stats-table-dialog {
  width: min(760px, 100%);
}

.stats-table-content {
  padding: 0;
}

.stats-record-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: #1f2937;
  font-size: 12px;
}

.stats-record-table col:nth-child(1) {
  width: 31%;
}

.stats-record-table col:nth-child(2) {
  width: 36%;
}

.stats-record-table col:nth-child(3) {
  width: 19%;
}

.stats-record-table col:nth-child(4) {
  width: 14%;
}

.stats-record-table th,
.stats-record-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.stats-record-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.stats-record-table tbody tr {
  cursor: pointer;
}

.stats-record-table tbody tr:hover,
.stats-record-table tbody tr:focus-visible {
  background: #eff6ff;
  outline: 0;
}

.stats-record-table td span:not(.table-status):not(.stats-view-link) {
  color: var(--muted);
  font-size: 11px;
}

.table-status {
  display: inline-block;
  border-radius: 5px;
  padding: 4px 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.table-status.pending,
.table-status.archived {
  background: #e5e7eb;
  color: #374151;
}

.table-status.testing {
  background: var(--orange);
}

.table-status.completed {
  background: var(--green);
}

.stats-view-link {
  color: var(--blue);
  font-weight: 800;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  box-shadow: 0 10px 25px rgba(17, 24, 39, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden-file {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 520px) {
  body {
    background: #f8fafc;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .phone-frame {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .inline-field {
    grid-template-columns: 1fr;
  }

  .inline-field .btn {
    width: 100%;
  }

  .section-title small {
    width: 100%;
    text-align: left;
  }

  .wear-table {
    display: block;
    min-width: 0;
  }

  .wear-table thead {
    display: none;
  }

  .wear-table tbody {
    display: grid;
    gap: 10px;
  }

  .wear-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
  }

  .wear-table td {
    display: grid;
    gap: 5px;
    border: 0;
    padding: 0;
    text-align: left;
  }

  .wear-table td::before {
    content: attr(data-label);
    color: #4b5563;
    font-size: 11px;
    font-weight: 700;
  }

  .wear-table td:first-child,
  .wear-table td:last-child {
    grid-column: 1 / -1;
  }

  .wear-table td:last-child .row-btn {
    width: 100%;
    height: 34px;
  }

  .table-scroll {
    overflow-x: visible;
  }

  .stats-record-table {
    font-size: 11px;
  }

  .stats-record-table col:nth-child(1) {
    width: 34%;
  }

  .stats-record-table col:nth-child(2) {
    width: 32%;
  }

  .stats-record-table col:nth-child(3) {
    width: 20%;
  }

  .stats-record-table th,
  .stats-record-table td {
    padding: 10px 6px;
  }

  .stats-record-table th,
  .table-status,
  .stats-view-link {
    font-size: 10px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 9mm;
  }

  body {
    background: #fff;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .phone-frame {
    width: 100%;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
  }

  .status-bar,
  .topbar,
  .tabbar,
  .actions-row,
  .report-control,
  .compression-notice,
  .toast {
    display: none !important;
  }

  .screen {
    overflow: visible;
    padding: 0;
  }

  .report-document {
    width: 100%;
    color: #111827;
    font-size: 10pt;
  }

  .report-head {
    padding: 8px;
    margin-bottom: 6px;
  }

  .report-head h2 {
    margin-bottom: 3px;
    font-size: 18pt;
  }

  .info-box,
  .report-document .section,
  .note-box {
    margin-bottom: 6px;
    padding: 7px;
    break-inside: avoid;
  }

  .info-box {
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
  }

  .info-row {
    grid-template-columns: 68px 1fr;
    font-size: 9pt;
  }

  .result-table {
    font-size: 9pt;
  }

  .result-table th,
  .result-table td {
    padding: 5px 6px;
  }

  .report-signoff {
    margin-top: 8px;
  }

  .stamp-row {
    min-height: 70px;
    padding-right: 18px;
  }

  .stamp {
    width: 66px;
    height: 66px;
  }

  .report-template-customer .stamp-row {
    min-height: 58px;
  }
}
