:root {
  --green: #16794f;
  --green-d: #0f5e3c;
  --green-l: #e8f4ee;
  --ink: #17241e;
  --muted: #6a7a72;
  --line: #dfe7e2;
  --bg: #f5f8f6;
  --card: #ffffff;
  --danger: #c0392b;
  --shadow: 0 6px 24px rgba(22, 121, 79, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: var(--green); }

/* ---------- 管理后台骨架 ---------- */
.app-header {
  background: linear-gradient(135deg, var(--green-d), var(--green));
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.app-header h1 { font-size: 19px; margin: 0; letter-spacing: 1px; }
.app-header .sub { opacity: .8; font-size: 12px; margin-left: 10px; }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.chip { background: rgba(255,255,255,.16); padding: 5px 12px; border-radius: 20px; }

.layout { max-width: 1240px; margin: 20px auto; padding: 0 18px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 10px 18px; cursor: pointer; color: var(--muted); font-size: 14px;
}
.tab.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }
.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h2 { font-size: 16px; margin: 0 0 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.field .req { color: var(--danger); }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  background: #fff; color: var(--ink); outline: none; min-height: 38px;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,121,79,.1); }
textarea { resize: vertical; min-height: 64px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.full { grid-column: 1 / -1; }

.btn {
  border: 1px solid var(--green); background: var(--green); color: #fff;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; min-height: 38px;
}
.btn:hover { background: var(--green-d); }
.btn.ghost { background: #fff; color: var(--green); }
.btn.ghost:hover { background: var(--green-l); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 12px; }
.btn.danger { background: #fff; color: var(--danger); border-color: #e6b5af; }
.btn.danger:hover { background: #fdf0ee; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar .left, .toolbar .right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #fafcfb; }
tr:hover td { background: #fbfdfc; }
.code-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--green-d); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; background: var(--green-l); color: var(--green-d); }
.badge.off { background: #f1f1f1; color: #888; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.hint { font-size: 12px; color: var(--muted); }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.notice.ok { background: var(--green-l); color: var(--green-d); }
.notice.err { background: #fdf0ee; color: var(--danger); }
.notice.warn { background: #fff8e6; color: #8a6100; }
.hidden { display: none !important; }

/* 登录 */
.login-box { max-width: 420px; margin: 48px auto; }
.login-box .card { padding: 28px; }
.login-box h2 { margin-top: 0; }

/* 报告缩略图 */
.report-list { display: flex; gap: 10px; flex-wrap: wrap; }
.report-item { position: relative; width: 96px; }
.report-item img, .report-item .ph {
  width: 96px; height: 72px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: #f4f7f5; display: block;
}
.report-item .ph { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); }
.report-item .rm {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; cursor: pointer; padding: 0;
}
.report-item .nm { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }

/* 弹层 */
.mask { position: fixed; inset: 0; background: rgba(10,30,20,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .close { float: right; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.qr-wrap { text-align: center; padding: 10px 0; }
.qr-wrap img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-wrap .code { font-family: ui-monospace, monospace; font-size: 17px; font-weight: 700; color: var(--green-d); margin-top: 10px; word-break: break-all; }
.copy-box { display: flex; gap: 8px; margin-top: 14px; }
.copy-box input { flex: 1; font-size: 12px; }

/* ---------- 扫码展示页 ---------- */
.trace-page { max-width: 680px; margin: 0 auto; padding: 0 16px 40px; }
.trace-hero {
  background: linear-gradient(135deg, var(--green-d), var(--green));
  color: #fff; border-radius: 0 0 22px 22px; padding: 28px 22px 30px;
  box-shadow: 0 8px 30px rgba(15,94,60,.2);
}
.trace-hero .brand { font-size: 12px; opacity: .85; letter-spacing: 2px; }
.trace-hero h1 { margin: 10px 0 6px; font-size: 24px; }
.trace-hero .hero-product { font-size: .7em; font-weight: 500; margin-left: 10px; opacity: .95; letter-spacing: 1px; }
.trace-hero .code-line { font-family: ui-monospace, monospace; font-size: 12px; opacity: .9; word-break: break-all; }
.verify { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.16); border-radius: 20px; padding: 4px 12px; font-size: 12px; margin-top: 14px; }
.verify .dot { width: 8px; height: 8px; border-radius: 50%; background: #7ff0b4; }
.trace-body { margin-top: -14px; }
.trace-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.trace-card h2 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.trace-card h2 .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--green); }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.kv .k { font-size: 11px; color: var(--muted); }
.kv .v { font-size: 14px; font-weight: 600; margin-top: 2px; word-break: break-all; }
.kv .v.na { color: #9aa8a0; font-weight: 400; }
.kv-note { grid-column: 1 / -1; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--line); }
.kv-note .k { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.note-body .note-para { font-size: 13px; line-height: 1.75; color: #33413a; padding: 8px 12px; margin-bottom: 8px; background: var(--green-l); border-radius: 8px; border-left: 3px solid var(--green); word-break: break-all; }
.note-body .note-para:last-child { margin-bottom: 0; }
.trace-report { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.trace-report a { display: block; width: 100%; max-width: 220px; }
.trace-report img { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; }
.trace-report .cap { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: center; word-break: break-all; }
.pdf-link { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; text-decoration: none; }
.pdf-link:hover { border-color: var(--green); background: var(--green-l); }
.trace-foot { text-align: center; color: var(--muted); font-size: 11px; padding: 10px 0 0; line-height: 1.8; }
.status-card { text-align: center; padding: 46px 20px; }
.status-card .icon { font-size: 40px; }
.status-card h2 { font-size: 18px; }
.search-code { display: flex; gap: 8px; margin-top: 16px; }
.search-code input { flex: 1; }
.contact-card { text-align: center; }
.contact-card .hint { margin-bottom: 14px; }
.contact-btn { display: block; width: 100%; max-width: 320px; margin: 0 auto; text-align: center; text-decoration: none; font-size: 16px; font-weight: 600; min-height: 46px; border-radius: 10px; }

@media (max-width: 520px) {
  .kv { grid-template-columns: 1fr 1fr; gap: 12px; }
  .trace-hero h1 { font-size: 20px; }
  .app-header { padding: 12px 16px; }
  .layout { padding: 0 12px; }
  .card { padding: 16px; }
  th, td { padding: 8px 6px; font-size: 12px; }
}
@media print {
  body { background: #fff; }
  .app-header, .tabs, .toolbar, .pager, .no-print, .card:not(.print-area) { display: none !important; }
  .layout { margin: 0; padding: 0; max-width: none; }
  #qrPanel.card { display: block !important; border: none; box-shadow: none; }
  .print-labels { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .label { border: 1px dashed #999; padding: 10px; text-align: center; page-break-inside: avoid; }
  .label img { width: 120px; height: 120px; }
  .label .lc { font-family: monospace; font-size: 13px; font-weight: 700; }
  .label .ln { font-size: 12px; }
}
