:root {
  --brand: #4f46e5;
  --bg: #ffffff;
  --side: #f7f8fb;
  --text: #171a22;
  --muted: #5f6677;
  --line: #e5e8ef;
  --code-bg: #0f1222;
  --code-text: #e3e6ff;
  --inline-bg: #f1f2f8;
  --ok: #157f3d; --ok-bg: #e9f9ef;
  --bad: #b42318; --bad-bg: #fdeeec;
  --warn-bg: #fff7e6; --warn-line: #f3d08a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0d1016;
  --side: #121620;
  --text: #e9ecf3;
  --muted: #9aa3b5;
  --line: #232a37;
  --code-bg: #070910;
  --inline-bg: #1b2130;
  --ok-bg: #0f2a1c; --bad-bg: #2e1513;
  --warn-bg: #2a2412; --warn-line: #5c4a1c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86em; background: var(--inline-bg); padding: 1px 6px; border-radius: 5px; }
pre { background: var(--code-bg); color: var(--code-text); padding: 16px 18px; border-radius: 10px; overflow-x: auto; position: relative; margin: 12px 0 18px; }
pre code { background: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.55; }
pre .copy { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.08); color: #cfd3f5; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; font-size: 12px; padding: 3px 8px; cursor: pointer; }

.top { position: sticky; top: 0; z-index: 10; height: 56px; display: flex; align-items: center; padding: 0 20px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 750; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.tag { font-size: 11px; font-weight: 600; background: var(--inline-bg); color: var(--muted); padding: 2px 7px; border-radius: 999px; }
.top-right { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; }
.ghost { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 15px; }

.wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.side { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 18px 12px 40px; background: var(--side); border-right: 1px solid var(--line); }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 16px 10px 6px; }
.side a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--text); font-size: 14px; }
.side a:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); text-decoration: none; }
.side a.active { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand); font-weight: 600; }

