:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #17362d;
  background: #f3f7f4;
  --theme: #126a53;
  --theme-dark: #0a4537;
  --paper: #ffffff;
  --line: #dce8e2;
  --muted: #6d817a;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f3f7f4; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.admin-page { background: #f5f7fb; }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 20px 22px; background: #fff; border-right: 1px solid #dfe8e4; box-shadow: 8px 0 30px rgba(20, 67, 52, .035); z-index: 5; }
.admin-brand { display: block; padding: 4px 5px 24px; border-bottom: 1px solid #edf2ef; }
.admin-brand img { display: block; width: 190px; max-width: 100%; height: auto; }
.side-caption { margin: 24px 10px 10px; color: #91a19b; font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.side-nav { display: grid; gap: 8px; margin: 0; padding: 0; overflow: visible; }
.side-nav .tab { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; border: 0; border-radius: 12px; padding: 12px 13px; background: transparent; color: #48645b; text-align: left; }
.side-nav .tab:hover { background: #f0f6f3; color: var(--theme); }
.side-nav .tab.active { background: linear-gradient(135deg, var(--theme), #17876b); color: #fff; box-shadow: 0 10px 24px rgba(18, 106, 83, .2); }
.nav-index { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; opacity: .65; }
.side-nav .tab strong { min-width: 24px; padding: 3px 7px; border-radius: 999px; background: rgba(18, 106, 83, .09); font-size: 11px; text-align: center; }
.side-nav .tab.active strong { background: rgba(255, 255, 255, .18); }
.sidebar-account { margin-top: auto; display: flex; align-items: center; gap: 10px; border-top: 1px solid #edf2ef; padding: 20px 8px 0; }
.account-avatar { flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: #e3f1eb; color: var(--theme); font-weight: 900; }
.account-copy { min-width: 0; }
.sidebar-account strong, .sidebar-account small { display: block; }
.sidebar-account small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.account-action { margin: 6px 0 0; border: 0; padding: 0; background: transparent; color: var(--theme); font-size: 12px; font-weight: 800; }
.account-action:hover { text-decoration: underline; }
.admin-main { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; padding: 30px clamp(20px, 3vw, 46px) 18px; }
.topbar, .admin-content, .admin-footer { width: min(1320px, 100%); margin-left: auto; margin-right: auto; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 24px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.eyebrow { margin: 0 0 6px; color: var(--theme); font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(25px, 4vw, 38px); letter-spacing: -.04em; }
.subtle { color: var(--muted); margin-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 8px 12px; background: #e2f2eb; color: var(--theme); font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #24a877; box-shadow: 0 0 0 4px #c8eadc; }

.tab { font: inherit; white-space: nowrap; }
.panel { display: none; }
.panel.active { display: block; }
.admin-content { flex: 1; }
.admin-footer { margin-top: 34px; padding: 20px 0 4px; border-top: 1px solid #dfe8e4; color: #72857e; font-size: 13px; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card { grid-column: span 12; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); padding: 20px; box-shadow: 0 12px 34px rgba(20, 67, 52, .06); }
.card.half { grid-column: span 6; }
.card h2 { margin-bottom: 6px; font-size: 20px; }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-head p { margin-bottom: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 700; color: #4e675f; }
input, textarea, select { width: 100%; border: 1px solid #ccdcd4; border-radius: 10px; padding: 11px 12px; background: #fbfdfc; color: #16382d; outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--theme); box-shadow: 0 0 0 3px rgba(18, 106, 83, .11); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn { border: 1px solid var(--theme); border-radius: 10px; padding: 10px 15px; background: var(--theme); color: #fff; font-weight: 700; text-decoration: none; text-align: center; }
.btn.secondary { background: #fff; color: var(--theme); }
.btn.ghost { border-color: var(--line); background: #fff; color: #436057; }
.btn:disabled { opacity: .55; cursor: wait; }

[hidden] { display: none !important; }
.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 35, 28, .48); backdrop-filter: blur(4px); }
.modal-card { width: min(480px, 100%); border: 1px solid rgba(255,255,255,.7); border-radius: 20px; padding: 22px; background: #fff; box-shadow: 0 28px 80px rgba(5, 35, 27, .3); }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.modal-head h2 { margin-bottom: 0; }
.modal-close { flex: 0 0 34px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: #edf4f1; color: #45645a; font-size: 24px; line-height: 1; }
.modal-hint { margin: 12px 0 18px; font-size: 13px; line-height: 1.65; }
.password-form .field small { color: var(--muted); font-size: 11px; }

.list { display: grid; gap: 12px; }
.list-item { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: #fbfdfc; }
.list-item-row { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.list-item h3 { font-size: 16px; margin-bottom: 5px; }
.meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.record-details { margin-top: 12px; border-top: 1px solid #e4ece8; padding-top: 10px; }
.record-details summary { width: fit-content; cursor: pointer; color: var(--theme); font-size: 13px; font-weight: 800; list-style-position: inside; }
.record-details[open] summary { margin-bottom: 12px; }
.record-details dl { margin: 0; display: grid; gap: 0; border: 1px solid #e1ebe6; border-radius: 10px; overflow: hidden; }
.detail-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 9px 11px; background: #fff; border-bottom: 1px solid #edf2ef; }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--muted); font-size: 12px; }
.detail-row dd { margin: 0; color: #24493d; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
.code-sample { margin-top: 10px; padding: 9px 11px; border-radius: 9px; background: #edf5f1; color: #245848; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.qr-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.qr-section-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.qr-section-head span { color: var(--muted); font-size: 12px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.qr-item { display: grid; gap: 7px; justify-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; text-align: center; }
.qr-item strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.qr-item > a:last-child { color: var(--theme); font-size: 12px; font-weight: 700; }
.qr-image-link { display: block; width: 100%; border-radius: 8px; background: #fff; }
.qr-image-link img { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; }
.empty { border: 1px dashed #c7d9d0; border-radius: 12px; color: var(--muted); padding: 28px; text-align: center; }
.status { position: fixed; z-index: 40; left: 50%; bottom: 22px; transform: translate(-50%, 120px); padding: 11px 18px; border-radius: 999px; background: #173e32; color: #fff; box-shadow: 0 14px 38px rgba(0,0,0,.22); transition: transform .25s; }
.status.show { transform: translate(-50%, 0); }
.status.error { background: #a33b32; }

.trace-page { min-height: 100vh; background: linear-gradient(155deg, var(--theme-dark), var(--theme) 35%, #eff6f2 35.1%); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.trace-shell { width: min(560px, calc(100% - 28px)); margin: 0 auto; padding: 28px 0 46px; }
.trace-hero { color: #fff; padding: 15px 5px 34px; }
.trace-hero .seal { width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.4); border-radius: 18px; background: rgba(255,255,255,.12); font-weight: 900; font-size: 22px; backdrop-filter: blur(6px); }
.trace-hero h1 { margin: 19px 0 7px; font-size: 30px; }
.trace-hero p { margin: 0; opacity: .8; }
.trace-card { border-radius: 22px; padding: 22px; background: #fff; box-shadow: 0 20px 50px rgba(5, 49, 37, .17); margin-bottom: 14px; }
.verified { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.verified-icon { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: #dcf3e8; color: var(--theme); font-weight: 900; font-size: 21px; }
.verified strong { display: block; }
.verified span { color: var(--muted); font-size: 12px; }
.product-name { font-size: 25px; margin-bottom: 8px; }
.description { color: #5b746b; line-height: 1.75; }
.facts { display: grid; gap: 0; }
.fact { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf2ef; }
.fact:last-child { border-bottom: 0; }
.fact span { color: var(--muted); }
.fact strong { text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.identity { border-radius: 15px; padding: 14px; background: #f0f6f3; }
.identity-row { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 5px 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.identity-row span { color: var(--muted); font-family: inherit; }
.identity-row strong { overflow-wrap: anywhere; }
.notice { color: #667b74; font-size: 12px; line-height: 1.65; text-align: center; padding: 8px 20px; }
.loading, .trace-error { width: min(520px, calc(100% - 32px)); margin: 90px auto; border-radius: 18px; background: #fff; padding: 34px; text-align: center; box-shadow: 0 18px 45px rgba(0,0,0,.12); }
.spinner { width: 32px; height: 32px; border: 3px solid #d6e4de; border-top-color: var(--theme); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 15px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .admin-layout { display: block; }
  .admin-sidebar { position: static; height: auto; padding: 16px 18px; border-right: 0; border-bottom: 1px solid #dfe8e4; }
  .admin-brand { padding: 0 0 14px; border-bottom: 0; }
  .admin-brand img { width: 145px; }
  .side-caption, .sidebar-account { display: none; }
  .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side-nav .tab { grid-template-columns: 24px 1fr auto; padding: 10px; }
  .admin-main { min-height: calc(100vh - 150px); padding: 22px 18px 16px; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 22px, 1180px); padding-top: 18px; }
  .topbar { align-items: start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .side-nav { display: flex; overflow-x: auto; padding-bottom: 3px; }
  .side-nav .tab { flex: 0 0 154px; }
  .card.half { grid-column: span 12; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .list-item-row { flex-direction: column; }
  .list-item-row .btn { width: 100%; }
  .qr-section-head { align-items: start; flex-direction: column; }
  .qr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-row { grid-template-columns: 92px minmax(0, 1fr); }
}
