:root {
  --green: #173f35;
  --green-soft: #285b4d;
  --gold: #c99433;
  --cream: #f7f3e9;
  --card: #fffdfa;
  --ink: #202722;
  --muted: #718078;
  --line: #dedfd8;
  --success: #1f7a51;
  --warning: #b2691f;
  --error: #b33f3f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fffdf7 0, var(--cream) 44%, #eee8db 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
[hidden] { display: none !important; }

.page-shell { width: min(100%, 470px); margin: 0 auto; padding: 26px 16px max(24px, env(safe-area-inset-bottom)); }
.admin-shell { width: min(100%, 1180px); margin: 0 auto; padding: 26px 18px 40px; }
.brand-header { text-align: center; margin-bottom: 20px; }
.brand-header.compact { margin-bottom: 16px; }
.brand-header h1 { margin: 5px 0 4px; color: var(--green); font-size: clamp(26px, 7vw, 34px); }
.brand-header p { margin: 0; color: var(--muted); font-size: 14px; }
.brand-header .eyebrow { color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .08em; }

.card, .result-card, .records-panel {
  border: 1px solid rgba(23,63,53,.12);
  border-radius: 18px;
  background: rgba(255,253,250,.95);
  box-shadow: 0 12px 34px rgba(48,55,49,.09);
}
.card { padding: 20px; }
.card h2 { margin: 0 0 16px; font-size: 19px; }
label { display: block; margin: 13px 0 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid var(--line);
  border-radius: 11px; color: var(--ink); background: #fff; outline: none;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,148,51,.14); }

.primary-button, .secondary-button, .text-button {
  border: 0; border-radius: 11px; min-height: 46px; padding: 0 17px; font-weight: 800;
}
.primary-button { width: 100%; margin-top: 17px; color: white; background: var(--green); }
.primary-button.small { width: auto; min-height: 39px; margin: 0; }
.secondary-button { min-height: 39px; background: #e8eee9; color: var(--green); }
.text-button { min-height: 39px; background: transparent; color: var(--muted); }
button:disabled { opacity: .55; cursor: wait; }

.scanner-card { position: relative; overflow: hidden; aspect-ratio: 3/4; max-height: 64vh; border-radius: 20px; background: #08100d; box-shadow: 0 12px 34px rgba(0,0,0,.2); }
.scanner-card video { width: 100%; height: 100%; object-fit: cover; }
.shade { position: absolute; inset: 0; box-shadow: inset 0 0 0 999px rgba(0,0,0,.22); pointer-events: none; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 31%; aspect-ratio: 2.4/1; border: 2px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.22); pointer-events: none; }
.scan-frame::after { content: ""; position: absolute; left: 5%; right: 5%; top: 50%; height: 2px; background: var(--gold); box-shadow: 0 0 12px rgba(201,148,51,.85); }
.scan-frame span::before, .scan-frame span::after { content: ""; position: absolute; width: 25px; height: 25px; border-color: var(--gold); border-style: solid; }
.scan-frame span::before { left: -3px; top: -3px; border-width: 4px 0 0 4px; border-radius: 13px 0 0; }
.scan-frame span::after { right: -3px; bottom: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 13px; }

.status { min-height: 22px; margin: 13px 2px; text-align: center; color: var(--muted); font-size: 13px; }
.status[data-tone="error"] { color: var(--error); }
.status[data-tone="warn"] { color: var(--warning); }

.result-card { display: none; padding: 20px; }
.result-card.show { display: block; }
.result-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.result-heading h2 { margin: 0; font-size: 20px; }
.result-badge { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 900; }
.result-card.success .result-badge { background: var(--success); }
.result-card.duplicate .result-badge { background: var(--warning); }
.result-card.error .result-badge { background: var(--error); }
.result-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.result-label { color: var(--muted); font-size: 13px; }
.result-value { font-weight: 700; word-break: break-word; }

footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 21px; color: var(--muted); font-size: 12px; }

.admin-login { max-width: 430px; margin: 0 auto; }
.records-panel { padding: 16px; }
.records-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.records-toolbar p { margin: 0; }
.records-toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 900px; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #ecece7; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; color: var(--green); background: #edf2ed; }
td.empty { padding: 35px; text-align: center; color: var(--muted); }

@media (max-width: 650px) {
  .records-toolbar { align-items: flex-start; flex-direction: column; }
  footer { flex-direction: column; align-items: center; }
}
