:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --reserved: #f59e0b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; }
.brand .subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white; display: grid; place-items: center; font-weight: 700;
}
.status { display: flex; gap: 8px; align-items: center; }
.pill {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
.pill.pill-demo { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill.pill-live { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pill.pill-muted {
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
  font-weight: 500;
}
.pill select { background: transparent; border: 0; font-size: 12px; font-weight: 600; color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 24px 28px 80px; }

.hero {
  background: var(--panel); padding: 22px; border-radius: 12px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  margin-bottom: 18px;
}
.hero h2 { margin: 0 0 6px; font-size: 17px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; max-width: 60ch; }
.hero-controls { display: flex; flex-direction: column; gap: 8px; min-width: 240px; }

button {
  cursor: pointer; font: inherit; padding: 10px 14px;
  background: var(--primary); color: white;
  border: 0; border-radius: 8px; font-weight: 600;
  transition: filter .15s ease, transform .05s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.scenario {
  background: var(--panel); border-radius: 12px; padding: 18px 22px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.scenario h3 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.scenario ol { margin: 0; padding-left: 22px; color: var(--ink); }
.scenario li { padding: 4px 0; color: var(--muted); }
.scenario li.active { color: var(--ink); font-weight: 600; }
.scenario li.done { color: var(--success); }
.scenario li.done::marker { color: var(--success); }
body[data-variant="desktop"] .scenario li.variant-pro { text-decoration: line-through; opacity: .5; }

.live-reference {
  background: var(--panel); border-radius: 12px; padding: 18px 22px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.live-reference details {
  border: 1px solid var(--border); border-radius: 8px; margin-top: 10px;
  background: #fafafa; overflow: hidden;
}
.live-reference summary {
  cursor: pointer; padding: 10px 12px; font-weight: 700; font-size: 13px;
  color: var(--ink); background: #f9fafb;
}
.live-reference pre {
  margin: 0; padding: 12px; border-top: 1px solid var(--border);
  overflow: auto; max-height: 360px; background: white;
}
.live-reference code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  white-space: pre;
}
.replay-panel {
  display: grid; gap: 10px; padding: 12px; border-top: 1px solid var(--border);
  background: white;
}
.replay-controls {
  display: flex; align-items: end; gap: 10px; flex-wrap: wrap;
}
.replay-controls-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end;
}
.replay-controls label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted);
}
.replay-controls input {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fafafa; min-width: 0;
}
.replay-panel .result {
  max-height: 280px; overflow: auto;
}
.service-list {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
}
.service-list div {
  display: flex; flex-direction: column; gap: 5px;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  background: #fafafa; min-width: 0;
}
.service-list strong { font-size: 13px; color: var(--ink); }
.service-list span {
  color: var(--muted); font-family: ui-monospace, Menlo, monospace;
  font-size: 11px; overflow-wrap: anywhere;
}
@media (max-width: 1000px) {
  .replay-controls-grid { grid-template-columns: 1fr; }
  .service-list { grid-template-columns: 1fr; }
}

.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px; margin-bottom: 18px;
}
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border-radius: 12px; padding: 18px 20px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.card h3 { margin: 0; font-size: 16px; }
.card .hint { margin: 0; color: var(--muted); font-size: 13px; }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.card input,
.card textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fafafa;
}
.card textarea { min-height: 108px; resize: vertical; font-family: ui-monospace, Menlo, monospace; }
.card input:focus,
.card textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; }
.result {
  font-size: 12px; padding: 8px 10px; border-radius: 6px; min-height: 16px;
  background: var(--bg); color: var(--muted); font-family: ui-monospace, Menlo, monospace;
  white-space: pre-wrap; word-break: break-all;
}
.result.ok { background: #ecfdf5; color: #065f46; }
.result.err { background: #fef2f2; color: #991b1b; }

.qty-display { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.qty-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; background: #eef2ff; border-radius: 8px;
}
.qty-tile.reserved { background: #fff7ed; }
.qty-tile.sellable { background: #ecfdf5; }
.qty-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; font-weight: 600; }
.qty-value { font-size: 28px; font-weight: 700; color: var(--ink); }
.qty-tile.reserved .qty-value { color: var(--reserved); }
.qty-tile.sellable .qty-value { color: var(--success); }

.live-checks {
  background: var(--panel); border-radius: 12px; padding: 18px 22px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.section-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
.section-head h3 { margin: 0 0 4px; font-size: 16px; }
.section-head .hint { margin: 0; color: var(--muted); font-size: 13px; }
.check-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
.check-card { box-shadow: none; border: 1px solid var(--border); }
.check-card input {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fafafa;
}
@media (max-width: 1000px) {
  .check-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; }
}

.log-section {
  background: var(--panel); border-radius: 12px; padding: 16px 22px;
  box-shadow: var(--shadow);
}
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.log-header h3 { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
#log { display: flex; flex-direction: column-reverse; gap: 6px; max-height: 360px; overflow: auto; }
.log-entry {
  display: grid; grid-template-columns: 60px 1fr 60px;
  gap: 10px; padding: 8px 10px; background: var(--bg); border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; align-items: center;
}
.log-entry .verb { font-weight: 700; }
.log-entry .verb.GET { color: #2563eb; }
.log-entry .verb.POST { color: #059669; }
.log-entry .verb.DELETE { color: var(--danger); }
.log-entry .verb.PUT { color: #d97706; }
.log-entry .path { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.log-entry .status { font-weight: 700; text-align: right; }
.log-entry .status.s2 { color: var(--success); }
.log-entry .status.s4, .log-entry .status.s5 { color: var(--danger); }
.log-entry-details {
  grid-column: 1 / -1; margin-top: 6px; padding: 8px 10px; background: white;
  border-radius: 4px; border: 1px solid var(--border);
  white-space: pre-wrap; word-break: break-all; color: var(--muted); display: none;
}
.log-entry.open .log-entry-details { display: block; }

footer {
  text-align: center; padding: 24px; color: var(--muted); font-size: 12px;
}
footer a { color: var(--primary); text-decoration: none; }
