:root {
  --success: #25845a;
  --success-soft: #e8f6ee;
  --warning: #8a5b14;
}

.hidden { display: none !important; }
.onboarding-page { min-height: 100vh; background: var(--canvas); }

.onboarding-header {
  width: min(1180px, calc(100% - 48px));
  min-height: 90px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.setup-state { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 600; }
.setup-state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.onboarding-header > .text-button { justify-self: end; }
.text-button { padding: 9px 2px; border: 0; background: transparent; cursor: pointer; }
.text-button:hover { color: var(--pink-dark); }

.onboarding-shell {
  width: min(1120px, calc(100% - 48px));
  min-height: 690px;
  margin: 18px auto 24px;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  overflow: hidden;
  border-radius: 28px;
  background: var(--surface);
}
.setup-intro { display: flex; flex-direction: column; padding: 40px 32px; border-right: 1px solid var(--line); background: var(--pink-pale); }
.eyebrow { margin-bottom: 14px; color: var(--pink-dark); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.setup-intro h1 { margin-bottom: 14px; font-size: clamp(48px, 5vw, 64px); line-height: .9; }
.setup-lede { margin-bottom: 26px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }

.setup-progress { margin-bottom: 28px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: var(--pink-soft); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--pink); transition: width 400ms ease; }
.progress-copy { margin-top: 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.progress-copy strong { color: var(--ink); }

.setup-nav { margin: 0; padding: 0; display: grid; gap: 7px; list-style: none; }
.setup-nav li { padding: 10px; display: grid; grid-template-columns: 34px 1fr 18px; gap: 10px; align-items: center; border-radius: 13px; color: var(--muted); }
.setup-nav li > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 700; }
.setup-nav strong, .setup-nav small { display: block; }
.setup-nav strong { margin-bottom: 2px; color: var(--ink); font-size: 12px; }
.setup-nav small { font-size: 10px; }
.setup-nav i { display: none; color: var(--success); font-style: normal; font-size: 12px; font-weight: 700; }
.setup-nav li.active { background: var(--surface); }
.setup-nav li.complete > span { color: white; background: var(--success); }
.setup-nav li.complete i { display: block; }

.remi-companion { margin-top: auto; padding-top: 28px; display: flex; align-items: center; gap: 12px; }
.remi-setup-mascot { flex: 0 0 64px; width: 64px; height: 64px; object-fit: cover; border-radius: 20px; filter: saturate(.76); }
.remi-companion p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }

.setup-workspace { position: relative; min-height: 690px; padding: 44px; background: var(--surface); }
.workspace-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.loading-orb { width: 34px; height: 34px; border: 3px solid var(--pink-soft); border-top-color: var(--pink); border-radius: 50%; animation: onboarding-spin .8s linear infinite; }

