:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f8ef;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #eee;
  --bg: #f5f6f8;
  --card: #fff;
  --danger: #ee0a24;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: none;
  min-height: 100vh;
  padding-bottom: calc(80px + var(--safe-bottom));
}

.page--active {
  display: block;
}

/* ========== 首页 ========== */
#pageHome {
  padding-bottom: 0;
  background: #87ceeb;
}

.home-page {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 24px calc(16px + var(--safe-bottom));
  overflow: hidden;
}

.home-page__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #87ceeb;
  background-image: url('../assets/images/home-bg.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.home-page__bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.05) 0%,
      rgba(255, 255, 255, 0.15) 45%,
      rgba(255, 255, 255, 0.55) 85%,
      rgba(255, 255, 255, 0.75) 100%
    );
}

.home-page__main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  transform: translateY(-3%);
}

.home-header {
  text-align: center;
  margin-bottom: 20px;
}

.home-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin-bottom: 16px;
  background: #1e66ff;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(30, 102, 255, 0.35);
}

.home-logo svg {
  width: 48px;
  height: 48px;
}

.home-logo svg path {
  fill: #fff;
}

.home-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

.home-subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
}

.home-card {
  width: 100%;
  padding: 20px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(6px);
}

.home-card__hint {
  margin-bottom: 16px;
  font-size: 14px;
  color: #888;
  text-align: center;
  line-height: 1.5;
}

.home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: #1e66ff;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.home-btn:active {
  background: #1854d4;
  transform: scale(0.98);
}

.home-card__divider {
  height: 1px;
  margin: 16px 0 14px;
  background: #f0f0f0;
}

.home-card__link {
  text-align: center;
  font-size: 14px;
  color: #888;
}

.home-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  color: #1e66ff;
  cursor: pointer;
}

.home-status {
  text-align: center;
  margin-bottom: 16px;
}

.home-status__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: 700;
  color: #1e66ff;
  background: #eef3ff;
}

.home-status__title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 6px;
}

.home-status__desc {
  font-size: 14px;
  color: #888;
}

.home-footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 100%;
  max-width: 400px;
  padding: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  line-height: 1.6;
}

.card {
  margin: 16px;
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card--highlight {
  border: 1px solid #b7eb8f;
  background: linear-gradient(180deg, #f6ffed 0%, #fff 100%);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 14px;
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
}

.status-icon--success {
  background: var(--primary-light);
  color: var(--primary);
}

.page-header {
  position: sticky;
  top: 33px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 17px;
}

.back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.form {
  padding-bottom: 90px;
}

.section-title {
  font-size: 16px;
  margin-bottom: 14px;
}

.required {
  color: var(--danger);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  background: #fafafa;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
  background: #fff;
}

.field input.error {
  border-color: var(--danger);
}

.package-options {
  display: grid;
  gap: 10px;
}

.package-option {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  background: var(--card);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.package-option:hover:not(.selected) {
  border-color: #b7eb8f;
}

.package-option.selected {
  border-color: var(--primary);
  background: var(--primary);
}

.package-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.package-option__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.package-option__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.package-option.selected .package-option__title {
  color: #fff;
}

.package-option__price {
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.package-option.selected .package-option__price {
  color: #fff;
}

.package-option__desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.package-option.selected .package-option__desc {
  color: rgba(255, 255, 255, 0.88);
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.bottom-bar__price .label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.bottom-bar__price .amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn--outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--block {
  width: 100%;
}

.result-page {
  padding: 40px 16px 24px;
  text-align: center;
}

.result-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.result-icon--success {
  background: var(--primary-light);
  color: var(--primary);
}

.result-icon--fail {
  background: #fff1f0;
  color: var(--danger);
  font-weight: 700;
}

.result-page--fail {
  padding-top: 24px;
}

.fail-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 16px 24px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
  color: #fff;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(255, 77, 79, 0.35);
}

.fail-banner__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.result-desc--fail {
  color: var(--danger);
  font-size: 15px;
  font-weight: 500;
}

.result-hint {
  color: var(--text-secondary);
  font-size: 14px;
  margin: -16px 0 20px;
}

.order-summary--fail {
  border: 1px solid #ffccc7;
  background: #fffafa;
}

.btn--lg {
  min-height: 50px;
  font-size: 17px;
}

.result-page h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.result-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.result-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.order-summary {
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row .label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.detail-row .value {
  text-align: right;
  word-break: break-all;
}

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-tag--paid {
  background: var(--primary-light);
  color: var(--primary);
}

.status-tag--pending {
  background: #fff7e6;
  color: #d46b08;
}

.empty-state {
  margin: 40px 16px;
  padding: 32px 20px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay[hidden] {
  display: none !important;
}

.pay-dialog {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.pay-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.pay-logo {
  font-weight: 700;
  color: var(--primary);
}

.pay-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
}

.pay-merchant {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.pay-amount {
  text-align: center;
  font-size: 36px;
  font-weight: 700;
  margin: 8px 0 16px;
}

.pay-tip {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pay-dialog__actions {
  display: grid;
  gap: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 400;
  max-width: calc(100% - 40px);
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

.toast[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 768px) {
  body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px var(--border);
  }

  .overlay {
    align-items: center;
  }

  .pay-dialog {
    border-radius: 16px;
  }
}
