:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #161b26;
  --text-secondary: #667085;
  --text-muted: #98a2b3;
  --border: #eaecf0;
  --wechat: #07c160;
  --wechat-dark: #06ad56;
  --wechat-soft: rgba(7, 193, 96, 0.1);
  --alipay: #1677ff;
  --alipay-dark: #0958d9;
  --alipay-soft: rgba(22, 119, 255, 0.1);
  --danger: #e5484d;
  --warning-bg: #fff8eb;
  --warning-border: #fedf89;
  --warning-text: #b54708;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 12px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, 0.22);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  word-break: break-all;
}

.page-shell {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 16px calc(108px + env(safe-area-inset-bottom, 0px));
}

.result-shell {
  padding-top: 28px;
  padding-bottom: 40px;
}

/* 顶部栏 */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 16px;
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shield-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.top-bar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.top-bar__sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--wechat-soft);
  color: var(--wechat-dark);
  white-space: nowrap;
}

.env-badge--sandbox {
  background: var(--alipay-soft);
  color: var(--alipay-dark);
}

.env-badge--mock {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* 提示条 */
.notice-banner {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 12.5px;
  line-height: 1.55;
}

/* 通用卡片 */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.flow-tag {
  font-size: 11.5px;
  color: var(--text-secondary);
  background: #f2f4f7;
  padding: 3px 9px;
  border-radius: 999px;
}

/* 金额卡片 */
.order-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

.order-meta__label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.order-meta__value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.amount-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 14px 0 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 8px 0 14px;
}

.amount-box__symbol {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.amount-box__input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 38px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  padding: 0;
  min-width: 0;
}

.amount-box__input:disabled {
  color: var(--text);
  opacity: 1;
  -webkit-text-fill-color: var(--text);
}

.amount-box__currency {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.16s ease;
}

.chip:hover {
  border-color: #cbd5e1;
}

.chip.is-active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

/* 支付方式列表 */
.method-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.method-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.method-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-item__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.method-item__name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
}

.recommend-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--wechat-soft);
  color: var(--wechat-dark);
}

.method-item__desc {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.radio-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #d0d5dd;
  flex-shrink: 0;
  position: relative;
  transition: all 0.16s ease;
}

.method-item.is-selected[data-method="wechatpay"] {
  border-color: var(--wechat);
  background: #f5fdf8;
}

.method-item.is-selected[data-method="wechatpay"] .radio-dot {
  border-color: var(--wechat);
  background: var(--wechat);
}

.method-item.is-selected[data-method="alipaycn"] {
  border-color: var(--alipay);
  background: #f3f8ff;
}

.method-item.is-selected[data-method="alipaycn"] .radio-dot {
  border-color: var(--alipay);
  background: var(--alipay);
}

.method-item.is-selected .radio-dot::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2.2px 2.2px 0;
  transform: rotate(45deg);
}

/* 调试面板 */
.debug-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.debug-panel__label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.debug-panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.mini-btn.is-active {
  background: #161b26;
  color: #ffffff;
  border-color: #161b26;
}

/* 底部说明 */
.trust-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 8px 0;
  line-height: 1.6;
}

.trust-footer p {
  margin: 0;
}

.trust-footer__sub {
  margin-top: 2px !important;
  font-size: 11.5px;
}

/* 底部吸底支付按钮栏 */
.pay-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}

.pay-bar__inner {
  max-width: 460px;
  margin: 0 auto;
}

.pay-btn {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 14px;
  color: #ffffff;
  font-size: 16.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.pay-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.pay-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.pay-btn--wechat {
  background: var(--wechat);
  box-shadow: 0 8px 20px rgba(7, 193, 96, 0.28);
}

.pay-btn--wechat:hover:not(:disabled) {
  background: var(--wechat-dark);
}

.pay-btn--alipay {
  background: var(--alipay);
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.28);
}

.pay-btn--alipay:hover:not(:disabled) {
  background: var(--alipay-dark);
}

.pay-btn__spinner,
.redirect-spinner,
.result-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 弹窗通用 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-card__head {
  padding: 16px 18px;
  color: #ffffff;
  background: var(--wechat);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-card__head.is-alipay {
  background: var(--alipay);
}

.modal-card__title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
}

.modal-card__sub {
  margin: 3px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-card__body {
  padding: 20px 18px 22px;
  text-align: center;
}

.qr-amount {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.qr-frame {
  width: 224px;
  height: 224px;
  margin: 0 auto 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.qr-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  background: #f4f6f9;
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wechat);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.45; }
}

.qr-order-id {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* 按钮组 */
.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions.vertical {
  flex-direction: column;
}

.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: #161b26;
  color: #ffffff;
}

.btn-secondary {
  background: #f2f4f7;
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost.light {
  color: rgba(255, 255, 255, 0.88);
}

/* 手机跳转弹窗 */
.redirect-body {
  padding: 28px 20px 22px;
}

.redirect-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  border: 3.5px solid #e5e7eb;
  border-top-color: var(--alipay);
}

.redirect-title {
  margin: 0 0 8px;
  font-size: 17px;
}

.redirect-desc {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 微信内引导遮罩 */
.wx-guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.84);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 22px;
}

.wx-guide-arrow {
  align-self: flex-end;
  margin-right: 6px;
}

.wx-guide-card {
  width: 100%;
  max-width: 340px;
  margin-top: 12px;
  padding: 22px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  text-align: center;
  backdrop-filter: blur(10px);
}

.wx-guide-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.wx-guide-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.9);
}

.wx-guide-card .btn-primary {
  background: var(--alipay);
}

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

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-icon--pending {
  background: var(--alipay-soft);
}

.result-icon--pending .result-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(22, 119, 255, 0.22);
  border-top-color: var(--alipay);
}

.result-icon--success {
  background: var(--wechat-soft);
  color: var(--wechat);
}

.result-icon--failed {
  background: rgba(229, 72, 77, 0.12);
  color: var(--danger);
}

.result-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.result-subtitle {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.result-amount {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 20px;
}

.detail-list {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 20px;
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 7px 0;
  font-size: 13px;
}

.detail-row__label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.detail-row__value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.result-actions {
  margin-top: 6px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: rgba(22, 27, 38, 0.92);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: calc(100% - 32px);
  text-align: center;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
