:root {
  --bg: #ffffff;
  --surface: #f6f6f7;
  --surface-el: #eeeeef;
  --fg: #111113;
  --fg2: #636366;
  --fg3: #aeaeb2;
  --border: #e5e5ea;
  --accent: #7c3aed;
  --accent-h: #6d28d9;
  --accent-a: #5b21b6;
  --accent-sub: #ede9fe;
  --success: #16a34a;
  --success-sub: #dcfce7;
  --warn: #d97706;
  --danger: #dc2626;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 9999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
input, button { font: inherit; border: none; outline: none; background: none; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

.page { display: none; min-height: 100dvh; flex-direction: column; }
.page.active { display: flex; }

.app-shell { max-width: 480px; margin: 0 auto; width: 100%; min-height: 100dvh; display: flex; flex-direction: column; position: relative; background: var(--bg); }
@media (min-width: 640px) {
  .app-shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 100vh; }
}

/* ─── Login (blue variant) ──────────────────────────────────────── */
#page-login { background: linear-gradient(160deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%); }
#page-login .app-shell-inner,
#page-login { background: none; }
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; flex: 1; background: linear-gradient(160deg, #1e3a5f 0%, #2563eb 50%, #1e40af 100%); }
.login-card { width: 100%; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 28px; border-radius: var(--r-xl); background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); display: grid; place-items: center; }
.login-logo svg { width: 30px; height: 30px; color: #fff; }
.login-title { font-size: 28px; font-weight: 700; text-align: center; letter-spacing: -0.025em; margin-bottom: 8px; color: #ffffff; }
.login-subtitle { text-align: center; color: rgba(255,255,255,0.7); font-size: 14px; margin-bottom: 40px; letter-spacing: 0.01em; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-field { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.12); border: 1.5px solid rgba(255,255,255,0.2); border-radius: var(--r-lg); padding: 0 16px; height: 52px; transition: border-color 120ms ease, background 120ms ease; backdrop-filter: blur(4px); }
.login-field:focus-within { border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.18); }
.login-field svg { width: 18px; height: 18px; color: rgba(255,255,255,0.6); flex-shrink: 0; }
.login-field input { flex: 1; background: none; color: #ffffff; font-size: 15px; height: 100%; }
.login-field input::placeholder { color: rgba(255,255,255,0.45); }
.login-error { color: #fca5a5; font-size: 13px; min-height: 20px; text-align: center; }
.btn-accent { display: flex; align-items: center; justify-content: center; height: 52px; background: #ffffff; color: #1e40af; border-radius: var(--r-lg); font-size: 16px; font-weight: 700; letter-spacing: 0.02em; transition: background 120ms ease, transform 80ms ease; }
.btn-accent:hover { background: #f0f0ff; }
.btn-accent:active { background: #e0e0ff; transform: scale(0.98); }
.btn-accent:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.login-footer { text-align: center; margin-top: 36px; font-size: 12px; color: rgba(255,255,255,0.5); }
.login-footer a { color: rgba(255,255,255,0.7); text-decoration: underline; }

/* ─── Header ────────────────────────────────────────────────────── */
.page-top { display: flex; align-items: center; justify-content: space-between; padding: 24px; border-bottom: 1px solid var(--border); background: var(--bg); }
.page-top-info { display: flex; flex-direction: column; gap: 3px; }
.page-top-info h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
.page-top-info span { font-size: 13px; color: var(--fg2); }
.page-top-actions { display: flex; gap: 8px; }
.btn-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-md); border: 1.5px solid var(--border); color: var(--fg2); transition: background 120ms ease, border-color 120ms ease; background: var(--bg); }
.btn-icon:hover { background: var(--surface); border-color: var(--fg3); }
.btn-logout { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--r-md); border: 1.5px solid var(--border); color: var(--fg2); font-size: 13px; font-weight: 500; transition: background 120ms ease; }
.btn-logout:hover { background: var(--surface); }

/* ─── Speed tabs ────────────────────────────────────────────────── */
.speed-section { padding: 24px 24px 0; }
.speed-tabs { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.speed-tabs::-webkit-scrollbar { display: none; }
.speed-tab { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 14px 22px; border-radius: var(--r-lg); border: 1.5px solid var(--border); background: var(--bg); color: var(--fg2); transition: all 120ms ease; cursor: pointer; min-width: 76px; }
.speed-tab:hover { border-color: var(--fg3); background: var(--surface); }
.speed-tab.active { border-color: var(--accent); background: var(--accent-sub); color: var(--accent); }
.speed-tab .val { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; font-family: var(--mono); }
.speed-tab .lbl { font-size: 11px; color: var(--fg3); font-weight: 500; }
.speed-tab.active .lbl { color: var(--accent); }

/* ─── Package list ──────────────────────────────────────────────── */
.pkg-section { padding: 24px; flex: 1; overflow-y: auto; }
.pkg-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 420px) { .pkg-grid { grid-template-columns: 1fr 1fr; } }
.pkg-card { position: relative; background: var(--surface); border: 2px solid transparent; border-radius: var(--r-xl); padding: 22px; cursor: pointer; transition: border-color 120ms ease, background 120ms ease, transform 100ms ease; }
.pkg-card:hover { background: var(--surface-el); }
.pkg-card.selected { border-color: var(--accent); background: var(--accent-sub); }
.pkg-badge { position: absolute; top: 0; right: 16px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 4px 10px; border-radius: 0 0 var(--r-sm) var(--r-sm); letter-spacing: 0.04em; }
.pkg-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; color: var(--fg); }
.pkg-desc { font-size: 12px; color: var(--fg2); margin-bottom: 16px; }
.pkg-price { font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--fg); }
.pkg-price span { font-size: 15px; font-weight: 500; }
.pkg-original { font-size: 12px; color: var(--fg3); text-decoration: line-through; margin-top: 4px; font-family: var(--mono); }
.pkg-save { display: inline-block; margin-top: 10px; font-size: 11px; color: var(--success); background: var(--success-sub); padding: 3px 10px; border-radius: var(--r-pill); font-family: var(--mono); font-weight: 600; }

/* ─── Bottom bar ────────────────────────────────────────────────── */
.bottom-bar { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; z-index: 5; }
.bottom-info { display: flex; flex-direction: column; gap: 2px; }
.bottom-info .label { font-size: 12px; color: var(--fg2); font-weight: 500; }
.bottom-info .value { font-size: 14px; font-weight: 600; }
.bottom-info .value.price { font-family: var(--mono); color: var(--accent); font-size: 20px; font-weight: 700; }
.btn-pay { height: 48px; padding: 0 32px; border-radius: var(--r-lg); background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; white-space: nowrap; transition: background 120ms ease, transform 80ms ease; }
.btn-pay:hover { background: var(--accent-h); }
.btn-pay:active { background: var(--accent-a); transform: scale(0.97); }
.btn-pay:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ─── Confirm page ──────────────────────────────────────────────── */
.confirm-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); background: var(--bg); }
.confirm-header h2 { font-size: 17px; font-weight: 700; }
.confirm-body { padding: 24px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.info-card { background: var(--surface); border: none; border-radius: var(--r-xl); padding: 22px; }
.info-card-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin-bottom: 16px; color: var(--fg2); text-transform: uppercase; letter-spacing: 0.04em; }
.info-card-title svg { color: var(--accent); }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.info-row + .info-row { border-top: 1px solid var(--border); }
.info-label { font-size: 13px; color: var(--fg2); }
.info-value { font-size: 14px; font-weight: 500; }
.info-value.hl { color: var(--accent); font-weight: 600; }
.info-value.price-big { font-family: var(--mono); font-size: 26px; font-weight: 700; color: var(--fg); }
.info-divider { height: 1px; background: var(--border); margin: 10px 0; }