.content { padding: 28px 48px 80px; max-width: 980px; }
section { padding: 8px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
section:last-of-type { border-bottom: 0; }
h1 { font-size: 34px; letter-spacing: -0.02em; margin: 6px 0 10px; }
h2 { font-size: 23px; letter-spacing: -0.01em; margin: 10px 0 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
h3 { font-size: 16px; margin: 22px 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lead { font-size: 17px; color: var(--muted); }
.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 14px; display: block; overflow-x: auto; }
table thead, table tbody { display: table; width: 100%; table-layout: auto; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { white-space: nowrap; }
.params td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.req { color: #c2410c; font-size: 11px; font-weight: 600; margin-left: 4px; }
.verb { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; color: #fff; }
.verb.post { background: #16a34a; }
.verb.get { background: #2563eb; }
.code201 { font-size: 12px; background: var(--ok-bg); color: var(--ok); padding: 2px 8px; border-radius: 999px; }
.callout { background: color-mix(in srgb, var(--brand) 7%, transparent); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); padding: 12px 16px; border-radius: 10px; margin: 14px 0; }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.flow { counter-reset: s; list-style: none; padding: 0; }
.flow li { position: relative; padding: 10px 12px 10px 48px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.flow li::before { counter-increment: s; content: counter(s); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.who { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-right: 6px; background: var(--inline-bg); }
.who.crm { background: #e0ecff; color: #1d4ed8; }
.who.kp { background: #ede9fe; color: #5b21b6; }
.who.client { background: #dcfce7; color: #166534; }
:root[data-theme='dark'] .who.crm { background: #172554; color: #bfdbfe; }
:root[data-theme='dark'] .who.kp { background: #2e1065; color: #ddd6fe; }
:root[data-theme='dark'] .who.client { background: #052e16; color: #bbf7d0; }
.states { font-size: 14px; line-height: 2.2; margin: 6px 0 10px; }
.st { padding: 3px 9px; border-radius: 999px; background: var(--inline-bg); font-family: ui-monospace, monospace; font-size: 12.5px; }
.st.ok { background: var(--ok-bg); color: var(--ok); }
.st.bad { background: var(--bad-bg); color: var(--bad); }
.tabs { display: flex; gap: 4px; margin-top: 10px; }
.tabs button { background: var(--inline-bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.tabs button.on { background: var(--code-bg); color: var(--code-text); border-color: var(--code-bg); }
.tabs + pre, .tabs ~ pre { margin-top: 0; border-top-left-radius: 0; }
.checks { list-style: none; padding: 0; }
.checks li { padding-left: 26px; position: relative; margin: 6px 0; }
.checks li::before { content: '✓'; position: absolute; left: 4px; color: var(--ok); font-weight: 700; }
/* --- Integration tiles (Choose an integration) ------------------------------------ */
.callout.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 12px 0 22px; }
.path { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text); background: var(--bg); transition: border-color .15s, box-shadow .15s, transform .15s; }
.path:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); box-shadow: 0 8px 24px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.path-ill { background: var(--side); border-bottom: 1px solid var(--line); padding: 12px 14px; }
.path-ill svg { display: block; width: 100%; height: auto; }
.path-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.path-body h3 { margin: 2px 0 4px; font-size: 15px; color: var(--brand); }
.path-body p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); flex: 1; }
.path-tags { display: flex; gap: 6px; }
.ptag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--inline-bg); color: var(--muted); vertical-align: middle; }
.ptag.rec { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.ptag.nocode { background: var(--ok-bg); color: var(--ok); }
h2 .ptag { font-size: 12px; margin-left: 6px; }
.effort { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.effort span { margin-right: 6px; }
.effort i { width: 18px; height: 6px; border-radius: 3px; background: var(--line); }
.effort i.on { background: var(--brand); }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 760px; }

/* Tile illustrations */
.ill .frame, .ill .card { fill: var(--bg); stroke: var(--line); stroke-width: 1.4; }
.ill .card { stroke: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.ill .rule { stroke: var(--line); }
.ill .dot { fill: var(--line); }
.ill .soft { fill: var(--line); }
.ill .field-i { fill: var(--inline-bg); stroke: var(--line); }
.ill .accent { fill: var(--brand); }
.ill .iframe { fill: none; stroke: var(--brand); stroke-width: 1.2; stroke-dasharray: 4 3; }
.ill .flow { fill: none; stroke: var(--brand); stroke-width: 2; }
.ill .flowhead { fill: var(--brand); }
.ill .bubble { fill: var(--bg); stroke: var(--line); stroke-width: 1.4; }
.ill .cardicon { fill: var(--brand); opacity: .85; }
.ill .bank { fill: var(--muted); }
.ill .ill-t { fill: var(--muted); font-size: 10px; font-weight: 600; }
.ill .ill-ok { fill: var(--ok); font-size: 15px; font-weight: 800; }
.ill .ill-link { fill: var(--brand); font-size: 10px; font-family: ui-monospace, monospace; }

/* --- Diagrams --------------------------------------------------------------------- */
.diagram { margin: 16px 0 20px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 10px; background: var(--side); overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 640px; height: auto; }
.diagram figcaption { color: var(--muted); font-size: 13px; margin-top: 6px; }
.seq text { font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.seq .lane { fill: var(--bg); stroke: var(--line); stroke-width: 1.4; }
.seq .lane.kp { stroke: var(--brand); }
.seq .lane.psp { stroke: color-mix(in srgb, var(--ok) 70%, var(--line)); }
.seq .lane-l { fill: var(--text); font-size: 13px; font-weight: 700; }
.seq .lane-s { fill: var(--muted); font-size: 11px; }
.seq .life { stroke: var(--line); stroke-width: 1.4; stroke-dasharray: 4 5; }
.seq .m { stroke: var(--brand); stroke-width: 1.8; }
.seq .m.back { stroke: var(--muted); stroke-dasharray: 6 4; }
.seq .m.secure { stroke: var(--ok); stroke-width: 2.6; }
.seq .ah { fill: var(--brand); }
.seq .ah.b { fill: var(--muted); }
.seq .ah.s { fill: var(--ok); }
.seq .lbl { fill: var(--text); font-size: 12.5px; paint-order: stroke; stroke: var(--side); stroke-width: 5px; stroke-linejoin: round; }
.seq .lbl.secure { fill: var(--ok); font-weight: 700; }
.seq .num circle { fill: var(--brand); }
.seq .num.s circle { fill: var(--ok); }
.seq .num text { fill: #fff; font-size: 10.5px; font-weight: 700; }
.seq .note rect { fill: var(--warn-bg); stroke: var(--warn-line); }
.seq .note text { fill: var(--text); font-size: 12px; }
.seq.boundary .zone-browser { fill: var(--bg); stroke: var(--line); stroke-width: 1.4; }
.seq.boundary .box { fill: var(--side); stroke: var(--brand); stroke-width: 1.2; }
.seq.boundary .secure-box { fill: color-mix(in srgb, var(--ok) 9%, var(--bg)); stroke: var(--ok); stroke-width: 1.8; stroke-dasharray: 5 3; }
.seq.boundary .secure-t { fill: var(--ok); font-size: 12px; font-weight: 700; }
.seq.boundary .field { fill: var(--bg); stroke: var(--line); }
.seq.boundary .field-t { fill: var(--muted); font-size: 11.5px; font-family: ui-monospace, monospace; }
@media (max-width: 980px) { .paths { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .paths { grid-template-columns: minmax(0, 1fr); } }

.foot { color: var(--muted); font-size: 13px; padding-top: 20px; }

.content { min-width: 0; }
body { overflow-x: hidden; }

@media (max-width: 860px) {
  .wrap { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky; top: 56px; z-index: 9; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 2px; padding: 8px 12px; white-space: nowrap; scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .side .group { display: none; }
  .side a { flex: none; }
  html { scroll-padding-top: 112px; }
  .content { padding: 20px 16px 60px; }
  h1 { font-size: 28px; }
  .top { padding: 0 16px; }
  .top-right a { display: none; }
}
.ill .ill-t.inv { fill: #fff; }

/* Side notes (e.g. names from before the rename) */
p.note { border-left: 3px solid var(--warn-line); background: var(--warn-bg); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 14px; }
