:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #4f46e5;
  --brand-ink: #ffffff;

  --success: #16a34a;
  --success-bg: #ecfdf3;
  --success-border: #b7ebc8;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --neutral-bg: #f1f5f9;

  --wa-green: #008069;
  --wa-dark: #075e54;
  --wa-chat: #efeae2;
  --wa-out: #d9fdd3;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.15rem; letter-spacing: -.01em; }
h3 { font-size: .98rem; }
h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
code, .mono { font-family: var(--mono); font-size: .86em; }
[hidden] { display: none !important; }

/* ---------- banner & header ---------- */
.sim-banner {
  background: repeating-linear-gradient(-45deg, #fde047, #fde047 14px, #facc15 14px, #facc15 28px);
  color: #422006;
  text-align: center;
  padding: 7px 16px;
  font-size: .86rem;
}
.banner-sub { opacity: .8; margin-left: 6px; }
.banner-sub::before { content: "· "; }
.footer p { margin: 2px 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner, .container, .footer { max-width: 1240px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { min-width: 0; display: grid; gap: 2px; }
.brand-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-desc { font-size: .84rem; color: var(--muted); max-width: 720px; }
.brand-mark {
  flex: none; width: 40px; height: 40px; font-size: 1.15rem; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 800;
}
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-name span { color: var(--brand); }
.brand-tag {
  font-size: .75rem; font-weight: 600; color: var(--brand);
  background: #eef2ff; border: 1px solid #c7d2fe; padding: 2px 9px; border-radius: 999px;
}

.story { display: grid; gap: 14px; }
.story h2 { font-size: 1.3rem; }
.story-lead { color: #334155; max-width: 900px; }
.story-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.story-item { background: var(--error-bg); border: 1px solid var(--error-border); border-radius: 12px; padding: 14px; display: grid; gap: 6px; align-content: start; }
.story-item h3 { font-size: .92rem; color: #7f1d1d; }
.story-item p { font-size: .84rem; color: #475569; }
.story-solution { background: var(--success-bg); border: 1px solid var(--success-border); border-radius: 12px; padding: 16px; display: grid; gap: 8px; }
.story-solution h3 { color: #14532d; }
.story-solution p { color: #334155; font-size: .9rem; }
.story-benefits { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .88rem; color: #334155; }
.story-cta { font-weight: 600; color: var(--brand); }

.topbar-actions { display: flex; gap: 8px; flex: none; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.contact-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: linear-gradient(135deg, #ecfdf5, #eef2ff); border: 1px solid #a7f3d0;
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.contact-text { display: grid; gap: 6px; max-width: 760px; min-width: 0; }
.contact-text a { color: var(--wa-green); font-weight: 700; }
.contact-btn { padding: 12px 20px; font-size: .95rem; }

.container { padding-top: 20px; padding-bottom: 28px; display: grid; gap: 20px; }
.footer { color: var(--muted); font-size: .8rem; padding-bottom: 28px; text-align: center; }

/* ---------- cards & common ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-size: .74rem; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 2px; }
.hint { font-size: .8rem; color: var(--muted); }
.center { text-align: center; }
.stack { display: grid; gap: 8px; margin-bottom: 16px; }
.label { font-size: .86rem; font-weight: 600; }

.pill { font-size: .76rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.pill-neutral { background: var(--neutral-bg); color: var(--muted); border-color: var(--border); }
.pill-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.pill-error { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-success { background: var(--success); }
.dot-warning { background: #f59e0b; }
.dot-error { background: var(--error); }
.tone-neutral { color: var(--muted); }
.tone-success { color: var(--success); }
.tone-warning { color: var(--warning); }
.tone-error { color: var(--error); }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .chip:focus-visible, .btn-link:focus-visible, .input:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
.btn-sm { padding: 7px 12px; font-size: .84rem; }
.btn-xs { padding: 3px 9px; font-size: .76rem; border-radius: 7px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }
.btn-wa { background: var(--wa-green); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.input {
  width: 100%; min-width: 0; padding: 10px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.input:focus { border-color: var(--brand); }
.input:disabled, .input:read-only { background: var(--surface-2); }
.input-row { display: flex; gap: 8px; }
.otp-input { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .45em; text-align: center; max-width: 240px; }

/* ---------- scenario bar ---------- */
.scenario-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.scenario-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.scenario-title { font-weight: 700; font-size: .9rem; }
.scenario-desc { font-size: .82rem; color: var(--muted); }
.scenario-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font: inherit; font-size: .83rem; font-weight: 600; cursor: pointer;
}
.chip:hover { background: var(--neutral-bg); }
.chip.active.chip-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.chip.active.chip-error { background: var(--error-bg); border-color: var(--error); color: var(--error); }

/* ---------- layout ---------- */
.main-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------- MySaas panel ---------- */
.instruct { border: 1px dashed #c7d2fe; background: #f8f9ff; border-radius: 12px; padding: 14px; margin-bottom: 16px; display: grid; gap: 14px; }
.instruct-step { display: flex; gap: 12px; }
.instruct-step > div { min-width: 0; display: grid; gap: 6px; justify-items: start; }
.instruct-title { font-weight: 600; font-size: .9rem; }
.step-badge { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .78rem; font-weight: 700; display: grid; place-items: center; }
.link-box { display: flex; align-items: center; gap: 8px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.link-box code { overflow-wrap: anywhere; min-width: 0; }
.otp-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.otp-actions { display: flex; align-items: center; gap: 12px; }
.countdown { font-weight: 600; font-size: .88rem; font-variant-numeric: tabular-nums; }

.alert { border-radius: 12px; padding: 12px 14px; border: 1px solid; margin-bottom: 16px; font-size: .88rem; display: grid; gap: 4px; }
.alert-title { font-weight: 700; }
.alert-code { font-size: .78rem; opacity: .85; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #14532d; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #78350f; }
.alert-error { background: var(--error-bg); border-color: var(--error-border); color: #7f1d1d; }

.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 0; }
.summary > div { background: var(--surface-2); padding: 10px 12px; min-width: 0; }
.summary dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.summary dd { margin: 2px 0 0; font-size: .86rem; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- WhatsApp mock ---------- */
.wa-column { display: grid; gap: 10px; justify-items: center; min-width: 0; }
.phone {
  width: 100%; max-width: 380px; height: 640px; display: flex; flex-direction: column;
  border-radius: 34px; border: 10px solid #111827; background: var(--wa-chat); overflow: hidden;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
}
.phone-status { display: flex; justify-content: space-between; background: var(--wa-dark); color: #d1fae5; font-size: .72rem; padding: 5px 16px 2px; font-variant-numeric: tabular-nums; }
.wa-header { display: flex; align-items: center; gap: 10px; background: var(--wa-dark); color: #fff; padding: 8px 12px 10px; }
.wa-back { font-size: 1.5rem; line-height: 1; opacity: .9; }
.wa-avatar { width: 36px; height: 36px; border-radius: 50%; background: #e0e7ff; color: var(--brand); font-weight: 800; display: grid; place-items: center; flex: none; }
.wa-contact { min-width: 0; flex: 1; }
.wa-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-verified { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: #25d366; color: #fff; font-size: .62rem; vertical-align: 1px; }
.wa-sub { font-size: .74rem; opacity: .8; }
.sim-chip { font-size: .62rem; font-weight: 800; letter-spacing: .06em; background: #fde047; color: #422006; padding: 2px 6px; border-radius: 5px; }

.wa-body {
  flex: 1; overflow-y: auto; padding: 12px 10px;
  background-color: var(--wa-chat);
  background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px);
  background-size: 16px 16px;
}
.wa-closed { height: 100%; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; color: #475569; font-size: .86rem; padding: 0 24px; }
.wa-closed-icon { font-size: 2.2rem; }
.wa-closed-title { font-weight: 700; color: var(--text); }
.wa-messages { display: flex; flex-direction: column; gap: 6px; }
.wa-day { align-self: center; background: #fff; color: #54656f; font-size: .72rem; padding: 3px 10px; border-radius: 7px; box-shadow: 0 1px .5px rgba(0, 0, 0, .1); }
.wa-system { align-self: center; max-width: 88%; text-align: center; background: #fff5c4; color: #54656f; font-size: .74rem; padding: 5px 10px; border-radius: 7px; box-shadow: 0 1px .5px rgba(0, 0, 0, .1); }
.wa-system-warn { background: #ffe4e1; color: #7f1d1d; }

.bubble { max-width: 84%; padding: 6px 9px 4px; border-radius: 9px; font-size: .88rem; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); overflow-wrap: anywhere; animation: pop .18s ease-out; }
.bubble p { margin: 0; }
.bubble .meta { display: block; text-align: right; font-size: .66rem; color: #667781; margin-top: 1px; }
.bubble-out { align-self: flex-end; background: var(--wa-out); border-top-right-radius: 2px; }
.bubble-in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.bubble-otp { border-left: 3px solid var(--wa-green); }
.otp-code { font-family: var(--mono); font-size: 1.1rem; letter-spacing: .12em; background: #e7f8f1; padding: 0 4px; border-radius: 4px; }
.ticks { color: #8696a0; letter-spacing: -2px; }
.ticks.read { color: #53bdeb; }
.typing { display: flex; gap: 4px; padding: 10px 12px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

.wa-composer { display: flex; gap: 6px; padding: 8px; background: #f0f2f5; }
.wa-input { flex: 1; min-width: 0; border: 0; border-radius: 20px; padding: 9px 14px; font: inherit; font-size: .88rem; background: #fff; }
.wa-input:focus { outline: 2px solid var(--wa-green); }
.wa-send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--wa-green); color: #fff; font-size: 1rem; cursor: pointer; flex: none; }
.wa-send:disabled { opacity: .45; cursor: not-allowed; }
.wa-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- gateway panel ---------- */
.gw-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.flow { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.flow-step { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); min-width: 0; transition: background .2s, border-color .2s; }
.flow-step:not(:last-child)::after { content: "→"; position: absolute; right: -8px; top: 50%; transform: translate(50%, -50%); color: var(--muted); font-size: .85rem; z-index: 1; }
.flow-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: #e2e8f0; color: var(--muted); }
.flow-text { display: grid; min-width: 0; }
.flow-label { font-size: .84rem; font-weight: 600; line-height: 1.25; }
.flow-state { font-size: .72rem; color: var(--muted); }
.flow-step.is-pending { background: var(--warning-bg); border-color: var(--warning-border); }
.flow-step.is-pending .flow-dot { background: #f59e0b; color: #fff; animation: blink 1.4s infinite; }
.flow-step.is-pending .flow-state { color: var(--warning); }
.flow-step.is-success { background: var(--success-bg); border-color: var(--success-border); }
.flow-step.is-success .flow-dot { background: var(--success); color: #fff; }
.flow-step.is-success .flow-state { color: var(--success); }
.flow-step.is-error { background: var(--error-bg); border-color: var(--error-border); }
.flow-step.is-error .flow-dot { background: var(--error); color: #fff; }
.flow-step.is-error .flow-state { color: var(--error); }
.flow-step.is-skipped { opacity: .7; border-style: dashed; }

.gw-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.contract { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.endpoint { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.endpoint code { overflow-wrap: anywhere; min-width: 0; }
.method { font-family: var(--mono); font-size: .72rem; font-weight: 800; background: #dbeafe; color: #1d4ed8; padding: 2px 6px; border-radius: 5px; flex: none; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; margin: 10px 0 4px; font-size: .84rem; font-weight: 600; }
.notes { margin-top: 14px; font-size: .82rem; }
.notes summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.notes ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 5px; color: #334155; }

.code {
  margin: 0; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px;
  font-family: var(--mono); font-size: .78rem; line-height: 1.55; overflow-x: auto; white-space: pre;
}
.j-key { color: #93c5fd; }
.j-str { color: #86efac; }
.j-num { color: #fcd34d; }
.j-kw { color: #f9a8d4; }

.logs { min-width: 0; }
.logs-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.count { display: inline-block; min-width: 22px; text-align: center; font-size: .72rem; background: var(--neutral-bg); border-radius: 999px; padding: 1px 7px; color: var(--muted); margin-left: 4px; }
.log-list { display: grid; gap: 8px; max-height: 620px; overflow-y: auto; padding-right: 2px; }
.empty { color: var(--muted); font-size: .86rem; border: 1px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; }

.log { border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; background: var(--surface); animation: pop .2s ease-out; }
.log-success { border-left-color: var(--success); }
.log-error { border-left-color: var(--error); }
.log-warning { border-left-color: #f59e0b; }
.log-info { border-left-color: #94a3b8; }
.log summary { list-style: none; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; font-size: .84rem; }
.log summary::-webkit-details-marker { display: none; }
.log summary::before { content: "▸"; color: var(--muted); grid-row: 1; margin-right: -4px; display: none; }
.log[open] summary { border-bottom: 1px solid var(--border); }
.log-time { font-family: var(--mono); font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.actor { font-size: .7rem; font-weight: 700; background: #eef2ff; color: var(--brand); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.log-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.http { font-family: var(--mono); font-size: .74rem; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.http-success { background: var(--success-bg); color: var(--success); }
.http-error { background: var(--error-bg); color: var(--error); }
.http-info, .http-warning, .http-none { background: var(--neutral-bg); color: var(--muted); }
.log-dur { font-family: var(--mono); font-size: .74rem; color: var(--muted); min-width: 52px; text-align: right; }
.log-body { padding: 4px 12px 12px; min-width: 0; }
.kv-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: .8rem; margin-top: 8px; }
.kv-grid span { color: var(--muted); }
.kv-grid code { overflow-wrap: anywhere; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .main-grid, .gw-grid { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .flow-step::after { display: none; }
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar-inner, .container, .footer { padding-left: 16px; padding-right: 16px; }
  .card { padding: 16px; }
  .input-row { flex-direction: column; }
  .otp-input { max-width: none; }
  .summary { grid-template-columns: minmax(0, 1fr); }
  .phone { height: 560px; border-width: 8px; border-radius: 26px; }
  .log summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .log summary .actor, .log summary .log-dur { display: none; }
  .brand-tag { display: none; }
  .story-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-inner { flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .topbar-actions > * { flex: 1; }
  .contact-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
