:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #1c1f2e;
  --muted: #646a85;
  --border: #e3e5f0;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --ok: #0f8a5f;
  --ok-bg: #e5f6ee;
  --fail: #c2410c;
  --fail-bg: #fdeee6;
  --wait: #a16207;
  --wait-bg: #fdf6dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 23, 40, .05), 0 8px 24px rgba(20, 23, 40, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--brand); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }

.test-banner {
  background: #1c1f2e; color: #f3f4ff; text-align: center;
  font-size: .85rem; padding: .5rem 1rem;
}
.test-banner strong { color: #fcd34d; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1180px; margin: 0 auto; padding: 1.1rem 1.25rem;
}
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; }
.merchant-chip { font-size: .88rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: .35rem .75rem; border-radius: 999px; }

.page { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem 2rem; }
.page.narrow { max-width: 920px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem 2rem; }

/* Checkout */
.checkout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 0;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.summary { padding: 2rem; background: linear-gradient(160deg, #eef0ff, #f8f8ff); border-right: 1px solid var(--border); }
.summary h1 { font-size: 2.4rem; letter-spacing: -.02em; margin: .25rem 0 .5rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--brand); margin: 0; }
.facts { margin: 1.5rem 0 0; display: grid; gap: .65rem; }
.facts div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--border); padding-bottom: .5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; word-break: break-all; }

.card-form { padding: 2rem; }
.card-form h2 { font-size: 1.15rem; margin-bottom: 1rem; }
.field { display: grid; gap: .3rem; margin-bottom: .9rem; font-size: .88rem; color: var(--muted); }
.field input {
  font: inherit; font-size: 1.02rem; color: var(--text);
  width: 100%; min-width: 0; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfbfe;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); background: #fff; }
#card_number { letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .9rem; }
.alert { background: var(--fail-bg); color: var(--fail); border-radius: 10px; padding: .75rem .9rem; margin-bottom: 1rem; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 700; border: 0; border-radius: 10px; padding: .85rem 1.3rem;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-block { width: 100%; margin-top: .4rem; }
.btn-link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; padding: .6rem; }
.btn-link:hover { color: var(--text); }
form.inline { display: inline; }

.test-cards { margin-top: 1.5rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 2rem; }
.test-cards h3 { font-size: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 196px), 1fr)); gap: .75rem; margin-top: .75rem; }
.test-card {
  display: grid; gap: .25rem; text-align: left; cursor: pointer; font: inherit;
  border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; background: #fbfbfe;
  transition: border-color .15s, box-shadow .15s;
}
.test-card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .1); }
.test-card { justify-items: start; min-width: 0; }
.test-card .num { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: .86rem; white-space: nowrap; }
.test-card .label { font-size: .82rem; }
.test-card.ok .label { color: var(--ok); }
.test-card.fail .label { color: var(--fail); }

/* Result */
.result { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem 2rem; text-align: center; display: grid; justify-items: center; gap: .35rem; }
.result-icon { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; margin-bottom: .5rem; }
.result.ok .result-icon { background: var(--ok-bg); color: var(--ok); }
.result.fail .result-icon { background: var(--fail-bg); color: var(--fail); }
.result .amount { font-size: 1.8rem; font-weight: 800; margin: .25rem 0; }
.result p { margin: .1rem 0; }
.result .btn { margin: 1.25rem 0 .5rem; }

/* Dashboard */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; margin: .5rem 0 1.25rem; flex-wrap: wrap; }
.dash-head p { max-width: 640px; margin: 0; }
.stats { display: flex; gap: .75rem; flex-wrap: wrap; }
.stats div { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: .6rem 1rem; display: grid; min-width: 96px; }
.stats b { font-size: 1.15rem; }
.stats span { font-size: .78rem; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.payments { width: 100%; border-collapse: collapse; font-size: .9rem; }
.payments th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.payments td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.payments tr:last-child td { border-bottom: 0; }
.link-cell a { word-break: break-all; font-size: .85rem; }
button.copy { margin-left: .35rem; font: inherit; font-size: .75rem; border: 1px solid var(--border); background: #fbfbfe; border-radius: 6px; padding: .1rem .45rem; cursor: pointer; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.fail { background: var(--fail-bg); color: var(--fail); }
.pill.wait { background: var(--wait-bg); color: var(--wait); }
.hook.ok { color: var(--ok); font-weight: 600; }
.hook.fail { color: var(--fail); font-weight: 600; }
.empty { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem; text-align: center; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.5rem; }
.panel h3 { font-size: 1rem; }
.panel pre { background: #1c1f2e; color: #e6e8f5; border-radius: 10px; padding: 1rem; overflow-x: auto; font-size: .8rem; line-height: 1.45; }
table.mini { border-collapse: collapse; font-size: .88rem; }
table.mini td { padding: .3rem .9rem .3rem 0; }

@media (max-width: 760px) {
  .checkout { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 0 1rem 1.5rem; }
  .topbar { padding: 1rem; }
  .summary { border-right: 0; border-bottom: 1px solid var(--border); padding: 1.5rem; }
  .card-form, .test-cards { padding: 1.5rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .summary h1 { font-size: 2rem; }
}