/* ─── Pay methods ───────────────────────────────────────────────── */
.pay-methods { display: flex; flex-direction: column; gap: 10px; }
.pay-method { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: var(--r-lg); border: 1.5px solid var(--border); background: var(--bg); cursor: pointer; transition: border-color 120ms ease, background 120ms ease; }
.pay-method:hover { border-color: var(--fg3); }
.pay-method.active { border-color: var(--accent); background: var(--accent-sub); }
.pay-method-icon { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0; }
.pay-method-icon.wechat { background: rgba(7, 193, 96, 0.1); }
.pay-method-icon.alipay { background: rgba(22, 119, 255, 0.1); }
.pay-method-name { flex: 1; font-size: 14px; font-weight: 600; }
.pay-method-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; transition: all 120ms ease; }
.pay-method.active .pay-method-check { border-color: var(--accent); background: var(--accent); }
.pay-method-check svg { opacity: 0; transition: opacity 120ms ease; }
.pay-method.active .pay-method-check svg { opacity: 1; }

/* ─── Records ───────────────────────────────────────────────────── */
.record-list { padding: 24px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.record-card { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--surface); border-radius: var(--r-lg); cursor: pointer; transition: background 120ms ease, transform 100ms ease; }
.record-card:hover { background: var(--surface-el); }
.record-card:active { transform: scale(0.98); }
.record-icon { width: 44px; height: 44px; border-radius: var(--r-md); background: var(--accent-sub); display: grid; place-items: center; flex-shrink: 0; }
.record-icon svg { width: 20px; height: 20px; color: var(--accent); }
.record-body { flex: 1; min-width: 0; }
.record-body h4 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.record-body span { font-size: 12px; color: var(--fg2); }
.record-right { text-align: right; flex-shrink: 0; }
.record-right .amount { font-family: var(--mono); font-size: 16px; font-weight: 700; }
.record-right .status { font-size: 11px; color: var(--success); font-weight: 600; margin-top: 3px; }
.record-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; color: var(--fg3); text-align: center; }
.record-empty svg { opacity: 0.25; margin-bottom: 16px; }
.record-empty p { font-size: 15px; margin-bottom: 6px; color: var(--fg2); font-weight: 600; }
.record-empty span { font-size: 13px; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 100; align-items: flex-end; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-sheet { width: 100%; max-width: 480px; max-height: 85dvh; background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0; overflow-y: auto; animation: slideUp 200ms cubic-bezier(0.2, 0, 0, 1); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle { width: 36px; height: 4px; background: var(--fg3); border-radius: 2px; margin: 12px auto 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-head button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--fg2); transition: background 120ms ease; }
.modal-head button:hover { background: var(--surface); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.detail-section-title { font-size: 11px; font-weight: 700; color: var(--fg3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px; font-family: var(--mono); }
.modal-body .info-card { background: none; border: none; padding: 0; }
.modal-body .info-card + .info-card { border-top: 1px solid var(--border); padding-top: 24px; }
.modal-body .info-row { padding: 8px 0; }
.modal-btn { display: flex; justify-content: center; padding: 0 24px 28px; }
.modal-btn .btn-accent { width: 100%; background: var(--accent); color: #fff; }
.modal-btn .btn-accent:hover { background: var(--accent-h); }

/* ─── Success modal ─────────────────────────────────────────────── */
.success-content { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.success-icon { width: 80px; height: 80px; margin-bottom: 24px; border-radius: 50%; background: var(--success-sub); display: grid; place-items: center; }
.success-icon svg { width: 40px; height: 40px; color: var(--success); }
.success-content h3 { font-size: 22px; font-weight: 700; }
.success-content p { font-size: 14px; color: var(--fg2); margin: 8px 0 32px; max-width: 260px; }
.success-content .btn-accent { width: 100%; max-width: 220px; background: var(--accent); color: #fff; }
.success-content .btn-accent:hover { background: var(--accent-h); }

/* ─── Pay notice modal ─────────────────────────────────────────── */
.notice-warn { display: flex; gap: 12px; padding: 14px 16px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--r-md); }
.notice-warn svg { flex-shrink: 0; width: 22px; height: 22px; color: var(--warn); margin-top: 1px; }
.notice-warn p { font-size: 13px; line-height: 1.65; color: var(--fg); margin: 0; }
.notice-warn b { color: var(--warn); }
.notice-fields { display: flex; flex-direction: column; gap: 10px; }
.notice-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: var(--r-md); }
.notice-row .info-label { font-size: 12px; color: var(--fg3); flex-shrink: 0; min-width: 44px; }
.notice-row .info-value { flex: 1; font-size: 15px; font-weight: 600; color: var(--fg); }
.notice-example { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border-radius: var(--r-md); font-size: 13px; color: var(--fg2); }
.notice-example .mono { font-family: var(--mono); color: var(--fg); font-weight: 600; flex: 1; min-width: 0; word-break: break-all; }
.notice-copy { flex-shrink: 0; padding: 5px 10px; font-size: 12px; color: var(--accent); background: var(--accent-sub); border-radius: var(--r-sm); transition: opacity 120ms ease; }
.notice-copy:active { opacity: 0.6; }
.mono { font-family: var(--mono); }

/* ─── Qrcode modal ─────────────────────────────────────────────── */
.qrcode-amount { text-align: center; padding: 4px 0 12px; }
.qrcode-amount .label { display: block; font-size: 12px; color: var(--fg3); margin-bottom: 4px; }
.qrcode-amount .amount { font-size: 34px; font-weight: 700; color: var(--accent); }
.qrcode-img { display: flex; justify-content: center; padding: 4px 0 16px; }
.qrcode-img img { width: 300px; max-width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: #fff; }
.qrcode-remark { padding: 12px 14px; background: var(--accent-sub); border-radius: var(--r-md); border: 1px dashed var(--accent); }
.qrcode-remark > span { display: block; font-size: 12px; color: var(--fg2); margin-bottom: 6px; }
.remark-content { font-size: 16px; font-weight: 700; color: var(--accent); word-break: break-all; }
.qrcode-tip { padding: 10px 14px; font-size: 12px; color: var(--fg3); text-align: center; line-height: 1.6; }

/* ─── Toast ────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(10px); background: rgba(0,0,0,0.82); color: #fff; padding: 9px 18px; border-radius: var(--r-pill); font-size: 13px; z-index: 300; opacity: 0; transition: opacity 200ms ease, transform 200ms ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Back button ───────────────────────────────────────────────── */
.btn-back { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-md); color: var(--fg2); transition: background 120ms ease; }
.btn-back:hover { background: var(--surface); }

@media (min-width: 640px) {
  .login-page { padding: 48px 40px; }
  .speed-section { padding: 28px 32px 0; }
  .pkg-section { padding: 28px 32px; }
  .page-top { padding: 28px 32px; }
  .confirm-body { padding: 28px 32px; }
  .confirm-header { padding: 22px 32px; }
  .bottom-bar { padding: 18px 32px; }
  .record-list { padding: 28px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; transition-duration: 0ms !important; }
}
