/* ==========================================================
   自动发卡系统 · 全站样式
   设计原则：单列聚焦 / 大字号 / 单一主行动点 / 充足留白 / 移动优先
   零外部依赖，可直接部署到国内服务器
   ========================================================== */

:root {
  --brand:        #2563EB;
  --brand-dark:   #1D4ED8;
  --brand-soft:   #EFF6FF;
  --brand-ring:   rgba(37, 99, 235, .18);
  --accent:       #F97316;
  --accent-soft:  #FFF7ED;
  --success:      #10B981;
  --success-soft: #ECFDF5;
  --danger:       #EF4444;
  --danger-soft:  #FEF2F2;
  --warning:      #D97706;
  --warning-soft: #FFFBEB;

  --ink:      #0F172A;
  --ink-2:    #475569;
  --ink-3:    #94A3B8;
  --line:     #E2E8F0;
  --line-2:   #F1F5F9;
  --surface:  #FFFFFF;
  --bg:       #F4F7FF;

  --radius:    20px;
  --radius-sm: 12px;
  --shadow:    0 18px 50px -20px rgba(30, 64, 175, .28), 0 2px 10px rgba(15, 23, 42, .04);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 50% -180px, rgba(37, 99, 235, .13), transparent 70%),
    radial-gradient(600px 400px at 100% 100%, rgba(59, 130, 246, .07), transparent 70%);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
[hidden] { display: none !important; }
::selection { background: var(--brand-ring); }

:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }

/* ---------------- 布局 ---------------- */
.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 18px 56px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page--wide { max-width: 1120px; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--ink);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
}
.brand__mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(140deg, #3B82F6, var(--brand-dark));
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .7);
}
.brand__sub { color: var(--ink-3); font-weight: 500; font-size: 13px; }

.footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 26px;
}
.card--flat { box-shadow: var(--shadow-sm); padding: 22px; }

/* ---------------- 商品页 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 18px;
}
.badge--warn { background: var(--warning-soft); color: var(--warning); }
.badge--ok   { background: var(--success-soft); color: #047857; }
.badge--gray { background: var(--line-2); color: var(--ink-2); }

.product-title {
  margin: 0 0 22px;
  font-size: 26px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -.02em;
  word-break: break-word;
}
.price-block {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, var(--brand-soft), #F8FBFF);
  border: 1px solid rgba(37, 99, 235, .09);
}
.price-block__label { color: var(--ink-2); font-size: 14px; }
.price-block__label small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.price {
  color: var(--brand-dark);
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.price i { font-style: normal; font-size: 20px; margin-right: 2px; }

.divider { height: 1px; background: var(--line-2); margin: 24px 0; }
.section-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 12px;
}
.remark {
  white-space: pre-line;
  word-break: break-word;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.9;
  background: #F8FAFC;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 72px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 20px -10px rgba(37, 99, 235, .9);
  transition: background-color .2s ease, box-shadow .2s ease, border-color .2s ease, color .2s ease;
}
.btn:hover:not(:disabled) { background: var(--brand-dark); box-shadow: 0 12px 26px -12px rgba(37, 99, 235, 1); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--ghost {
  background: #fff; color: var(--ink-2);
  border-color: var(--line); box-shadow: none;
}
.btn--ghost:hover:not(:disabled) { background: #F8FAFC; color: var(--ink); border-color: #CBD5E1; }
.btn--success { background: var(--success); box-shadow: 0 8px 20px -10px rgba(16, 185, 129, .9); }
.btn--success:hover:not(:disabled) { background: #059669; }
.btn--danger { background: #fff; color: var(--danger); border-color: #FECACA; box-shadow: none; }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn--sm { min-height: 38px; padding: 7px 14px; font-size: 13px; border-radius: 9px; width: auto; }
.btn--block-sm { min-height: 42px; font-size: 14px; }

.hint {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--ink-3); font-size: 12px; margin: 14px 0 0;
}
.notice {
  display: flex; gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.65;
  background: var(--warning-soft);
  color: #92400E;
  border: 1px solid #FDE68A;
  margin-bottom: 18px;
}
.notice svg { flex: none; margin-top: 2px; }
.notice--danger { background: var(--danger-soft); color: #B91C1C; border-color: #FECACA; }
.notice--info   { background: var(--brand-soft); color: var(--brand-dark); border-color: #BFDBFE; }

/* ---------------- 支付 / 结果页 ---------------- */
.order-meta {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 13px; color: var(--ink-2);
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.order-meta:last-of-type { border-bottom: none; }
.order-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.qr-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 0 8px;
}
.qr-box {
  width: 208px; height: 208px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
}
.qr-box svg { width: 100%; height: 100%; }
.qr-tip { color: var(--ink-2); font-size: 13px; margin-top: 14px; text-align: center; }

