:root {
  --ink: #1e2925;
  --muted: #6f756d;
  --paper: #f3f0e7;
  --card: #fffdf7;
  --line: #d7d2c5;
  --green: #0d684e;
  --green-soft: #d9ebdf;
  --orange: #e66a32;
  --red: #b94432;
  --shadow: 0 24px 70px rgba(42, 52, 46, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 4%, rgba(230, 106, 50, 0.16), transparent 28rem),
    linear-gradient(135deg, #ede9de, var(--paper) 52%, #e5ebe3);
  font-family: "Avenir Next", "Gill Sans", sans-serif;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

main { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 70px; }

.masthead { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(44px, 7vw, 88px); font-weight: 400; letter-spacing: -0.07em; line-height: 0.76; }
h1 em { color: var(--orange); font-weight: 400; }

.connection-card { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 253, 247, 0.7); }
.connection-card div { display: grid; }
.connection-card small { color: var(--muted); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #2f9b65; box-shadow: 0 0 0 6px rgba(47, 155, 101, 0.14); }

.layout { display: grid; grid-template-columns: minmax(280px, 0.78fr) minmax(520px, 1.45fr); gap: 18px; }
.setup-panel, .workbench, .activity-column, .webhook-column { position: relative; border: 1px solid rgba(197, 192, 179, 0.85); border-radius: 24px; background: rgba(255, 253, 247, 0.86); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.setup-panel, .workbench { padding: 28px; }

.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.section-heading > span:first-child { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--ink); border-radius: 50%; font-family: Georgia, serif; font-size: 12px; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 27px; font-weight: 400; letter-spacing: -0.03em; }

label { display: grid; gap: 7px; margin-bottom: 16px; color: #464d47; font-size: 12px; font-weight: 800; letter-spacing: 0.055em; text-transform: uppercase; }
label small, #publicUrlHint { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0; line-height: 1.35; text-transform: none; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; outline: none; background: #fffefb; color: var(--ink); padding: 12px 13px; font: 500 14px/1.2 "Avenir Next", sans-serif; transition: border-color 160ms, box-shadow 160ms; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(13, 104, 78, 0.1); }

.secret-field, .order-id-field { display: flex; gap: 7px; }
.secret-field input, .order-id-field input { flex: 1; }
.text-button { border: 0; background: transparent; color: var(--green); cursor: pointer; font: 800 12px "Avenir Next", sans-serif; }
.push { margin-left: auto; }

.profile-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0; }
.profile { display: grid; gap: 3px; padding: 12px; text-align: left; border: 1px solid var(--line); border-radius: 13px; background: transparent; color: var(--ink); cursor: pointer; }
.profile span { font-weight: 800; }
.profile small { color: var(--muted); }
.profile.active { border-color: var(--green); background: var(--green-soft); }

.merchant-identity {
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid #b9c8bb;
  border-radius: 17px;
  background: linear-gradient(135deg, #f1f6ef, #fffdf7);
}
.identity-intro { display: grid; gap: 3px; }
.identity-intro strong { font-family: Georgia, serif; font-size: 18px; font-weight: 400; }
.identity-intro small { color: var(--muted); }
.merchant-identity .profile-switch { margin: 15px 0; }
.identity-fields { display: grid; grid-template-columns: 1fr; gap: 12px; }
.identity-fields label { margin-bottom: 0; }

.webhook-box { padding: 14px; border: 1px dashed #9da99e; border-radius: 14px; background: #eef3ec; }
.webhook-box span { display: block; margin-bottom: 7px; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.webhook-box code { display: block; overflow-wrap: anywhere; font: 11px/1.5 ui-monospace, monospace; }
.webhook-box button { margin-top: 8px; padding: 0; }

.order-grid { display: grid; grid-template-columns: 1.4fr 0.7fr 0.5fr; gap: 0 12px; }
.order-grid .wide { grid-column: span 2; }
.order-id-field button { width: 50px; border: 0; border-radius: 11px; background: var(--ink); color: white; cursor: pointer; font-weight: 800; }

.primary-actions { display: flex; gap: 10px; margin: 5px 0 22px; }
.button { border: 1px solid var(--ink); border-radius: 999px; padding: 13px 20px; cursor: pointer; font-weight: 800; }
.button.primary { background: var(--ink); color: white; }
.button.ghost { background: transparent; color: var(--ink); }
.button:disabled { cursor: not-allowed; opacity: 0.4; }

.flow-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 8px; border-radius: 17px; background: #e9e5da; }
.flow-strip button { min-height: 76px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; font: 700 12px/1.25 "Avenir Next", sans-serif; }
.flow-strip button:hover { background: var(--card); }
.flow-strip span { display: grid; place-items: center; width: 24px; height: 24px; margin: 0 auto 6px; border-radius: 50%; background: var(--card); font-family: Georgia, serif; }

.status-card { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 20px; border-radius: 17px; background: var(--green); color: white; }
.status-card div { display: grid; gap: 4px; }
.status-card small { opacity: 0.72; text-transform: uppercase; }
.status-card strong { font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
.poll-control { display: flex; align-items: center; gap: 8px; margin: 0; color: white; }
.poll-control input { width: auto; }

.refund-row { display: grid; grid-template-columns: minmax(170px, 0.55fr) 1fr; gap: 18px; align-items: end; margin-top: 18px; }
.refund-row label { margin: 0; }
.refund-row p { margin: 0 0 4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.observability { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 18px; margin-top: 18px; }
.activity-column, .webhook-column { min-height: 320px; padding: 28px; }
.counter { margin-left: auto; min-width: 28px; padding: 5px 8px; border-radius: 999px; background: var(--orange); color: white; text-align: center; }
.empty-state { display: grid; min-height: 210px; place-items: center; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); font-family: Georgia, serif; text-align: center; }

.log-entry { margin-bottom: 9px; border: 1px solid var(--line); border-radius: 13px; background: #fffefb; overflow: hidden; }
.log-entry summary { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 12px; cursor: pointer; list-style: none; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-entry .method { padding: 4px 7px; border-radius: 6px; background: var(--ink); color: white; font: 800 10px ui-monospace, monospace; }
.log-entry .time, .log-entry .duration { color: var(--muted); font-size: 11px; }
.log-entry .status { color: var(--green); font-weight: 800; }
.log-entry.error .status { color: var(--red); }
.log-entry pre { max-height: 360px; margin: 0; padding: 15px; overflow: auto; border-top: 1px solid var(--line); background: #202a26; color: #e5f2e9; font: 11px/1.55 ui-monospace, monospace; }

#toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(20px); opacity: 0; z-index: 5; padding: 12px 17px; border-radius: 999px; background: var(--ink); color: white; box-shadow: var(--shadow); transition: 180ms ease; }
#toast.visible { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  main { width: min(100% - 22px, 720px); padding-top: 22px; }
  .masthead { align-items: center; }
  .layout, .observability { grid-template-columns: 1fr; }
  .order-grid { grid-template-columns: 1fr 1fr; }
  .order-grid .wide { grid-column: span 2; }
}

@media (max-width: 560px) {
  .connection-card { display: none; }
  .setup-panel, .workbench, .activity-column, .webhook-column { padding: 20px; border-radius: 18px; }
  .order-grid { grid-template-columns: 1fr; }
  .order-grid .wide { grid-column: auto; }
  .flow-strip { grid-template-columns: 1fr 1fr; }
  .refund-row { grid-template-columns: 1fr; }
  .status-card { align-items: flex-start; gap: 14px; flex-direction: column; }
  .primary-actions { flex-direction: column; }
  .identity-fields { grid-template-columns: 1fr; }
}
