:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #0070ba;
  --blue-dark: #003087;
  --green: #059669;
  --amber: #b45309;
  --red: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e8f1ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #eef6ff 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.page { max-width: 1040px; margin: 0 auto; padding: 28px 20px 40px; }

/* top bar */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}

/* two-line nav: merchants on top, actions below */
.nav-stack {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 8px; flex: none;
}
.nav-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center;
}
.nav-actions .nav-btn, .nav-actions .ghost {
  height: 32px; padding: 0 13px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; white-space: nowrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 20px;
  box-shadow: 0 6px 16px rgba(0, 48, 135, 0.25);
}
h1 { font-size: 18px; margin: 0; letter-spacing: -0.2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.badges { display: flex; gap: 8px; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: #e8f1ff; color: var(--blue-dark); border: 1px solid #cfe3ff;
}
.badge-muted { background: #f3f4f6; color: #4b5563; border-color: var(--line); }
.badge-ok { background: #ecfdf5; color: var(--green); border-color: #bbf7d0; }
.badge-warn { background: #fffbeb; color: var(--amber); border-color: #fde68a; }

.badge-link {
  text-decoration: none;
  cursor: pointer;
  background: #fff;
  color: var(--blue-dark);
  border-color: #cfe3ff;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.badge-link:hover { background: #eff6ff; border-color: var(--blue); }
.badge-link:active { transform: translateY(1px); }

.badge-merchant {
  background: #fff; color: #6b7280; border-color: var(--line);
  text-decoration: none;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.badge-merchant:hover { border-color: #c4b5fd; color: #5b21b6; background: #faf5ff; }
.badge-merchant.active {
  background: #f5f3ff; color: #5b21b6; border-color: #c4b5fd; font-weight: 700;
}
.merchant-switch { display: inline-flex; gap: 6px; align-items: center; }

/* notice */
.notice {
  border-radius: 12px; padding: 11px 14px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.5;
  border: 1px solid #fde68a; background: #fffbeb; color: var(--amber);
}
.notice.info { border-color: #cfe3ff; background: #eff6ff; color: #1d4ed8; }
.hidden { display: none !important; }

/* layout */
.grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 16px; font-weight: 700;
}

/* fields */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 12.5px; font-weight: 600;
  color: #374151; margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="number"], input[type="password"], select {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1.5px solid #e2e6ee; border-radius: 12px;
  background: #fbfcfe; color: var(--ink); font-size: 14px; font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input[type="text"]:hover, input[type="email"]:hover, input[type="number"]:hover, input[type="password"]:hover, select:hover {
  border-color: #cfd6e2;
}
input:focus, select:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 112, 186, 0.10);
}
input::placeholder { color: #a8b0bd; }

/* 持卡人姓名：用自己的输入框（PayPal 姓名字段是可选的） */
.cf-input {
  width: 100%; height: 48px; padding: 0 14px; box-sizing: border-box;
  border-radius: 12px !important;
  border: 1.5px solid #e2e6ee !important;
  background: #fbfcfe !important;
  color: #111827 !important;
  font-size: 16px; font-family: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.cf-input:hover { border-color: #cfd6e2 !important; }
.cf-input:focus {
  background: #fff !important;
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 4px rgba(0, 112, 186, 0.10) !important;
}
.cf-input::placeholder { color: #9ca3af !important; }
.amount-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }

/* quick amounts */
.quick-amounts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.quick-amounts button {
  flex: 1; min-width: 64px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.quick-amounts button:hover { border-color: var(--blue); color: var(--blue); }

/* email input with inline generate button */
.email-row { position: relative; }
.email-row input { padding-right: 104px; }
.email-row .gen-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.email-row .gen-btn:hover { color: var(--blue); border-color: var(--blue); }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; background: #f3f4f6; border-radius: 11px;
}
.segmented button {
  border: 0; background: transparent; padding: 8px 6px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: #4b5563; cursor: pointer;
  font-family: inherit; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented button.active {
  background: #fff; color: var(--blue-dark);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.summary { border-top: 1px dashed var(--line); margin-top: 18px; padding-top: 14px; }
.summary .row {
  display: flex; justify-content: space-between; padding: 5px 0;
  color: var(--muted); font-size: 13px;
}
.summary .row b { color: var(--ink); font-weight: 600; }
.summary .total {
  border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px;
  color: var(--ink); font-size: 14px;
}
.summary .total b { font-size: 18px; letter-spacing: -0.3px; }

.safe {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  font-size: 12px; color: var(--muted);
  background: #f9fafb; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px;
}
.safe .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); flex: none;
}
.safe.live {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.safe.live .dot {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; font-size: 11.5px; color: var(--muted);
}
.meta code { font-family: Consolas, monospace; color: #374151; }

/* pay panel */
.paypal-buttons { min-height: 50px; position: relative; z-index: 0; isolation: isolate; }

/* SDK v6 web component button */
paypal-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
}
.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 14px; color: var(--muted); font-size: 12px;
}
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.cf-wrap { min-width: 0; margin-bottom: 12px; }
.cf-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: #374151; margin-bottom: 6px;
}
.cf {
  display: flex; align-items: center;
  height: 48px; border-radius: 12px; border: 1.5px solid #e2e6ee;
  background: #fbfcfe; overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.cf.invalid { border-color: #f3b4b4; background: #fffafa; }
.cf:hover { border-color: #cfd6e2; }
.cf.loading {
  background: linear-gradient(90deg, #f1f5f9 25%, #e6edf7 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: cfShimmer 1.4s ease-in-out infinite;
  border-color: #e2e6ee;
}
@keyframes cfShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.cf:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 112, 186, 0.10);
  background: #fff;
}
.cf iframe {
  display: block;
  width: 100% !important;
  height: 44px !important;
  border: 0;
}

.primary {
  width: 100%; height: 46px; margin-top: 6px; border: 0; border-radius: 12px;
  background: linear-gradient(180deg, #0079d6 0%, #0060a8 100%);
  color: #fff; font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: filter 0.15s, transform 0.05s;
  box-shadow: 0 6px 14px rgba(0, 96, 168, 0.22);
}
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.ghost {
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid #d1d5db; background: #fff; color: #374151;
  font-weight: 600; font-family: inherit; cursor: pointer;
}
.ghost:hover { background: #f9fafb; }
.small { width: auto; height: 38px; padding: 0 16px; margin: 0; font-size: 13.5px; }

.demo {
  border: 1px dashed #c7d2fe; background: #f5f7ff;
  border-radius: 12px; padding: 14px; text-align: center;
}
.demo p { margin: 0 0 10px; color: #4338ca; font-size: 13px; }

/* result */
.result-card { margin-top: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin-bottom: 14px;
  font-size: 12.5px;
}
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.detail-grid .wide { grid-column: 1 / -1; }
.detail-grid span { color: var(--muted); font-size: 11.5px; }
.detail-grid code {
  font-family: Consolas, monospace; color: #374151;
  word-break: break-all; font-size: 12px;
}
.detail-grid .err-text { color: var(--red); }
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.result-head-right { display: flex; align-items: center; gap: 10px; }
.result-head-right .ghost.small { height: 30px; font-size: 12.5px; padding: 0 12px; }
.result-head h2 { margin: 0; }
.status {
  font-size: 12px; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: #f3f4f6; color: #4b5563;
}
.status.ok { background: #ecfdf5; color: var(--green); }
.status.err { background: #fef2f2; color: var(--red); }
.status.warn { background: #fffbeb; color: var(--amber); }

.result-actions { display: flex; gap: 8px; margin-bottom: 12px; }

.paypal-toggle { margin: 0 0 12px; }
.switch-row {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.switch-row input {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--blue); cursor: pointer;
}

.check-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: #374151; cursor: pointer; user-select: none;
  padding: 10px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px solid var(--line);
  margin-bottom: 10px;
}
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.check-row span { color: #4b5563; }

.result {
  margin: 0; padding: 14px; background: #0b1220; color: #cbd5e1;
  border-radius: 12px; font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px; line-height: 1.6; max-height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}

.foot {
  display: flex; justify-content: space-between; margin-top: 18px;
  color: #9ca3af; font-size: 11.5px; font-family: Consolas, monospace;
}

/* top nav buttons */
.nav-btn {
  height: 32px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.nav-btn:hover { background: #f8fafc; border-color: #cfd6e2; color: var(--blue-dark); }

/* 右侧列：支付方式 + 交易结果 上下排列；左侧订单信息跨两行 */
.grid > .card:first-of-type { grid-row: span 2; }
.grid .result-card { margin-top: 0; }
.raw-card { margin-top: 16px; }
@media (max-width: 860px) {
  .grid > .card:first-of-type { grid-row: auto; }
}

/* 右侧列：支付方式 + 交易结果 同一列，底部与左侧卡片对齐 */
.grid { align-items: stretch; }
.col-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-right > .card { margin-top: 0; }
.col-right .result-card { flex: 1; display: flex; flex-direction: column; }
.grid > .card:first-of-type { grid-row: auto; }
