* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { --border: #e3e5e8; --muted: #666; --bg: #f5f6f8; --accent: #635bff; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: #1a1a1a; }
a { color: #3b33d6; }
code { background: #f0f1f4; padding: 1px 4px; border-radius: 3px; font-size: 0.85em; }
h1 { margin: 8px 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; }
h4 { margin: 12px 0 4px; font-size: 0.85rem; }
h5 { margin: 8px 0 2px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
pre { background: #111; color: #9fe39f; padding: 10px; border-radius: 6px; overflow: auto; max-height: 360px; font-size: 0.78rem; white-space: pre-wrap; word-break: break-word; margin: 4px 0; }

/* ---- chrome ---- */
.banner { background: #6b7280; color: #fff; text-align: center; padding: 8px; font-weight: 600; font-size: 0.9rem; }
.banner.test { background: #b45309; }
.banner.live { background: #b91c1c; }
nav { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; background: #fff; border-bottom: 1px solid var(--border); padding: 6px; }
nav a { padding: 6px 14px; border-radius: 6px; color: #333; text-decoration: none; font-weight: 500; }
nav a.active { background: #eef0ff; color: #3b33d6; }
main { max-width: 680px; margin: 0 auto; padding: 16px 16px 64px; }
main.wide { max-width: 1400px; }
.card { background: #fff; border-radius: 10px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }
.card h2 { margin-top: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 0.85rem; }
.status { font-weight: 600; min-height: 1.2em; }
.status.error { color: #b91c1c; }
.status.ok { color: #047857; }
.disabled { opacity: 0.6; }

button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 12px 18px; font-size: 1rem; cursor: pointer; margin-top: 14px; width: 100%; }
button:disabled { opacity: 0.5; cursor: default; }
button.small { width: auto; padding: 5px 10px; font-size: 0.8rem; margin: 0; background: #4b5563; }
button.danger { background: #b91c1c; }
input[type=search], input[type=number], select { font: inherit; padding: 6px 8px; border: 1px solid #cfd3d8; border-radius: 6px; background: #fff; }
label.check { font-size: 0.85rem; display: flex; gap: 4px; align-items: center; }

/* ---- checkout ---- */
.checkout-grid { display: grid; grid-template-columns: minmax(0, 620px) minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.amount-row { display: flex; gap: 8px; }
.amount-row input { font-size: 1.4rem; width: 9em; }
.amount-row select { font-size: 1.1rem; }
.presets { display: flex; gap: 6px; margin-top: 10px; }
.chip { width: auto; margin: 0; padding: 5px 12px; font-size: 0.85rem; background: #eef0ff; color: #3b33d6; border-radius: 999px; }
.chip.on { background: var(--accent); color: #fff; }
.big-total { font-size: 1.2rem; margin: 10px 0 0; }
#shop-pay-button { min-height: 48px; }

.feed { list-style: none; padding: 0; margin: 0; font-size: 0.83rem; }
.feed li { border-left: 3px solid #ccc; padding: 6px 0 6px 10px; margin-bottom: 6px; }
.feed li a { color: inherit; text-decoration: none; display: block; }
.feed-head { display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.feed-head .ms { margin-left: auto; }
.explain { color: #374151; font-size: 0.82rem; margin-top: 3px; line-height: 1.35; }

/* ---- shared badges ---- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.03em; vertical-align: middle; white-space: nowrap; }
.badge.stripe { background: #635bff; }
.badge.paypal { background: #003087; }
.badge.shopify { background: #5a31f4; }
.dir { font-size: 0.7rem; padding: 1px 6px; border-radius: 4px; background: #eee; color: #333; white-space: nowrap; }
.dir.browser { background: #fff3cd; }
.dir.server { background: #e2e8f0; }
.dir.outbound { background: #d1fae5; }
.dir.inbound { background: #fde2e4; }
li.browser, .step.browser, .event.browser { border-color: #f0c040 !important; }
li.server, .step.server, .event.server { border-color: #94a3b8 !important; }
li.outbound, .step.outbound, .event.outbound { border-color: #10b981 !important; }
li.inbound, .step.inbound, .event.inbound { border-color: #e11d48 !important; }
.code { font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.code.good { background: #d1fae5; color: #065f46; }
.code.bad { background: #fde2e4; color: #9b1c1c; }
.ms, .time { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.url { font-family: ui-monospace, monospace; font-size: 0.78rem; word-break: break-all; background: #f0f1f4; padding: 4px 6px; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.8rem; color: var(--muted); margin-bottom: 12px; }
.live { color: #047857; font-size: 0.8rem; font-weight: 600; }
.live.off { color: #999; }

/* ---- toolbars ---- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.segmented { display: flex; gap: 2px; background: #e3e5e8; border-radius: 6px; padding: 2px; }
.seg { width: auto; margin: 0; padding: 4px 12px; font-size: 0.8rem; background: transparent; color: #333; text-transform: capitalize; }
.seg.on { background: #fff; color: #111; }

/* ---- flows (inspector) ---- */
.inspector { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.flows { display: flex; flex-direction: column; gap: 6px; max-height: 80vh; overflow: auto; }
.flow { display: flex; gap: 8px; background: #fff; border-radius: 8px; padding: 10px; cursor: pointer; border: 2px solid transparent; font-size: 0.85rem; }
.flow.selected { border-color: var(--accent); }
.flow.failed { box-shadow: inset 4px 0 0 #b91c1c; }
.meta { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.detail { min-width: 0; overflow-x: auto; }
.columns { display: grid; gap: 16px; }
.columns.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.column { background: #fff; border-radius: 10px; padding: 14px; min-width: 0; border: 1px solid var(--border); }
.column h2 { font-size: 1rem; margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 6px; }
.stat { background: var(--bg); border-radius: 6px; padding: 6px; text-align: center; }
.stat .value { font-weight: 700; }
.stat .label { font-size: 0.65rem; color: var(--muted); }
.step { border-left: 3px solid #ccc; margin: 8px 0; padding-left: 8px; }
.step summary, .event summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.82rem; padding: 4px 0; }
.step summary .explain, .event summary .explain { flex-basis: 100%; }
.step .offset { font-variant-numeric: tabular-nums; color: #888; font-size: 0.72rem; width: 64px; }
.step .label, .event .label { font-family: ui-monospace, monospace; font-weight: 600; background: none; }
.step-body { padding-bottom: 8px; }

/* ---- events ---- */
.events { display: flex; flex-direction: column; gap: 4px; }
.event { background: #fff; border-left: 4px solid #ccc; border-radius: 6px; padding: 6px 12px; }
.event .flow-link { margin-left: auto; font-size: 0.78rem; }

/* ---- logs ---- */
.logs { background: #0b0f14; color: #d1d5db; border-radius: 8px; padding: 10px; font-family: ui-monospace, monospace; font-size: 0.78rem; height: 70vh; overflow: auto; }
.log { display: flex; gap: 10px; padding: 2px 0; border-bottom: 1px solid #1f2937; align-items: baseline; }
.log .time { color: #6b7280; }
.log .lvl { width: 46px; font-weight: 700; flex-shrink: 0; }
.lvl.debug { color: #6b7280; } .lvl.info { color: #60a5fa; } .lvl.warn { color: #fbbf24; } .lvl.error { color: #f87171; }
.log .msg { color: #f9fafb; }
.log .ctx { color: #9ca3af; word-break: break-all; }
.log .trace { color: #a78bfa; margin-left: auto; white-space: nowrap; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; }
table.matrix { border-collapse: collapse; font-size: 0.85rem; width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid #eee; padding: 8px; text-align: left; vertical-align: top; }
.matrix tbody th { width: 170px; color: #444; }
.matrix td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #e5e7eb; }
.pill.succeeded { background: #d1fae5; color: #065f46; }
.pill.failed { background: #fde2e4; color: #9b1c1c; }
.pill.processing { background: #fef3c7; color: #92400e; }
.pill.refunded { background: #e0e7ff; color: #3730a3; }

/* ---- compare ---- */
.money-shapes { display: flex; flex-wrap: wrap; gap: 16px; margin: 14px 0; font-size: 0.9rem; }
.money-shapes > div { display: flex; gap: 6px; align-items: center; }

@media (max-width: 1000px) {
  .checkout-grid, .inspector, .columns.three { grid-template-columns: 1fr; }
  .sticky { position: static; max-height: none; }
}

/* ---- admin ---- */
.who { font-size: 0.9rem; font-weight: 400; color: var(--muted); margin-left: 12px; }
.card.narrow { max-width: 420px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; }
.stack input { font: inherit; padding: 8px; border: 1px solid #cfd3d8; border-radius: 6px; }
.glossary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; font-size: 0.85rem; }
.glossary strong { display: block; margin-bottom: 2px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
div.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
button.small.primary { background: var(--accent); }
button.ghost { background: #e5e7eb; color: #111; }
dialog { border: 0; border-radius: 12px; padding: 22px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog h2 { margin: 0; font-size: 1.1rem; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.warning { background: #fde2e4; color: #9b1c1c; padding: 8px 10px; border-radius: 6px; font-weight: 600; }
.wide-seg { display: inline-flex; }
.wide-seg .seg { padding: 6px 14px; text-transform: none; }
.pill.authorized { background: #fef3c7; color: #92400e; }
.pill.voided { background: #e5e7eb; color: #374151; }
.pill.partially_refunded { background: #e0e7ff; color: #3730a3; }

/* ---- card checkout ---- */
.field { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #cfd3d8; border-radius: 6px; }
.saved-line { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.card-option { display: flex; gap: 10px; align-items: center; border: 1px solid #cfd3d8; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.card-option.on { border-color: var(--accent); background: #f5f4ff; }
#save-wrap { margin-top: 12px; }
.forget { display: flex; gap: 8px; margin-top: 12px; }
.amount-row.compact input { font-size: 1rem; width: 6em; }
.amount-row.compact select { font-size: 0.9rem; }
.live-stats { grid-template-columns: repeat(5, 1fr); }
.verdict p { font-size: 1rem; margin: 4px 0 12px; }
h1 .hint { font-size: 0.9rem; font-weight: 400; }

/* ---- 3DS / abandonment ---- */
.pill.action_required { background: #fef3c7; color: #92400e; }
.pill.abandoned { background: #f3f4f6; color: #6b7280; }
.pill.expired { background: #fde2e4; color: #9b1c1c; }
.error-text { color: #b91c1c !important; }
.sweep-form { margin: 0 0 12px; font-size: 0.85rem; flex-wrap: wrap; }
.sweep-form input { width: 5em; }

/* ---- Link ---- */
#link-auth { margin-bottom: 4px; }
.link-toggle { margin-left: 8px; }
#express-checkout { min-height: 44px; }
#results { font-size: 0.8rem; }
#results th, #results td { padding: 6px 5px; }
.badge.affirm { background: #4a4af4; }
#affirm-section .amount-row { margin-bottom: 4px; }
