:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1a1d29;
  --muted: #5a6072;
  --border: #dde1ea;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --primary-text: #ffffff;
  --focus: #f59e0b;
  --ok-bg: #dcfce7; --ok-text: #14532d;
  --info-bg: #e0e7ff; --info-text: #312e81;
  --warn-bg: #fef3c7; --warn-text: #78350f;
  --bad-bg: #fee2e2; --bad-text: #7f1d1d;
  --neutral-bg: #eceff4; --neutral-text: #374151;
  --code-bg: #0f172a; --code-text: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --surface: #171a23; --text: #e7e9ee; --muted: #a3a9b8; --border: #2a2f3c;
    --primary: #818cf8; --primary-hover: #a5b4fc; --primary-text: #0b0d14;
    --ok-bg: #133821; --ok-text: #bbf7d0; --info-bg: #1e2250; --info-text: #c7d2fe;
    --warn-bg: #3b2a0a; --warn-text: #fde68a; --bad-bg: #3f1414; --bad-text: #fecaca;
    --neutral-bg: #262b36; --neutral-text: #d1d5db; --code-bg: #0a0c12;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1rem; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .88em; }
code { background: var(--neutral-bg); color: var(--neutral-text); padding: .08em .35em; border-radius: 5px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.wrap-break, .wrap { overflow-wrap: anywhere; }
code.wrap { word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-text); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 .3rem; }
h2 { font-size: 1.2rem; margin: 0; }
h3, .h3 { font-size: 1.02rem; margin: 1.2rem 0 .5rem; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; min-height: 60px; padding-top: .5rem; padding-bottom: .5rem; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand-mark { color: var(--primary); }
.nav { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; align-items: center; }
.nav a, .linkbtn { display: inline-block; padding: .4rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; font: inherit; font-size: .95rem; }
.nav a:hover, .linkbtn:hover { background: var(--neutral-bg); color: var(--text); }
.nav a[aria-current="page"] { background: var(--info-bg); color: var(--info-text); font-weight: 600; }
.linkbtn { background: none; border: 0; cursor: pointer; }
.inline { display: inline; margin: 0; }
.footer { padding-top: 1.5rem; padding-bottom: 2rem; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.page-head p { margin: 0; max-width: 70ch; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.step { border-left: 5px solid var(--border); }
.step.is-active { border-left-color: var(--primary); }
.step.is-done { border-left-color: #16a34a; }
.step-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.step-num { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--neutral-bg); color: var(--neutral-text); }
.step.is-active .step-num { background: var(--primary); color: var(--primary-text); }
.step.is-done .step-num { background: var(--ok-bg); color: var(--ok-text); }

.stepper { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: .4rem; padding: 0; margin: 0 0 1.2rem; }
.stepper a { display: flex; align-items: center; gap: .45rem; padding: .5rem .6rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--muted); font-size: .85rem; line-height: 1.2; height: 100%; }
.stepper-num { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--neutral-bg); color: var(--neutral-text); }
.stepper-item.is-done a { color: var(--text); }
.stepper-item.is-done .stepper-num { background: var(--ok-bg); color: var(--ok-text); }
.stepper-item.is-active a { border-color: var(--primary); color: var(--text); font-weight: 600; }
.stepper-item.is-active .stepper-num { background: var(--primary); color: var(--primary-text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .95rem; padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--neutral-bg); color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--bad-text); border-color: var(--bad-bg); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; }
.btn.huge { font-size: 1.15rem; padding: .9rem 1.6rem; min-height: 56px; background: #15803d; border-color: #15803d; color: #fff; }
.btn.huge:hover { background: #166534; color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

form { margin: .6rem 0; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row form { margin: 0; }
.grow { flex: 1 1 240px; min-width: 0; }
.stack > * + * { margin-top: .8rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem 1rem; align-items: end; }
.span2 { grid-column: span 2; }
@media (max-width: 480px) { .span2 { grid-column: auto; } }
.actions { display: flex; align-items: flex-end; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
.field label .muted { font-weight: 400; }
input[type=text], input:not([type]), input[type=email], input[type=search], input[type=number], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; min-height: 42px;
}
textarea { min-height: 12rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 1rem 0; }
.kv dt { font-weight: 600; color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: .4rem; } }

.chip { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--info-bg); color: var(--info-text); margin: .1rem 0; font-family: ui-monospace, Menlo, Consolas, monospace; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; letter-spacing: .01em; vertical-align: middle; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-bad { background: var(--bad-bg); color: var(--bad-text); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-text); }

.flash, .msg { border-radius: 10px; padding: .65rem .9rem; margin: .7rem 0; }
.flash { font-weight: 600; margin-bottom: 1rem; }
.flash-info, .msg-info { background: var(--info-bg); color: var(--info-text); }
.flash-warning, .msg-warning { background: var(--warn-bg); color: var(--warn-text); }
.flash-error, .msg-error { background: var(--bad-bg); color: var(--bad-text); }
.messages { list-style: none; padding: 0; margin: .8rem 0; }
.msg code { background: rgba(0,0,0,.08); color: inherit; }
.msg-type { font-weight: 800; font-size: .75rem; letter-spacing: .05em; }
.messages .muted { color: inherit; opacity: .8; }
.warning-note { background: var(--warn-bg); color: var(--warn-text); padding: .6rem .85rem; border-radius: 10px; }
.empty { color: var(--muted); font-style: italic; }
.selected { background: var(--ok-bg); color: var(--ok-text); padding: .55rem .85rem; border-radius: 10px; }
.selected code { background: rgba(0,0,0,.08); color: inherit; }

.products { margin-top: 1rem; }
.product { border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem 1rem; margin: 0 0 .8rem; min-width: 0; }
.product-title { font-weight: 700; padding: 0 .3rem; }
.product-body { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.product-body p { margin: .2rem 0 .5rem; }
.thumb { width: 88px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--neutral-bg); }
.variants, .webhook-list { list-style: none; padding: 0; margin: 0 0 .6rem; }
.variants li, .option { display: flex; align-items: center; gap: .55rem; padding: .35rem 0; border-top: 1px dashed var(--border); }
.variants li:first-child { border-top: 0; }
.variants label, .option label { display: flex; flex-wrap: wrap; gap: .25rem .7rem; align-items: center; cursor: pointer; }
input[type=radio] { width: 1.15rem; height: 1.15rem; accent-color: var(--primary); flex: none; }
.options { border: 1px solid var(--border); border-radius: 10px; padding: .5rem 1rem .8rem; margin: 0 0 .8rem; }
.options legend { font-weight: 600; padding: 0 .3rem; }
.webhook-list li { padding: .45rem 0; border-top: 1px solid var(--border); }

table { border-collapse: collapse; width: 100%; margin: .7rem 0; font-size: .92rem; }
.lines th, .lines td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.lines td:nth-child(n+2):not(:last-child), .lines th:nth-child(n+2):not(:last-child) { white-space: nowrap; }
.card:has(> .lines), .card { overflow-x: auto; }
.totals { max-width: 340px; margin-left: auto; }
.totals th { text-align: left; font-weight: 500; color: var(--muted); padding: .25rem .5rem; }
.totals td { text-align: right; padding: .25rem .5rem; font-variant-numeric: tabular-nums; }
.totals .grand th, .totals .grand td { font-weight: 800; color: var(--text); border-top: 2px solid var(--border); padding-top: .45rem; }

.log { margin-top: 1rem; }
.log-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .4rem; }
.exchange { border: 1px solid var(--border); border-radius: 10px; margin: .45rem 0; background: var(--bg); }
.exchange > summary { cursor: pointer; padding: .55rem .8rem; list-style: revert; overflow-wrap: anywhere; }
.exchange[open] > summary { border-bottom: 1px solid var(--border); }
.exchange-body { padding: .3rem .8rem .8rem; }
.exchange-body h4 { margin: .7rem 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
pre.code { background: var(--code-bg); color: var(--code-text); padding: .75rem .9rem; border-radius: 8px; overflow: auto; max-height: 520px; white-space: pre-wrap; word-break: break-all; margin: 0; }

@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .card { padding: 1rem; }
  .stepper { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.option-picker { border-top: 1px dashed var(--border); margin-top: .7rem; padding-top: .6rem; }
.option-picker .grid { gap: .5rem .8rem; margin-bottom: .6rem; }
.option-picker .row { gap: .5rem; }
