:root {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #172033;
  background: #f4f6f9;
  font-synthesis: none;
  letter-spacing: 0;
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --line: #dfe4eb;
  --muted: #657186;
  --surface: #ffffff;
  --success: #16875d;
  --warning-bg: #fff7e6;
  --warning: #9a5b00;
  --danger: #c73535;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f6f9;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.topbar {
  height: 68px;
  border-bottom: 1px solid #e4e8ee;
  background: #fff;
}

.topbar-inner {
  width: min(100% - 32px, 880px);
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 7px;
  font-size: 17px;
  font-weight: 700;
}

.brand-name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.brand-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.service-state {
  margin-left: auto;
  color: #4e5b6f;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.service-state b { font-weight: 400; }
.service-state.offline { color: #a33b3b; }
.service-state.offline span { background: #d14343; }

.service-state span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1ca66f;
}

.page-shell {
  width: min(100% - 32px, 760px);
  margin: 36px auto 24px;
}

.checkout-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 8px 26px rgba(22, 31, 49, 0.06);
}

.hidden { display: none !important; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  color: #101828;
  font-size: 24px;
  line-height: 1.3;
}

.security-badge, .countdown {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #b7d3ff;
  border-radius: 6px;
  color: #0958d9;
  background: #f2f7ff;
  font-size: 13px;
  white-space: nowrap;
}

fieldset { margin: 0 0 25px; padding: 0; border: 0; }
legend { margin-bottom: 11px; color: #313d50; font-size: 14px; font-weight: 700; }

.segment-control, .payment-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-button, .amount-button {
  min-height: 48px;
  border: 1px solid #d6dce5;
  border-radius: 6px;
  color: #29364a;
  background: #fff;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.option-button:hover, .amount-button:hover { border-color: #82b3ff; }
.option-button.active, .amount-button.active {
  border-color: var(--primary);
  color: #0958d9;
  background: #edf5ff;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.amount-button { font-weight: 700; }

.summary-row {
  margin-top: 4px;
  padding: 18px 0;
  border-top: 1px solid #edf0f4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.summary-row strong { color: #101828; font-size: 24px; }

.primary-button, .secondary-button, .plain-button {
  min-height: 44px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover { background: var(--primary-dark); }
.secondary-button { width: 100%; border: 1px solid #cfd6e0; color: #344054; background: #fff; }
.plain-button { border: 0; color: #0958d9; background: transparent; padding: 6px 8px; min-height: 34px; }
.error-message { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; text-align: center; }

.payment-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 30px;
  align-items: center;
  margin-bottom: 24px;
}

.qr-zone { text-align: center; }
.payment-qr, .qr-placeholder {
  width: 250px;
  height: 250px;
  border: 1px solid #d9dfe8;
  border-radius: 6px;
  background: #fff;
}

.payment-qr { display: block; object-fit: contain; padding: 8px; }
.qr-placeholder { display: grid; place-items: center; color: var(--muted); background: #f7f8fa; }
.payment-channel-name { margin-top: 10px; color: #4b586c; font-size: 14px; }

.exact-amount-block {
  padding-bottom: 18px;
  border-bottom: 1px solid #e8ebf0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.exact-amount-block span { color: var(--muted); font-size: 13px; }
.exact-amount-block strong { grid-column: 1; color: #d4380d; font-size: 38px; line-height: 1.25; }
.exact-amount-block .plain-button { grid-column: 2; grid-row: 1 / span 2; }

.order-facts { padding: 13px 0; }
.order-facts div { min-height: 29px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.order-facts span { color: var(--muted); font-size: 13px; }
.order-facts strong { max-width: 65%; overflow: hidden; text-overflow: ellipsis; color: #263247; font-size: 13px; white-space: nowrap; }

.amount-warning {
  padding: 10px 12px;
  border: 1px solid #ffd591;
  border-radius: 6px;
  color: var(--warning);
  background: var(--warning-bg);
  font-size: 13px;
  line-height: 1.5;
}

.waiting-line { margin-top: 15px; display: flex; align-items: center; gap: 9px; color: #526075; font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid #c7d9f4; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.centered { text-align: center; }
.success-icon, .offline-icon {
  width: 54px;
  height: 54px;
  margin: 4px auto 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  font-size: 28px;
  font-weight: 700;
}
.offline-icon { background: #cc3d3d; }
.success-summary, .state-message { margin: 12px auto 24px; color: var(--muted); text-align: center; line-height: 1.6; }

.code-output {
  margin: 24px 0 14px;
  padding: 22px;
  border: 1px dashed #9ebce6;
  border-radius: 7px;
  background: #f7faff;
}
.code-output code { display: block; margin-bottom: 16px; overflow-wrap: anywhere; color: #13223a; font-family: Consolas, monospace; font-size: 22px; text-align: center; }

footer { padding: 12px 16px 28px; color: #8993a3; font-size: 12px; text-align: center; }

@media (max-width: 700px) {
  .page-shell { width: min(100% - 20px, 760px); margin-top: 18px; }
  .checkout-panel { padding: 20px 16px; }
  .section-heading { margin-bottom: 23px; }
  h1 { font-size: 21px; }
  .security-badge { display: none; }
  .amount-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .payment-layout { grid-template-columns: 1fr; gap: 21px; }
  .payment-qr, .qr-placeholder { width: min(250px, 78vw); height: min(250px, 78vw); margin: 0 auto; }
  .exact-amount-block strong { font-size: 34px; }
}

@media (max-width: 400px) {
  .topbar-inner { width: calc(100% - 20px); }
  .brand-meta { display: none; }
  .service-state { font-size: 12px; }
  .segment-control, .payment-options { grid-template-columns: 1fr; }
}
