: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-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;
}

.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-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;
}

.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%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}

.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;
}

.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-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-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: 74px;
  height: 74px;
  border: 2px dashed #b91c1c;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #b91c1c;
  font-size: 12px;
  transform: rotate(-8deg);
}

.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;
}

.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;
  }
}

@media print {
  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,
  .toast {
    display: none !important;
  }

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