.wait {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 26px 0 8px; text-align: center;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.wait__title { font-size: 17px; font-weight: 600; }
.wait__desc { color: var(--ink-2); font-size: 13px; max-width: 300px; }

.stack { display: grid; gap: 10px; margin-top: 22px; }

/* ---------------- 提取码弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(4px);
  animation: fade-in .22s ease both;
}
.modal__panel {
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 24px;
  padding: 30px 26px 26px;
  text-align: center;
  box-shadow: 0 30px 70px -20px rgba(15, 23, 42, .5);
  animation: pop-in .28s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes draw-check { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }

.success-icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid; place-items: center;
}
.success-icon svg path { stroke-dasharray: 30; animation: draw-check .5s .1s ease both; }
.modal__title { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.modal__desc { color: var(--ink-2); font-size: 13px; margin: 0 0 22px; }

.code-box {
  position: relative;
  background: #F8FAFC;
  border: 1px dashed #CBD5E1;
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 14px;
  user-select: all;
}
.code-box__label { color: var(--ink-3); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.code-box__value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-all;
  line-height: 1.5;
}
.modal__meta { color: var(--ink-3); font-size: 12px; margin-top: 16px; word-break: break-all; }
.modal__close {
  background: none; border: none; color: var(--ink-3);
  font-size: 13px; margin-top: 16px; padding: 6px;
}
.modal__close:hover { color: var(--ink); }

/* ---------------- Toast ---------------- */
.toast-host {
  position: fixed; z-index: 90;
  top: 20px; left: 50%; transform: translateX(-50%);
  display: grid; gap: 8px; width: min(92vw, 380px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13px; color: var(--ink);
  box-shadow: 0 12px 32px -12px rgba(15, 23, 42, .32);
  animation: toast-in .22s ease both;
}
.toast--ok { border-left-color: var(--success); }
.toast--err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field__help { color: var(--ink-3); font-size: 12px; margin-top: 6px; line-height: 1.6; }
.input, .textarea, .select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.7; font-family: inherit; }
.textarea--code { font-family: var(--mono); min-height: 150px; font-size: 13px; }
.input--mono { font-family: var(--mono); font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px;
}
.switch-row__text { font-size: 13px; font-weight: 600; }
.switch-row__text small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #CBD5E1;
  transition: background-color .2s ease; pointer-events: none;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s ease;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }

/* ---------------- 后台 ---------------- */
.admin-shell { display: grid; grid-template-columns: 216px 1fr; gap: 24px; align-items: start; }
.sidebar {
  position: sticky; top: 24px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 12px;
  box-shadow: var(--shadow-sm);
}
.sidebar__title { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 15px; }
.nav { display: grid; gap: 3px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  border: none; background: transparent;
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  width: 100%; text-align: left;
  transition: background-color .18s ease, color .18s ease;
}
.nav__item:hover { background: var(--line-2); color: var(--ink); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav__item svg { flex: none; }
.sidebar__foot { border-top: 1px solid var(--line-2); margin-top: 12px; padding-top: 12px; }

.panel { display: none; }
.panel.is-active { display: block; animation: fade-in .2s ease both; }
.panel__head { margin-bottom: 18px; }
.panel__title { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.panel__desc { color: var(--ink-2); font-size: 13px; margin: 5px 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat__label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat__value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat--brand .stat__value { color: var(--brand-dark); }
.stat--ok .stat__value { color: var(--success); }
.stat--warn .stat__value { color: var(--accent); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 700; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.table th {
  background: #F8FAFC; color: var(--ink-2); font-weight: 600;
  text-align: left; padding: 11px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FBFCFF; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.table .nowrap { white-space: nowrap; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill--ok { background: var(--success-soft); color: #047857; }
.pill--wait { background: var(--warning-soft); color: var(--warning); }
.pill--off { background: var(--danger-soft); color: #B91C1C; }
.empty { padding: 36px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }

.login-wrap { max-width: 400px; margin: 8vh auto 0; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-head .brand { margin-bottom: 12px; }
.login-head p { color: var(--ink-2); font-size: 13px; margin: 0; }

.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kv { display: flex; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 7px 0; }
.kv b { color: var(--ink); font-weight: 600; word-break: break-all; }
.code-inline { font-family: var(--mono); background: var(--line-2); padding: 2px 6px; border-radius: 5px; font-size: 12px; color: var(--ink); }
.code-block {
  font-family: var(--mono); font-size: 12px; line-height: 1.65;
  color: var(--ink-2); background: #F8FAFC;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 0;
  white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow: auto;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .page--wide { padding: 20px 14px 40px; }
  .admin-shell { grid-template-columns: 1fr; gap: 14px; }
  .sidebar { position: static; padding: 12px; }
  .sidebar__title { padding-bottom: 10px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav__item { width: auto; flex: none; white-space: nowrap; padding: 9px 12px; }
  .sidebar__foot { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 8px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .page { padding: 24px 14px 40px; }
  .card { padding: 24px 20px; border-radius: 17px; }
  .product-title { font-size: 23px; }
  .price { font-size: 33px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .stat-grid { gap: 9px; }
  .stat { padding: 13px 14px; }
  .stat__value { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
