:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #5f6b7a;
  --text-3: #9aa4b2;
  --border: #eceef1;
  --accent: #ffcf01;
  --accent-contrast: #211b06;
  --danger: #ff3b30;
  --success: #00b578;
  --warning: #ff8a00;
  --radius: 16px;
}

body[data-channel="eleme"] {
  --accent: #00a5ff;
  --accent-contrast: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button {
  font-family: inherit;
}

.shell {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.hidden {
  display: none !important;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 700;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transition: background 0.2s;
}

.secure {
  font-size: 12px;
  color: var(--text-3);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(31, 35, 41, 0.05);
}

.card-title {
  font-size: 17px;
  margin-bottom: 4px;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 16px;
  line-height: 1.5;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ---------- 配置表单 ---------- */
.field {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  outline: none;
}

select:focus {
  border-color: var(--accent);
}

.amount-preview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text-2);
}

.amount-preview strong {
  font-size: 20px;
  color: var(--text);
}

.channel-options {
  display: flex;
  gap: 10px;
}

.channel-option {
  flex: 1;
  padding: 12px 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.channel-option.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

/* ---------- 商家卡片 ---------- */
.merchant-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.merchant-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  background: #f0f1f3;
  flex-shrink: 0;
}

.merchant-info {
  flex: 1;
  min-width: 0;
}

.merchant-name {
  font-size: 16px;
  font-weight: 700;
}

.merchant-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.channel-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.2s;
}

/* ---------- 订单卡片 ---------- */
.order-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.product-img {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  object-fit: cover;
  background: #f4f5f7;
  flex-shrink: 0;
}

.order-info {
  flex: 1;
  min-width: 0;
}

.order-name {
  font-size: 15px;
  font-weight: 600;
}

.order-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
  line-height: 1.5;
}

.order-no {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
  word-break: break-all;
}

.order-amount {
  white-space: nowrap;
  padding-top: 2px;
}

.order-amount small {
  font-size: 12px;
}

.order-amount strong {
  font-size: 22px;
  font-weight: 800;
}

/* ---------- 倒计时 ---------- */
.countdown-card {
  text-align: center;
  padding: 18px 16px;
}

.countdown-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.countdown-label {
  font-size: 13px;
  color: var(--text-2);
}

.countdown {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: var(--text);
  transition: color 0.2s;
}

body.urgent .countdown {
  color: var(--warning);
}

body.critical .countdown {
  color: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  margin-top: 14px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 1s linear, background 0.3s;
}

body.critical .progress-bar {
  background: var(--danger);
}

/* ---------- 二维码上传 ---------- */
.pay-type-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 10px 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.dropzone {
  border: 1.5px dashed #d4d9e0;
  border-radius: 14px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fafbfc;
  overflow: hidden;
  transition: all 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #fffdf2;
}

.dropzone.uploading {
  opacity: 0.6;
  pointer-events: none;
}

.dropzone img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.dropzone-empty {
  text-align: center;
  padding: 20px;
}

.drop-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 24px;
  line-height: 42px;
  margin: 0 auto 10px;
}

.dropzone-empty p {
  font-size: 13px;
  color: var(--text-2);
}

.dropzone-empty .muted {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.qr-tip {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin-top: 10px;
  transition: color 0.2s;
}

.qr-tip.ok {
  color: var(--success);
}

/* ---------- 已生成页 ---------- */
.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.link-box span {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-2);
  word-break: break-all;
  text-align: left;
}

.copy-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:active {
  transform: scale(0.96);
}

.generated-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.generated-preview img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.generated-preview p {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 0;
}

.generated-preview strong {
  color: var(--text);
}

/* ---------- 支付方式 ---------- */
.pay-method {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.pay-method-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pay-method-info {
  flex: 1;
  min-width: 0;
}

.pay-method-name {
  font-size: 15px;
  font-weight: 700;
}

.pay-method-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.5;
}

.pay-method-check {
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ---------- 收款码长按识别兜底 ---------- */
.qr-fallback {
  text-align: center;
  margin-top: 4px;
}

.qr-fallback img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 0 auto 12px;
  display: block;
  background: #fff;
}

/* ---------- 按钮 ---------- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text-3);
  font-size: 12px;
  cursor: default;
}

.btn-pay {
  margin-top: 4px;
}

/* ---------- 结果页 ---------- */
.result-card {
  text-align: center;
  padding: 36px 20px;
}

.checkmark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 38px;
  line-height: 72px;
  margin: 0 auto 18px;
  animation: pop 0.35s ease;
}

@keyframes pop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.expired-icon {
  font-size: 56px;
  margin-bottom: 14px;
}

.result-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.result-card p {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 24px;
}

.result-card dl {
  text-align: left;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 24px;
}

.result-card dl div {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.result-card dt {
  color: var(--text-3);
}

.result-card dd {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

/* ---------- 页脚 / Toast ---------- */
.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 35, 41, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 99;
  white-space: nowrap;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
