:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --input: #f9fafb;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --shadow: 0 12px 34px rgba(31, 41, 55, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.site-header { height: 68px; padding: 0 max(24px, calc((100vw - 1040px) / 2)); display: flex; align-items: center; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #818cf8); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { line-height: 1.15; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.page-shell { width: min(1040px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 68px; }
.page-heading { margin-bottom: 25px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 750; }
.page-heading h1 { margin: 0; font-size: 28px; line-height: 1.3; }
.page-heading p:last-child { margin: 7px 0 0; color: var(--muted); }
.demo-tag, .context-tag { display: inline-block; padding: 5px 9px; border-radius: 6px; color: var(--accent-hover); background: var(--accent-soft); font-size: 11px; font-weight: 700; }

.checkout-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-auto-rows: 1fr; gap: 18px; align-items: stretch; }
.checkout-layout > .panel { height: 100%; align-self: stretch; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.checkout-panel { padding: 28px; }
.step-section + .step-section { margin-top: 29px; padding-top: 27px; border-top: 1px solid var(--line); }
.section-heading { margin-bottom: 17px; display: flex; align-items: center; gap: 10px; }
.section-heading > span { width: 24px; height: 24px; display: grid; place-items: center; flex: none; color: #fff; border-radius: 50%; background: var(--accent); font-size: 12px; font-weight: 700; }
h1, h2 { letter-spacing: 0; }
.section-heading h2, .order-summary h2 { margin: 0; font-size: 16px; }
label { display: block; margin-bottom: 8px; color: #4b5563; font-size: 12px; font-weight: 650; }
.lookup-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 8px; }
input { width: 100%; height: 44px; padding: 0 13px; color: var(--text); border: 1px solid #d1d5db; border-radius: 8px; outline: none; background: var(--input); }
input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
.button { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; text-decoration: none; font-weight: 650; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-hover); }
.button:disabled { cursor: not-allowed; background: #aeb4c0; }
.field-help, .type-note { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.account-result { height: 70px; margin-top: 13px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow: hidden; border: 1px solid #c7d2fe; border-radius: 9px; background: var(--accent-soft); }
.account-result.pending { color: var(--muted); border-color: var(--line); border-style: dashed; background: var(--input); }
.account-result.error { color: #b91c1c; border-color: #fecaca; background: var(--danger-soft); }
.account-result.loading { color: var(--accent-hover); }
.account-name { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.account-state { margin-top: 2px; color: var(--accent-hover); font-size: 11px; }
.account-meta { flex: none; color: var(--muted); font-size: 10px; text-align: right; }
.account-meta strong { display: block; margin-top: 2px; color: var(--text); font-size: 13px; }

.segment { padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 10px; background: #f1f3f5; }
.segment-button { height: 40px; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-weight: 650; }
.segment-button.active { color: var(--accent-hover); background: #fff; box-shadow: 0 2px 7px rgba(31,41,55,.08); }
.type-note { min-height: 18px; margin: 10px 0 14px; }
.package-grid { min-height: 90px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.package { min-height: 90px; padding: 14px 10px; position: relative; color: var(--text); border: 1px solid #d6dbe1; border-radius: 9px; background: #fff; text-align: left; }
.package:hover { border-color: #a5acb7; }
.package.selected { padding: 13px 9px; border: 2px solid var(--accent); background: #f7f7ff; }
.package.selected::after { content: "✓"; width: 19px; height: 19px; position: absolute; top: 7px; right: 7px; display: grid; place-items: center; color: #fff; border-radius: 50%; background: var(--accent); font-size: 11px; }
.package strong, .package span { display: block; }
.package strong { font-size: 17px; }
.package span { margin-top: 9px; color: var(--muted); font-size: 12px; }

.order-summary { padding: 24px; display: flex; flex-direction: column; }
.order-summary h2 { margin-bottom: 20px; }
.order-summary dl { margin: 0; }
.order-summary dl > div { padding: 9px 0; display: flex; justify-content: space-between; gap: 14px; }
.order-summary dt { color: var(--muted); }
.order-summary dd { max-width: 180px; margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.order-summary .summary-total { margin-top: 11px; padding-top: 17px; align-items: baseline; border-top: 1px solid var(--line); }
.summary-total dd { font-size: 25px; }
.pay-button { width: 100%; height: 48px; margin-top: 17px; }
.submit-error { min-height: 18px; margin: 9px 0 0; color: #b91c1c; font-size: 11px; text-align: center; }
.order-notice { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; text-align: center; }
.security-note { margin-top: auto; padding-top: 15px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; line-height: 1.65; }

.state-shell { width: min(560px, calc(100% - 28px)); min-height: calc(100vh - 134px); margin: 0 auto; padding: 42px 0; display: grid; place-items: center; }
.state-panel { width: 100%; min-height: 455px; padding: 42px 40px; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.state-panel h1 { margin: 17px 0 0; font-size: 22px; }
.state-panel > p { margin: 8px 0 0; color: var(--muted); }
.gateway-tag { color: #0b63ce; background: #eaf3ff; }
.danger-tag { color: #b91c1c; background: var(--danger-soft); }
.state-icon { width: 58px; height: 58px; margin: 20px auto 0; display: grid; place-items: center; border-radius: 50%; font-size: 25px; font-weight: 800; }
.state-icon.money { color: var(--accent); background: var(--accent-soft); }
.state-icon.success { color: var(--ok); background: var(--ok-soft); }
.state-icon.failed { color: var(--danger); background: var(--danger-soft); }
.spinner { width: 46px; height: 46px; margin: 23px auto 0; border: 3px solid #dfe3e8; border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-details { width: 100%; margin: 23px auto; padding: 13px 16px; border-radius: 9px; background: var(--input); text-align: left; }
.state-details > div { padding: 6px 0; display: flex; justify-content: space-between; gap: 14px; }
.state-details dt { color: var(--muted); }
.state-details dd { margin: 0; font-weight: 700; text-align: right; word-break: break-all; }
.state-action { width: 100%; min-height: 44px; }
.text-link { margin-top: 15px; color: var(--muted); text-decoration: none; font-size: 12px; }
.text-link:hover { color: var(--accent); }
footer { padding: 20px; color: #8a929d; text-align: center; font-size: 11px; }

@media (max-width: 780px) {
  .site-header { height: 60px; padding: 0 18px; }
  .page-shell { width: min(100% - 24px, 600px); padding: 32px 0 48px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 24px; }
  .checkout-layout { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .checkout-layout > .panel { height: auto; }
  .checkout-panel { padding: 21px 17px; }
  .package-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .state-shell { min-height: calc(100vh - 126px); padding: 24px 0; }
}

@media (max-width: 520px) {
  .page-heading { display: block; }
  .demo-tag { margin-top: 10px; }
  .lookup-row { grid-template-columns: 1fr; }
  .lookup-row .button { height: 42px; }
  .account-result { height: 76px; }
  .account-meta { max-width: 135px; }
  .state-panel { min-height: 420px; padding: 30px 20px; }
}