.setup-alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 10px; color: #7c3150; background: var(--pink-soft); font-size: 12px; }
.setup-alert.success { color: #166744; background: var(--success-soft); }
.setup-alert.error { color: #8b2929; background: #fff0f0; }
.setup-card { max-width: 690px; margin: 0 auto; }
.step-heading { margin-bottom: 24px; display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: start; }
.step-heading h2 { margin-bottom: 8px; font-size: clamp(38px, 4vw, 50px); }
.step-heading p { max-width: 520px; margin-bottom: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.step-kicker { margin-bottom: 5px !important; color: var(--pink-dark) !important; font-family: ui-monospace, monospace; font-size: 9px !important; font-weight: 700; letter-spacing: .1em; }
.step-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; font-size: 16px; font-weight: 700; }
.google-icon { color: #3567c7; background: #edf3ff; }
.mail-icon { color: var(--pink-dark); background: var(--pink-soft); }
.whatsapp-icon { color: #187449; background: #e5f6ed; }
.status-badge { padding: 7px 9px; border-radius: 999px; color: var(--muted); background: var(--canvas); font-size: 9px; font-weight: 700; white-space: nowrap; text-transform: uppercase; }
.status-badge.connected { color: var(--success); background: var(--success-soft); }

.permission-card, .completion-summary { padding: 10px 16px; display: grid; gap: 0; border-radius: 16px; background: var(--surface-soft); }
.permission-card > div, .completion-summary > div { padding: 12px 0; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.permission-card > div:last-child, .completion-summary > div:last-child { border-bottom: 0; }
.permission-card > div > span, .completion-summary > div > span { flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--pink-dark); background: var(--pink-soft); font-size: 11px; font-weight: 700; }
.permission-card p, .completion-summary p { margin: 0; }
.permission-card strong, .permission-card small, .completion-summary strong, .completion-summary small { display: block; }
.permission-card strong, .completion-summary strong { margin-bottom: 2px; font-size: 12px; }
.permission-card small, .completion-summary small { color: var(--muted); font-size: 10px; }

.account-preview, .email-account { margin-top: 14px; padding: 13px; display: flex; align-items: center; gap: 11px; border-radius: 13px; background: var(--success-soft); }
.account-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--pink-dark); background: white; font-size: 12px; font-weight: 700; }
.account-preview strong, .account-preview small, .email-account strong, .email-account small { display: block; }
.account-preview strong, .email-account strong { font-size: 12px; }
.account-preview small, .email-account small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.connected-check { margin-left: auto; color: var(--success); font-size: 10px; font-weight: 700; }

.card-actions { margin-top: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-actions.centered { justify-content: center; }
.primary-button, .secondary-button { min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 650; }
.primary-button { color: white; background: var(--ink); }
.primary-button:hover { background: #2a272c; }
.secondary-button { color: var(--ink); border-color: #8e898f; background: transparent; }
.privacy-note { margin: 13px 0 0; color: var(--muted); font-size: 10px; }

.connected-accounts { margin-bottom: 18px; display: grid; gap: 8px; }
.email-account { margin-top: 0; }
.email-account .disconnect { margin-left: auto; border: 0; color: #9a526c; background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.mail-form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 11px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.server-grid { grid-template-columns: minmax(0, 1fr) 90px 90px; align-items: end; }
.field > span, .toggle-field > span { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 10px; font-weight: 700; }
.field input, .field select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--ink); background: white; font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--pink); box-shadow: inset 0 0 0 1px var(--pink); }
.toggle-field { min-height: 42px; padding: 0 9px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.toggle-field input { accent-color: var(--pink); }
.toggle-field > span { margin: 0; }
.password-field { position: relative; }
.password-field input { padding-right: 54px; }
.password-field button { position: absolute; right: 7px; bottom: 6px; height: 30px; padding: 0 7px; border: 0; color: var(--pink-dark); background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; }
.form-divider { margin-top: 2px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.form-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.provider-help { padding: 12px 14px; border-radius: 10px; color: #6f4b14; background: #fff7df; font-size: 11px; }
.provider-help p { margin: 4px 0 0; line-height: 1.5; }

.whatsapp-flow { display: grid; grid-template-columns: 190px 1fr; gap: 28px; align-items: center; }
.mini-phone { min-height: 230px; padding: 10px; overflow: hidden; border: 6px solid var(--ink); border-radius: 25px; background: #efeae2; }
.mini-phone-head { margin: -10px -10px 10px; padding: 11px; display: flex; align-items: center; gap: 8px; color: white; background: #075e54; }
.mini-phone-head > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--pink); }
.mini-phone-head strong, .mini-phone-head small { display: block; }
.mini-phone-head strong { font-size: 11px; }
.mini-phone-head small { margin-top: 1px; opacity: .72; font-size: 8px; }
.mini-chat { padding-top: 82px; display: flex; justify-content: flex-end; }
.mini-chat span { max-width: 160px; padding: 9px 10px; border-radius: 11px 11px 3px 11px; background: #d9fdd3; font-size: 10px; font-weight: 700; }
.whatsapp-instructions { display: grid; grid-template-columns: 28px 1fr; gap: 14px 10px; }
.instruction-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--pink-dark); background: var(--pink-soft); font-size: 10px; font-weight: 700; }
.whatsapp-instructions p { align-self: center; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.4; }
.link-code-panel { margin-top: 18px; padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-radius: 13px; background: var(--success-soft); }
.link-code-panel small, .link-code-panel strong { display: block; }
.link-code-panel small { margin-bottom: 4px; color: var(--muted); font-size: 9px; }
.link-code-panel strong { color: #116c36; font-size: 12px; letter-spacing: .04em; }

.completion-card { padding-top: 8px; text-align: center; }
.completion-visual { width: 68px; height: 68px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 22px; background: var(--success-soft); }
.completion-visual span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--success); font-size: 20px; font-weight: 700; }
.completion-card > p:not(.eyebrow) { max-width: 520px; margin: 0 auto 20px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.completion-summary { max-width: 520px; margin: 0 auto; text-align: left; }

.onboarding-footer { padding: 4px 20px 28px; display: flex; justify-content: center; gap: 22px; color: var(--muted); font-size: 9px; font-weight: 600; }
.onboarding-footer span::before { content: "✓"; margin-right: 5px; color: var(--success); }
button:disabled, .primary-button[aria-disabled="true"] { opacity: .58; cursor: wait; }
@keyframes onboarding-spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .onboarding-shell { grid-template-columns: 1fr; }
  .setup-intro { border-right: 0; border-bottom: 1px solid var(--line); }
  .setup-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .setup-nav li { grid-template-columns: 30px 1fr; }
  .setup-nav li i, .setup-nav small { display: none; }
  .remi-companion { display: none; }
  .setup-workspace { min-height: 650px; }
}
@media (max-width: 640px) {
  .onboarding-header { width: calc(100% - 28px); min-height: 76px; grid-template-columns: 1fr auto; }
  .setup-state { display: none; }
  .onboarding-shell { width: calc(100% - 20px); margin-top: 6px; border-radius: 20px; }
  .setup-intro, .setup-workspace { padding: 24px 20px; }
  .setup-intro h1 { font-size: 46px; }
  .setup-nav { gap: 3px; }
  .setup-nav li { display: block; padding: 7px; text-align: center; }
  .setup-nav li > span { margin: 0 auto; }
  .setup-nav li div { display: none; }
  .step-heading { grid-template-columns: 40px 1fr; }
  .step-icon { width: 40px; height: 40px; }
  .status-badge { grid-column: 2; justify-self: start; }
  .two-columns, .server-grid, .whatsapp-flow { grid-template-columns: 1fr; }
  .mini-phone { width: 200px; margin: 0 auto; }
  .card-actions { align-items: stretch; flex-direction: column; }
  .card-actions > * { width: 100%; justify-content: center; text-align: center; }
  .link-code-panel { align-items: stretch; flex-direction: column; }
  .onboarding-footer { flex-wrap: wrap; gap: 8px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
