:root {
  --ink: #17324f;
  --muted: #70849a;
  --line: #d8e6f3;
  --paper: #ffffff;
  --wash: #eef7ff;
  --green: #4a9ad4;
  --green-dark: #2d7fbb;
  --amber: #e8983c;
  --danger: #c94c4c;
  --shadow: 0 20px 55px rgba(63, 119, 164, .15);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #edf6ff; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(255,255,255,.95), transparent 30%),
    radial-gradient(circle at 90% 25%, rgba(196,226,250,.76), transparent 31%),
    linear-gradient(145deg, #f8fcff 0%, #eaf5ff 100%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .04em; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--green); color: white; box-shadow: 0 8px 20px rgba(74,154,212,.25); }
.public-brand { font-size: 19px; letter-spacing: .13em; color: #276a9b; }
.public-shell { min-height: 100vh; max-width: 560px; margin: 0 auto; padding: 28px 20px 40px; display: flex; flex-direction: column; }
.public-header { padding: 2px 2px 40px; }
.hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: 12vh; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .16em; }
h1 { font-size: clamp(31px, 9vw, 48px); letter-spacing: -.055em; line-height: 1.08; margin: 0 0 16px; }
.hero > h1 { text-align: center; letter-spacing: -.035em; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.8; margin: 0 0 30px; }
.query-card, .result-card { background: rgba(255,255,255,.92); border: 1px solid rgba(255,255,255,.95); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.input-label { display: block; font-size: 13px; color: var(--muted); font-weight: 700; margin: 0 0 8px 4px; }
.query-row { display: flex; gap: 10px; }
.text-input { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: white; padding: 14px 15px; outline: none; color: var(--ink); transition: .2s; }
.text-input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(74,154,212,.12); }
.primary-btn { border: 0; border-radius: 14px; padding: 0 21px; min-height: 50px; white-space: nowrap; color: white; background: var(--green); font-weight: 800; box-shadow: 0 10px 22px rgba(74,154,212,.25); transition: .2s; }
.primary-btn:hover { background: var(--green-dark); transform: translateY(-1px); }
.primary-btn:disabled { opacity: .55; transform: none; cursor: wait; }
.microcopy { color: #8a9999; font-size: 12px; margin: 12px 4px 0; }
.message { display: none; margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.message.show { display: block; }
.message.error { color: #9a3535; background: #fff0ed; }
.result-card { display: none; text-align: center; padding: 27px 22px 25px; }
.result-card.show { display: block; animation: rise .35s ease both; }
.shop-tag { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 7px 11px; font-size: 12px; color: var(--green-dark); background: var(--wash); font-weight: 800; }
.result-card h2 { margin: 17px 0 8px; font-size: 22px; }
.qrcode-frame { width: min(72vw, 280px); aspect-ratio: 1; margin: 22px auto 16px; padding: 10px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 12px 35px rgba(24,48,54,.1); }
.qrcode-frame img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.result-tip { color: var(--muted); margin: 0; font-size: 14px; }
.link-btn { margin-top: 20px; border: 0; background: transparent; color: var(--green); font-weight: 800; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 430px) { .query-row { flex-direction: column; } .primary-btn { width: 100%; } }

/* Admin */
.admin-body { background: #f1f7fc; }
.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: white; border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 27px; margin-top: 30px; }
.login-card p { color: var(--muted); line-height: 1.6; }
.stack { display: grid; gap: 13px; }
.admin-app { display: none; min-height: 100vh; }
.admin-app.show { display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { background: #1f5f8d; color: white; padding: 28px 20px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand-mark { background: #dff1ff; color: #225f89; }
.nav { margin-top: 42px; display: grid; gap: 8px; }
.nav button { text-align: left; color: #bcd3ce; background: transparent; border: 0; border-radius: 11px; padding: 12px; font-weight: 700; }
.nav button.active, .nav button:hover { color: white; background: rgba(255,255,255,.1); }
.logout-btn { position: absolute; bottom: 24px; left: 20px; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #d9e9e6; border-radius: 11px; padding: 10px 14px; }
.admin-main { min-width: 0; padding: 34px clamp(22px, 4vw, 54px) 60px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.admin-title h1 { font-size: 29px; margin: 0 0 7px; letter-spacing: -.03em; }
.admin-title p { margin: 0; color: var(--muted); }
.status-pill { border-radius: 999px; padding: 9px 13px; font-size: 13px; font-weight: 800; background: #e9efee; color: var(--muted); }
.status-pill.valid { background: #dbf3e9; color: #16715e; }
.status-pill.invalid { background: #ffe3df; color: #a33939; }
.status-pill.warning, .status-pill.checking { background: #fff0d8; color: #94621c; }
.panel { display: none; }
.panel.active { display: block; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.card { background: white; border: 1px solid #e5ecea; border-radius: 18px; padding: 22px; }
.card h2 { font-size: 17px; margin: 0 0 8px; }
.card-sub { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 19px; }
.span-4 { grid-column: span 4; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.metric { font-size: 32px; font-weight: 800; margin: 13px 0 4px; }
.muted { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; color: var(--muted); font-weight: 700; }
textarea.text-input { resize: vertical; min-height: 86px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.secondary-btn, .danger-btn { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 11px; min-height: 42px; padding: 0 15px; font-weight: 700; }
.danger-btn { color: var(--danger); }
.upload-box { border: 1px dashed #aec3bf; border-radius: 14px; padding: 20px; text-align: center; background: #f8fbfa; }
.upload-box input { width: 100%; }
.shop-list { display: grid; gap: 12px; }
.shop-item { display: grid; grid-template-columns: 66px minmax(0, 1fr) auto; gap: 15px; align-items: center; border: 1px solid var(--line); border-radius: 15px; padding: 12px; }
.shop-item img { width: 66px; height: 66px; border-radius: 10px; border: 1px solid var(--line); object-fit: contain; }
.shop-item h3 { font-size: 15px; margin: 0 0 5px; }
.shop-item p { font-size: 12px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.shop-actions { display: flex; gap: 7px; }
.toggle { border: 0; border-radius: 999px; padding: 8px 11px; font-size: 12px; font-weight: 800; background: #e6efed; color: var(--muted); }
.toggle.on { background: #dcefff; color: #2876aa; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #edf1f0; font-size: 13px; }
th { color: var(--muted); font-weight: 700; }
.empty { text-align: center; padding: 35px 15px; color: var(--muted); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 360px; border-radius: 13px; color: white; background: #245f8b; padding: 13px 17px; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: #a93d3d; }
@media (max-width: 850px) {
  .admin-app.show { display: block; }
  .sidebar { position: static; height: auto; padding: 18px; }
  .sidebar .brand { margin-bottom: 15px; }
  .nav { margin: 0; display: flex; overflow-x: auto; }
  .logout-btn { position: absolute; right: 18px; left: auto; top: 15px; bottom: auto; }
  .admin-main { padding: 24px 16px 45px; }
  .span-4, .span-8 { grid-column: span 12; }
}
@media (max-width: 560px) {
  .admin-top { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .shop-item { grid-template-columns: 55px minmax(0, 1fr); }
  .shop-item img { width: 55px; height: 55px; }
  .shop-actions { grid-column: 1 / -1; }
}
