:root {
  --ink: #13213c;
  --muted: #65718a;
  --line: #dfe4ee;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --nav: #101a31;
  --primary: #5b4cf0;
  --primary-dark: #4434d3;
  --success: #14845d;
  --danger: #c23b4a;
  --warning: #a76511;
  --radius-sm: 10px;
  --radius: 16px;
  --shadow: 0 18px 45px rgba(17, 31, 61, .09);
  --focus: 0 0 0 3px rgba(91, 76, 240, .22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); font-weight: 550; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
input, select, textarea { font-weight: 550; }
input::placeholder, textarea::placeholder { color: #7a859b; font-weight: 500; opacity: 1; }
strong, b { font-weight: 800; }
h1, h2, h3, h4 { font-weight: 850; }
small { font-weight: 600; }
button, .button { min-height: 42px; }
:focus-visible { outline: none; box-shadow: var(--focus); }

.app-shell { width: 100%; min-height: 100vh; overflow-x: clip; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 268px; height: 100dvh; min-height: 0; display: flex; flex-direction: column; padding: 24px 18px; overflow: hidden; color: #dce3f3; background: var(--nav); box-shadow: 12px 0 34px rgba(11,20,39,.08); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.brand--dark { color: var(--ink); }
.brand__mark { display: inline-grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: white; background: linear-gradient(145deg, #7768ff, #4d3ce0); box-shadow: 0 8px 22px rgba(91, 76, 240, .35); }
.workspace-card { display: grid; gap: 4px; margin: 28px 0 18px; padding: 15px; border: 1px solid rgba(255,255,255,.11); border-radius: var(--radius); background: rgba(255,255,255,.06); }
.workspace-switcher { margin: 28px 0 18px; }
.workspace-switcher label { display: grid; gap: 7px; color: #99a8c6; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.workspace-switcher select { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.14); border-radius: var(--radius-sm); color: white; background: #202b43; text-transform: none; letter-spacing: 0; }
.sidebar-logout { padding: 0; border: 0; color: #aebbd3; background: transparent; cursor: pointer; text-decoration: underline; }
.workspace-card span { color: #99a8c6; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.workspace-card strong { color: white; font-size: 14px; }
.workspace-card small { color: #c7d0e4; font-weight: 650; }
.nav { min-height: 0; display: grid; align-content: start; gap: 5px; padding-right: 6px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #8290aa transparent; scrollbar-width: thin; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { border-radius: 999px; background: #64738f; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; color: #d2daf0; text-decoration: none; font-weight: 750; letter-spacing: .005em; }
.nav-link:hover { color: white; background: rgba(112, 94, 255, .18); }
.nav-link.is-active { color: white; background: rgba(112, 94, 255, .30); font-weight: 850; }
.nav-link__icon { display: inline-grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; font-size: 11px; }
.sidebar__footer { flex: 0 0 auto; display: grid; gap: 8px; margin-top: 12px; padding: 16px 10px 0; border-top: 1px solid rgba(255,255,255,.16); background: var(--nav); }
.sidebar__footer strong { overflow: hidden; color: #fff; font-size: 13px; text-overflow: ellipsis; }
.sidebar__footer span { color: #9eabc5; font-size: 12px; }
.sidebar__footer > a { width: fit-content; color: #fff; font-size: 13px; font-weight: 800; text-decoration-color: #8f82ff; text-underline-offset: 4px; }
.sidebar__footer > a:hover { color: #d9d4ff; }
.mode-switch { width: fit-content; color: #fff; font-size: 13px; font-weight: 800; text-decoration: underline; text-decoration-color: #8f82ff; text-underline-offset: 4px; }
.mode-switch:hover { color: #d9d4ff; }
.mode-switch-button { border-color: #c4bbff; color: #30258f; background: #f4f2ff; }
.mode-switch-button:hover { border-color: #8b7df5; color: #241a78; background: #ebe8ff; }

.main { width: auto; min-width: 0; max-width: none; min-height: 100vh; margin-left: 268px; padding: 46px 44px 80px; overflow-x: hidden; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-header h1, .auth-card h1 { margin: 2px 0 0; font-size: clamp(30px, 4vw, 43px); letter-spacing: -.045em; line-height: 1.05; }
.eyebrow { margin: 0; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.page-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 750; text-decoration: none; cursor: pointer; }
.button--primary { color: #fff; background: var(--primary); }
.button--primary:hover { background: var(--primary-dark); }
.button--secondary { color: var(--ink); border-color: var(--line); background: var(--surface); }
.button--secondary:hover { border-color: #bcc5d5; background: #f9faff; }
.button--danger { color: #fff; background: var(--danger); }
.button:disabled { opacity: .5; cursor: not-allowed; }

.hero-card, .panel, .metric, .auth-card, .empty-state { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: 24px; }
.table-panel { overflow: hidden; padding: 0; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 18px 20px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #56627a; background: #fafbfe; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
td { font-weight: 550; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: #5d6980; font-weight: 600; }
.hero-card { min-height: 265px; display: grid; align-items: end; padding: clamp(28px, 5vw, 56px); overflow: hidden; background: radial-gradient(circle at 85% 20%, rgba(108,91,255,.20), transparent 31%), linear-gradient(135deg, #fff, #f8f7ff); }
.hero-card div { max-width: 760px; }
.hero-card h2 { max-width: 700px; margin: 20px 0 12px; font-size: clamp(28px, 4vw, 48px); line-height: 1.08; letter-spacing: -.045em; }
.hero-card p { max-width: 680px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-top: 18px; }
.metric { display: grid; gap: 8px; padding: 23px; box-shadow: none; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.metric strong { font-size: 24px; letter-spacing: -.025em; }
.metric small { color: var(--muted); }
.status { display: inline-flex; width: fit-content; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; color: #3e4961; background: #eef1f6; font-size: 12px; font-weight: 800; }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--active, .status--healthy, .status--completed { color: var(--success); background: #e7f6f0; }
.status--error, .status--failed, .status--revoked { color: var(--danger); background: #fdecee; }
.status--pending, .status--testing { color: var(--warning); background: #fff4df; }
.notice { margin-bottom: 20px; padding: 13px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: white; }
.notice--error { color: #8e2633; border-color: #f2b7bf; background: #fff1f3; }
.notice--success { color: #0e6848; border-color: #a9dfca; background: #effaf5; }
.muted { color: #5d6980; font-weight: 550; }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 16% 10%, rgba(91,76,240,.20), transparent 30%), #f4f6fa; }
.auth-card { width: min(470px, 100%); display: grid; gap: 30px; padding: clamp(28px, 6vw, 48px); }
.auth-card p { line-height: 1.6; }
.installer-card { width: min(860px,100%); }
.installer-form { width: 100%; }
.installer-form h2 { margin: 12px 0 0; font-size: 18px; }
.check-list { display: grid; gap: 8px; }
.check-list > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check-list small { grid-column: 1 / -1; color: var(--muted); }
.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; color: #34415a; font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cdd4e1; border-radius: var(--radius-sm); color: var(--ink); background: white; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; }
.detail-row { display: grid; grid-template-columns: 140px 1fr; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: 0; }
.detail-row > span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.detail-row p { margin: 0; line-height: 1.6; }
.action-stack { align-items: stretch; flex-direction: column; }
.action-stack form, .action-stack .button { width: 100%; }
.conversation-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.conversation-head h2 { margin: 6px 0 0; }
.message-list { display: grid; gap: 12px; }
.message { width: min(720px, 88%); padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.message--outbound { justify-self: end; border-color: #c9c2ff; background: #f3f1ff; }
.message > div { display: flex; justify-content: space-between; gap: 16px; }
.message time, .message small { color: var(--muted); font-size: 12px; }
.message p { margin: 9px 0 0; line-height: 1.55; }
.commerce-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(320px,1fr); gap: 18px; margin-top: 18px; }
.commerce-grid > aside { display: grid; align-content: start; gap: 18px; }
.commerce-grid details.panel { padding: 0; overflow: hidden; }
.commerce-grid details.panel summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 22px; cursor: pointer; list-style: none; transition: background .15s ease; }
.commerce-grid details.panel summary::-webkit-details-marker { display: none; }
.commerce-grid details.panel summary:hover { background: #fafbff; }
.commerce-grid details.panel summary::after { content: "+"; display: grid; width: 30px; height: 30px; place-items: center; margin-left: auto; border-radius: 9px; color: var(--primary); background: #f0eeff; font-size: 20px; font-weight: 850; }
.commerce-grid details.panel[open] summary { border-bottom: 1px solid var(--line); background: #fafbff; }
.commerce-grid details.panel[open] summary::after { content: "−"; }
.commerce-grid details.panel summary strong,.commerce-grid details.panel summary small { display: block; }
.commerce-grid details.panel summary small { margin-top: 5px; color: var(--muted); }
.commerce-grid details.panel > form { padding: 4px 22px 22px; }
.connector-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.connector-grid .panel { display: flex; align-items: flex-start; flex-direction: column; gap: 16px; }
.connector-grid .panel > .form-stack,.connector-grid .panel > .actions { width: 100%; margin-top: auto; }
.split-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(300px,1fr); gap: 18px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form select { min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.section-gap { margin-top: 18px; }
.form-columns { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.health-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.overview-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 34px; border-radius: var(--radius); color: white; background: radial-gradient(circle at 88% 12%,rgba(130,115,255,.65),transparent 30%),linear-gradient(135deg,#101a31,#31266f); box-shadow: var(--shadow); }
.overview-intro h2 { margin: 8px 0; font-size: clamp(30px,4vw,46px); letter-spacing: -.04em; }
.overview-intro p:not(.eyebrow) { max-width: 650px; margin: 0; color: #d7dcf0; line-height: 1.6; }
.overview-intro .eyebrow { color: #bcb3ff; }
.overview-intro .button { flex: 0 0 auto; background: white; color: #241b64; }
.overview-metrics { grid-template-columns: repeat(4,minmax(0,1fr)); }
.overview-columns { display: grid; grid-template-columns: minmax(0,2fr) minmax(300px,1fr); gap: 18px; margin-top: 18px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2,.operational-card h2 { margin: 7px 0 0; }
.section-heading > span { color: var(--muted); font-size: 13px; font-weight: 750; }
.setup-list { display: grid; }
.setup-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none; }
.setup-item:first-child { border-top: 0; }
.setup-item strong,.setup-item small { display: block; }
.setup-item small { margin-top: 5px; color: var(--muted); line-height: 1.45; }
.setup-item b { color: var(--primary); font-size: 22px; }
.onboarding-step { display: grid; grid-template-columns: auto 1fr auto; }
.step-number { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: white; background: var(--primary); font-weight: 850; }
.onboarding-step.is-complete .step-number { background: var(--success); }
.progress-value { font-size: clamp(38px,6vw,68px); letter-spacing: -.05em; }
.operational-card { display: flex; align-items: flex-start; flex-direction: column; gap: 18px; }
.operational-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.complete-state { padding: 24px; border-radius: var(--radius-sm); background: #effaf5; }
.danger-panel { margin: 18px 0; border-color: #efb4bc; background: #fff7f8; }
.field input:hover { border-color: #aeb8ca; }
.empty-state { padding: 44px; text-align: center; }
.empty-state__icon { display: grid; width: 46px; height: 46px; place-items: center; margin: 0 auto 14px; border-radius: 14px; color: white; background: var(--primary); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.tag-list form { margin: 0; }
.tag-chip { min-height: 34px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: white; cursor: pointer; font-size: 12px; font-weight: 800; }
.tag-chip:hover { border-color: var(--primary); color: var(--primary); }
.tag-chip.is-active { border-color: #bdb4ff; color: #3c2db5; background: #f1efff; }
.help-steps { display: grid; gap: 12px; padding-left: 22px; color: var(--muted); line-height: 1.55; }
.legal-page { min-height: 100vh; padding: 40px 20px; background: var(--canvas); }
.legal-card { width: min(820px,100%); margin: 0 auto; padding: clamp(28px,5vw,56px); }
.legal-card h1 { margin: 14px 0 30px; font-size: clamp(34px,5vw,52px); letter-spacing: -.04em; }
.legal-card h2 { margin-top: 30px; }
.legal-card p { color: var(--muted); line-height: 1.7; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; height: auto; padding: 16px; overflow: visible; box-shadow: none; }
  .workspace-card, .sidebar__footer { display: none; }
  .nav { display: flex; margin-top: 16px; overflow-x: auto; overflow-y: hidden; }
  .nav-link { flex: 0 0 auto; }
  .main { width: 100%; margin-left: 0; padding: 28px 18px 60px; }
  .metric-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .commerce-grid { grid-template-columns: 1fr; }
  .connector-grid,.split-grid { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-columns { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-actions, .page-actions form, .page-actions .button { width: 100%; }
  .nav-link__icon { display: none; }
  .hero-card { min-height: 320px; padding: 28px 22px; }
  .health-grid { grid-template-columns: 1fr; }
  .overview-intro { align-items: flex-start; flex-direction: column; }
  .overview-metrics { grid-template-columns: 1fr; }
}

/* V4.1 product interface: compact, durable application chrome. */
:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --canvas: #f7f8fb;
  --nav: #111827;
  --primary: #635bff;
  --primary-dark: #5148e5;
  --radius-sm: 8px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}

body { font-size: 16px; font-weight: 550; }
.sidebar { width: 276px; padding: 24px 18px 18px; background: linear-gradient(180deg,#101a31 0%,#111827 100%); box-shadow: 1px 0 0 rgba(255,255,255,.05); }
.brand { min-height: 46px; padding: 0 6px; font-size: 17px; }
.brand__mark { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 6px 18px rgba(99,91,255,.30); }
.workspace-card { margin: 22px 0 16px; padding: 15px; border-color: rgba(255,255,255,.10); border-radius: 12px; background: rgba(255,255,255,.055); }
.workspace-card span { color: #aab4c7; font-size: 11px; font-weight: 750; }
.workspace-card strong { font-size: 15px; }
.workspace-card small { color: #b7c1d3; font-size: 13px; }
.nav { gap: 2px; padding: 2px 5px 8px 0; }
.nav-link { min-height: 46px; gap: 12px; padding: 9px 11px; border-radius: 9px; color: #d5dceb; font-size: 15px; font-weight: 700; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.is-active { color: #fff; background: rgba(99,91,255,.22); box-shadow: inset 3px 0 0 #8b83ff; }
.nav-link__icon { width: 28px; height: 28px; border-color: rgba(255,255,255,.12); border-radius: 8px; color: #c2cada; background: rgba(255,255,255,.035); font-size: 11px; font-weight: 800; }
.nav-link.is-active .nav-link__icon { color: #fff; border-color: rgba(139,131,255,.42); background: rgba(99,91,255,.24); }
.sidebar__footer { gap: 7px; margin-top: 8px; padding: 12px 9px 0; border-color: rgba(255,255,255,.09); }
.sidebar__footer strong { font-size: 14px; }
.sidebar__footer span,.sidebar-logout,.mode-switch,.sidebar__footer > a { font-size: 13px; }
.mode-switch,.sidebar__footer > a { display: inline-flex; min-height: 38px; align-items: center; padding: 9px 11px; border: 1px solid rgba(139,131,255,.38); border-radius: 8px; color: #fff; background: rgba(99,91,255,.16); text-decoration: none; }
.mode-switch:hover,.sidebar__footer > a:hover { color: #fff; border-color: rgba(139,131,255,.65); background: rgba(99,91,255,.24); }

.main { margin-left: 276px; padding: 38px clamp(28px,3.5vw,52px) 72px; }
.page-header { min-height: 76px; margin-bottom: 28px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.page-header h1,.auth-card h1 { margin-top: 5px; font-size: clamp(30px,3vw,40px); letter-spacing: -.04em; }
.eyebrow { color: #675ee8; font-size: 12px; letter-spacing: .12em; }
.button { min-height: 42px; padding: 10px 16px; border-radius: 9px; font-size: 14px; font-weight: 750; }
.button--primary { box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.panel,.metric,.metric-card,.auth-card,.empty-state { border-color: var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.panel { padding: 24px; }
.panel__header { gap: 20px; padding-bottom: 18px; }
.panel__header h2,.section-heading h2 { margin: 4px 0 0; font-size: 21px; letter-spacing: -.025em; }
.panel__header p { margin-top: 7px; }
.table-panel { padding: 0; }
table { font-size: 15px; }
th,td { padding: 16px 18px; }
th { color: #5d687c; background: #f9fafb; font-size: 12px; letter-spacing: .07em; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafbff; }
td strong { color: #1d2939; font-weight: 750; }
td small { color: #667085; font-size: 13px; }
.status { padding: 6px 10px; font-size: 12px; }
.notice { border-radius: 10px; }
.metric-grid,.overview-metrics { gap: 14px; }
.metric-card,.metric { min-height: 110px; padding: 18px; }

@media (max-width: 900px) {
  .sidebar { width: auto; padding: 14px; }
  .main { margin-left: 0; padding: 24px 16px 52px; }
  .brand { padding: 0; }
  .nav { padding: 0 0 6px; }
}
