:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #68758a;
  --line: #e5eaf2;
  --blue: #1769ff;
  --blue-dark: #0756dd;
  --green: #16a56b;
  --red: #e73a50;
  --surface: #ffffff;
  --bg: #f2f5fa;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(23, 105, 255, .18), transparent 34rem),
    var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }

.checkout-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.checkout-card {
  width: min(100%, 430px);
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 22px 70px rgba(26, 45, 84, .14);
  overflow: hidden;
}

.brand-strip {
  height: 7px;
  background: linear-gradient(90deg, var(--blue), #59a8ff);
}

.checkout-main { padding: 24px; }

.secure-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.12rem;
  font-weight: 750;
}

.shield {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  border-radius: 50%;
  font-size: .86rem;
}

.channel-tag {
  padding: 6px 10px;
  color: #08764b;
  background: #e7f8f0;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: .88rem;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.lead {
  margin: 8px 0 24px;
  color: var(--muted);
  line-height: 1.65;
  font-size: .94rem;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 22px;
}

.amount-btn {
  min-height: 64px;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: #fbfcff;
  font-size: 1.16rem;
  font-weight: 750;
  transition: .16s ease;
}

.amount-btn:hover { border-color: #9ebeff; }
.amount-btn.selected {
  color: var(--blue);
  border-color: var(--blue);
  background: #edf4ff;
  box-shadow: 0 0 0 3px rgba(23, 105, 255, .1);
}

.primary-btn, .secondary-btn, .danger-btn {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  font-weight: 750;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, #2c85ff, var(--blue));
  box-shadow: 0 10px 24px rgba(23, 105, 255, .24);
}
.primary-btn:hover { background: var(--blue-dark); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.helper {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

.message {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.5;
}
.message.show { display: block; }
.message.error { color: #aa1f34; background: #fff0f2; }
.message.info { color: #1551a8; background: #edf5ff; }

.result {
  display: none;
  text-align: center;
  padding-top: 18px;
}
.result.show { display: block; }
.result img {
  width: 210px;
  height: 210px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}
.result-title { margin: 0 0 7px; font-size: 1.15rem; }
.result-text { margin: 0 0 16px; color: var(--muted); font-size: .88rem; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.link-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 12px;
  color: var(--muted);
  background: #f7f9fc;
}
.copy-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  color: var(--blue);
  background: #edf4ff;
  font-weight: 700;
}
.open-btn { display: grid; place-items: center; margin-top: 10px; text-decoration: none; }

.fine-print {
  padding: 15px 24px 20px;
  color: #8691a3;
  background: #fafbfc;
  border-top: 1px solid var(--line);
  font-size: .74rem;
  text-align: center;
}

.admin-shell { max-width: 1180px; margin: 0 auto; padding: 28px 18px 60px; }
.admin-workspace { padding-top: 24px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.admin-head h1 { font-size: 1.7rem; }
.head-actions { display: flex; gap: 8px; }
.admin-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-weight: 800; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: white; background: var(--blue); border-radius: 11px; }
.panel {
  padding: 22px;
  margin-bottom: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(35, 51, 82, .07);
}
.panel h2 { margin: 0 0 17px; font-size: 1.05rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 18px 20px; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 28px rgba(35,51,82,.055); }
.stat-card span { display: block; color: var(--muted); font-size: .82rem; }
.stat-card strong { display: block; margin-top: 7px; font-size: 1.6rem; line-height: 1; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 5px; }
.section-head p { margin: 0; color: var(--muted); font-size: .84rem; }
.section-kicker { margin-bottom: 5px !important; color: var(--blue) !important; font-weight: 750; }
.section-actions { display: flex; align-items: center; gap: 10px; }
.search-box { min-width: 255px; display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); background: #f7f9fc; border: 1px solid var(--line); border-radius: 11px; }
.search-box span { font-size: .78rem; }
.search-box input { min-width: 0; width: 100%; height: 42px; border: 0; outline: 0; background: transparent; }
.compact-btn { width: auto; min-height: 42px; padding: 0 18px; border-radius: 11px; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; color: var(--muted); background: #f0f3f8; font-size: 1.35rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: .82rem; font-weight: 650; }
.field input, .field select {
  width: 100%;
  min-height: 45px;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid #d8dfeb;
  border-radius: 11px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,255,.1); }
.input-prefix { display: flex; align-items: center; min-height: 45px; border: 1px solid #d8dfeb; border-radius: 11px; overflow: hidden; }
.input-prefix:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,255,.1); }
.input-prefix span { padding-left: 13px; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.input-prefix input { min-width: 0; border: 0; box-shadow: none !important; }
.form-section { padding: 18px; margin-top: 12px; background: #f8faff; border: 1px solid #ebeff6; border-radius: 14px; }
.form-section h3 { margin: 0 0 14px; font-size: .92rem; }
.api-template summary { cursor: pointer; font-weight: 800; font-size: .92rem; }
.api-template[open] summary { margin-bottom: 10px; }
.api-order-test { display: flex; align-items: end; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.api-order-test .select-box { min-width: 150px; }
.api-order-test p { width: 100%; margin: -3px 0 0; color: var(--muted); font-size: .78rem; }
.api-order-result { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; padding: 14px; border: 1px solid #cfe0ff; background: #eef5ff; border-radius: 12px; }
.api-order-result div { min-width: 0; }
.api-order-result span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 4px; }
.api-order-result strong { display: block; overflow-wrap: anywhere; }
.api-result-link { grid-column: 1 / -1; }
.api-result-link a { display: inline-block; max-width: calc(100% - 70px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; color: var(--primary); font-weight: 750; }
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 45px; font-size: .88rem; font-weight: 650; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 42px; height: 24px; padding: 3px; border-radius: 99px; background: #bcc5d3; transition: .18s; }
.switch::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: .18s; }
.switch-row input:checked + .switch { background: var(--blue); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.captcha-row { display: grid; grid-template-columns: 1fr 122px; gap: 8px; }
.captcha-button { height: 45px; padding: 0; overflow: hidden; border: 1px solid #d8dfeb; border-radius: 11px; background: white; }
.captcha-button img { width: 100%; height: 100%; object-fit: contain; }
.advanced-token { margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); }
.advanced-token summary { color: var(--muted); cursor: pointer; font-size: .84rem; }
.advanced-token form { margin-top: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions button { width: auto; padding: 0 22px; }
.secondary-btn { color: var(--blue); background: #edf4ff; }
.ghost-btn { padding: 8px 12px; border: 0; border-radius: 9px; color: var(--muted); background: #eef1f6; }
.text-btn { padding: 6px 9px; border: 0; color: var(--blue); background: transparent; font-size: .78rem; font-weight: 700; white-space: nowrap; }

.login-card { width: min(100%, 410px); margin: 10vh auto 0; padding: 28px; }
.login-card .primary-btn { margin-top: 14px; }

.merchant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.merchant-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  transition: .16s ease;
}
.merchant-card:hover { border-color: #bfd1f6; box-shadow: 0 12px 28px rgba(35,51,82,.07); }
.merchant-card.inactive { background: #fafbfc; opacity: .82; }
.merchant-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.merchant-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.merchant-avatar { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--blue); background: #eaf2ff; font-weight: 800; }
.merchant-identity h3 { margin: 0; font-size: 1rem; }
.merchant-identity p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.merchant-statuses { display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
.status-pill { padding: 5px 8px; border-radius: 99px; font-size: .7rem; font-weight: 750; white-space: nowrap; }
.status-pill.online, .status-pill.authorized { color: #08764b; background: #e7f8f0; }
.status-pill.offline { color: #68758a; background: #edf0f4; }
.status-pill.warning { color: #9b6100; background: #fff3d6; }
.merchant-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 17px 0 13px; }
.merchant-details div:first-child { grid-column: 1 / -1; }
.merchant-details span, .merchant-details strong { display: block; overflow-wrap: anywhere; }
.merchant-details span { color: var(--muted); font-size: .72rem; }
.merchant-details strong { margin-top: 4px; font-size: .82rem; }
.checkout-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 9px 10px; color: var(--muted); background: #f6f8fc; border-radius: 10px; }
.checkout-link b { color: var(--ink); font-size: .72rem; white-space: nowrap; }
.checkout-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.fixed-links { margin-top: 10px; padding: 10px; border: 1px solid #e8edf5; border-radius: 11px; }
.fixed-links > p { margin: 0 0 6px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.fixed-link-list { display: grid; gap: 4px; }
.fixed-link-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto auto; align-items: center; gap: 5px; min-width: 0; }
.fixed-link-row strong { color: var(--blue); font-size: .78rem; }
.fixed-link-row span { overflow: hidden; color: var(--muted); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.extra-checkout-links { display: grid; gap: 9px; margin-top: 10px; }
.extra-checkout-block { padding: 11px; border: 1px solid #cfe0ff; border-radius: 11px; background: #f7faff; }
.extra-checkout-block.inactive { opacity: .62; background: #f7f7f8; }
.extra-checkout-heading { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.extra-checkout-heading strong { font-size: .8rem; }
.extra-checkout-heading > span:not(.status-pill) { color: var(--muted); font-size: .72rem; }
.extra-checkout-heading .status-pill { margin-left: auto; }
.extra-checkout-url { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 5px; margin-top: 6px; }
.extra-checkout-url > span { overflow: hidden; color: var(--muted); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.extra-fixed-links { display: grid; gap: 3px; margin-top: 5px; }
.extra-fixed-links > div { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 5px; }
.extra-fixed-links strong { color: var(--blue); font-size: .75rem; }
.extra-fixed-links span { overflow: hidden; color: var(--muted); font-size: .71rem; text-overflow: ellipsis; white-space: nowrap; }
.checkout-link-manager-list { display: grid; gap: 10px; margin: 18px 0; }
.checkout-link-manager-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbff; }
.checkout-link-manager-row.inactive { opacity: .65; }
.checkout-link-manager-row > div:first-child { min-width: 0; }
.checkout-manager-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.checkout-manager-heading strong { font-size: .88rem; }
.checkout-manager-heading span { color: var(--muted); font-size: .74rem; }
.checkout-link-manager-row p { margin: 5px 0 3px; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.checkout-link-manager-row small { color: var(--muted); }
.checkout-manager-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.merchant-actions { display: flex; align-items: center; gap: 7px; margin-top: 14px; flex-wrap: wrap; }
.card-action { width: auto; min-height: 38px; padding: 0 12px; border-radius: 10px; font-size: .78rem; box-shadow: none; }
.state-action { margin-left: auto; color: var(--muted); }
.editor-panel { scroll-margin-top: 18px; }
.auth-note { margin-top: -7px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 650; }
.badge { padding: 4px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge.success { color: #08764b; background: #e7f8f0; }
.badge.failed { color: #aa1f34; background: #fff0f2; }
.badge.requesting { color: #855a00; background: #fff6d9; }
.badge.pending { color: #1558b0; background: #e9f2ff; }
.select-box { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; }
.select-box select { min-height: 38px; padding: 0 28px 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; }
.empty-state { margin: 16px 0 0; padding: 20px; color: var(--muted); background: #f8f9fc; border-radius: 12px; text-align: center; font-size: .85rem; }
.merchant-empty { grid-column: 1 / -1; margin: 0; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .checkout-shell { place-items: start center; padding: 10px; }
  .checkout-card { border-radius: 20px; }
  .checkout-main { padding: 20px; }
  .secure-row { margin-bottom: 21px; }
  .amount-btn { min-height: 58px; }
  .admin-shell { padding: 18px 12px 40px; }
  .admin-head h1 { font-size: 1.4rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 15px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .section-actions { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; }
  .compact-btn { width: 100%; }
  .merchant-grid { grid-template-columns: 1fr; }
  .merchant-card-head { align-items: flex-start; }
  .checkout-link { grid-template-columns: auto minmax(0, 1fr); }
  .checkout-link .text-btn { grid-column: 1 / -1; width: 100%; background: #edf4ff; border-radius: 8px; }
  .fixed-link-row { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .fixed-link-row .text-btn:last-child { display: none; }
  .extra-checkout-url { grid-template-columns: minmax(0, 1fr) auto; }
  .extra-checkout-url .text-btn:last-child { display: none; }
  .checkout-link-manager-row { align-items: stretch; flex-direction: column; }
  .checkout-manager-actions { flex-wrap: wrap; }
  .merchant-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .card-action { width: 100%; }
  .merchant-actions .primary-btn { grid-column: 1 / -1; }
  .state-action { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-section { padding: 14px; }
  .api-order-result { grid-template-columns: 1fr; }
  .api-result-link { grid-column: auto; }
  .order-head { align-items: flex-start; }
}
