/* Shared setup wizard. Works with both the tenant and GOD dashboards. */
body.wizard-open { overflow: hidden; }

.wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.wizard-overlay[hidden] { display: none !important; }

.wizard {
  --wiz-primary: var(--primary, var(--brand, #7c3aed));
  --wiz-primary-dark: var(--primary-dark, var(--brand-dark, #6d28d9));
  --wiz-text: var(--text, var(--ink, #0f172a));
  --wiz-muted: var(--muted, #64748b);
  --wiz-card: var(--card, #ffffff);
  --wiz-line: var(--border, var(--line, #e2e8f0));
  --wiz-soft: var(--gray-50, #f8fafc);
  --wiz-soft-2: var(--gray-100, #f1f5f9);
  --wiz-danger: var(--danger, #b91c1c);
  --wiz-success: var(--success, #15803d);
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--wiz-text);
  background: var(--wiz-card);
  border: 1px solid var(--wiz-line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.34);
  animation: wizard-in 0.18s ease-out;
}

@keyframes wizard-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.wizard-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px 0;
}
.wizard-head-copy { min-width: 0; }
.wizard-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--wiz-primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.wizard-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.wizard-subtitle {
  margin: 6px 0 0;
  max-width: 56ch;
  color: var(--wiz-muted);
  font-size: 13px;
  line-height: 1.5;
}
.wizard-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--wiz-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}
.wizard-close:hover { color: var(--wiz-text); background: var(--wiz-soft-2); }

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 20px 26px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--wiz-line);
}
.wizard-steps[hidden] { display: none !important; }
.wiz-color-control { display: flex; align-items: center; gap: 10px; }
.wiz-color-input {
  width: 54px;
  height: 42px;
  flex: none;
  padding: 4px;
  background: var(--wiz-card);
  border: 1px solid var(--wiz-line);
  border-radius: 9px;
  cursor: pointer;
}
.wiz-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.wiz-color-input::-webkit-color-swatch { border: 0; border-radius: 5px; }
.wiz-color-input::-moz-color-swatch { border: 0; border-radius: 5px; }
.wiz-color-input:focus-visible { outline: none; border-color: var(--wiz-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wiz-primary) 18%, transparent); }
.wiz-color-value {
  display: inline-block;
  min-width: 94px;
  padding: 7px 9px;
  color: var(--wiz-text);
  background: var(--wiz-soft);
  border: 1px solid var(--wiz-line);
  border-radius: 7px;
  font: 600 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 92px;
  color: var(--wiz-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wizard-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--wiz-line);
  border-radius: 50%;
  background: var(--wiz-soft);
  color: var(--wiz-muted);
  font-size: 11px;
  font-weight: 700;
}
.wizard-step.is-active { color: var(--wiz-text); }
.wizard-step.is-active .wizard-step-dot {
  color: #fff;
  background: var(--wiz-primary);
  border-color: var(--wiz-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--wiz-primary) 14%, transparent);
}
.wizard-step.is-done { color: var(--wiz-text); }
.wizard-step.is-done .wizard-step-dot {
  color: #fff;
  background: var(--wiz-success);
  border-color: var(--wiz-success);
}
.wizard-step-line {
  flex: 1;
  min-width: 12px;
  height: 1px;
  margin-left: 2px;
  background: var(--wiz-line);
}

.wizard-body {
  flex: 1;
  min-height: 250px;
  padding: 24px 26px;
  overflow-y: auto;
}
.wizard-body > *:first-child { margin-top: 0; }
.wizard-body > *:last-child { margin-bottom: 0; }

.wizard-error {
  min-height: 22px;
  margin: 0;
  padding: 0 26px;
  color: var(--wiz-danger);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.wizard-error:empty { min-height: 12px; }

.wizard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 26px;
  border-top: 1px solid var(--wiz-line);
  background: var(--wiz-card);
}
.wizard-foot-right { display: flex; align-items: center; gap: 8px; }
.wizard-btn {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--wiz-line);
  border-radius: 9px;
  background: var(--wiz-card);
  color: var(--wiz-text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.wizard-btn:hover { background: var(--wiz-soft); }
.wizard-btn:disabled { opacity: 0.55; cursor: default; }
.wizard-btn-ghost { background: transparent; }
.wizard-btn-primary {
  color: #fff;
  background: var(--wiz-primary);
  border-color: var(--wiz-primary);
}
.wizard-btn-primary:hover:not(:disabled) { background: var(--wiz-primary-dark); border-color: var(--wiz-primary-dark); }
.wizard-btn[hidden] { display: none !important; }

/* Form controls used inside the wizard. */
.wiz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.wiz-grid.one { grid-template-columns: 1fr; }
.wiz-column-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-top: 18px;
}
.wiz-column-card {
  padding: 12px 14px;
  background: var(--wiz-soft);
  border: 1px solid var(--wiz-line);
  border-radius: 10px;
}
.wiz-column-card .wiz-section-title { margin: 0 0 6px; }
.wiz-grid.three,
.wiz-grid.four {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.wiz-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wiz-span { grid-column: 1 / -1; }
.wiz-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wiz-field > label,
.wiz-label {
  color: var(--wiz-text);
  font-size: 12px;
  font-weight: 700;
}
.wiz-input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--wiz-text);
  background: var(--wiz-card);
  border: 1px solid var(--wiz-line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
.wiz-input:focus {
  outline: none;
  border-color: var(--wiz-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--wiz-primary) 18%, transparent);
}
.wiz-input:disabled { color: var(--wiz-muted); background: var(--wiz-soft); cursor: not-allowed; }
.wiz-input::placeholder { color: var(--wiz-muted); opacity: 0.8; }
.wiz-help { margin: 0; color: var(--wiz-muted); font-size: 11px; line-height: 1.45; }

/* The choices of a dropdown, one row each. */
.wiz-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.wiz-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--wiz-soft);
  border: 1px solid var(--wiz-line);
  border-radius: 10px;
}

.wiz-choice-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 28px;
  padding: 0;
  color: var(--wiz-muted);
  background: none;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  letter-spacing: -2px;
  cursor: grab;
  touch-action: none;
}
.wiz-choice-drag:hover { color: var(--wiz-text); background: var(--wiz-soft-2); }
.wiz-choice-drag:active { cursor: grabbing; }
.wiz-choice-drag:focus-visible { outline: 2px solid var(--wiz-primary); outline-offset: 1px; }
.wiz-source-preview {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  color: var(--wiz-text);
  background: var(--wiz-soft-2);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wiz-choice.is-dragging { opacity: 0.45; }
.wiz-choice.drop-above { box-shadow: inset 0 3px 0 var(--wiz-primary); }
.wiz-choice.drop-below { box-shadow: inset 0 -3px 0 var(--wiz-primary); }
.wiz-choice-label { flex: 1; min-width: 120px; }
.wiz-choice-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.wiz-choice-preview {
  display: inline-block;
  max-width: 140px;
  padding: 4px 10px;
  overflow: hidden;
  color: var(--wiz-text);
  background: var(--wiz-soft-2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wiz-choice-colours {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.wiz-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.18);
  cursor: pointer;
}
.wiz-swatch.is-active { border-color: var(--wiz-text); }
.wiz-swatch-none {
  background: linear-gradient(135deg, #e2e8f0 25%, #fff 25%, #fff 50%, #e2e8f0 50%, #e2e8f0 75%, #fff 75%);
}
.wiz-choice-custom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--wiz-muted);
  font-size: 11px;
  cursor: pointer;
}
.wiz-choice-custom input {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.wiz-choice-remove {
  padding: 2px 7px;
  font-size: 16px;
  line-height: 1;
}

.wiz-card-condition {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  background: var(--wiz-soft);
  border: 1px solid var(--wiz-line);
  border-radius: 10px;
}
@media (max-width: 600px) {
  .wiz-choice { flex-direction: column; align-items: stretch; }
  .wiz-choice-side { justify-content: space-between; }
}
.wiz-note {
  margin-top: 16px;
  padding: 11px 13px;
  color: var(--wiz-muted);
  background: var(--wiz-soft);
  border: 1px solid var(--wiz-line);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
}
.wiz-note strong { color: var(--wiz-text); }
.wiz-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--wiz-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.wiz-check input { width: 16px; height: 16px; accent-color: var(--wiz-primary); }

// A row of checkboxes, for the places a column appears.
.wiz-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 4px;
}
.wiz-section-title {
  margin: 0 0 4px;
  color: var(--wiz-text);
  font-size: 16px;
  line-height: 1.3;
}
.wiz-section-sub { margin: 0 0 18px; color: var(--wiz-muted); font-size: 12px; line-height: 1.5; }

/* Review and result content. */
.wiz-review {
  overflow: hidden;
  border: 1px solid var(--wiz-line);
  border-radius: 11px;
  background: var(--wiz-card);
}
.wiz-review-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--wiz-line);
  font-size: 13px;
}
.wiz-review-row:last-child { border-bottom: 0; }
.wiz-review-row span { color: var(--wiz-muted); }
.wiz-review-row strong { text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.wiz-review-row code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--wiz-soft-2);
  font-size: 12px;
}
.wiz-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 4px;
  text-align: center;
}
.wiz-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  color: var(--wiz-success);
  background: color-mix(in srgb, var(--wiz-success) 12%, transparent);
  border-radius: 50%;
}
.wiz-success h3 { margin: 0 0 4px; font-size: 19px; }
.wiz-success > p { max-width: 48ch; margin: 0 0 16px; color: var(--wiz-muted); font-size: 13px; }
.wiz-secret {
  width: 100%;
  max-width: 520px;
  padding: 12px 14px;
  border: 1px dashed var(--wiz-line);
  border-radius: 10px;
  background: var(--wiz-soft);
}
.wiz-secret-label { display: block; margin-bottom: 6px; color: var(--wiz-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.wiz-secret-value {
  display: block;
  padding: 8px 0;
  color: var(--wiz-text);
  font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.wiz-secret-actions { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.wiz-copy {
  min-height: 34px;
  padding: 6px 12px;
  color: var(--wiz-text);
  background: var(--wiz-card);
  border: 1px solid var(--wiz-line);
  border-radius: 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.wiz-copy:hover { background: var(--wiz-soft-2); }
.wiz-detail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--wiz-muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.wiz-detail a { color: var(--wiz-primary); font-weight: 700; text-decoration: none; }
.wiz-detail a:hover { text-decoration: underline; }
.wiz-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}

@media (max-width: 640px) {
  .wizard-overlay { padding: 0; align-items: stretch; }
  .wizard {
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .wizard-head { padding: 18px 18px 0; }
  .wizard-head h2 { font-size: 19px; }
  .wizard-steps { padding: 14px 18px 12px; }
  .wizard-step { min-width: 0; flex: 0 0 auto; }
  .wizard-step-label { display: none; }
  .wizard-step-line { min-width: 20px; }
  .wizard-step.is-active .wizard-step-label { display: inline; }
  .wizard-body { padding: 18px; min-height: 0; }
  .wizard-error { padding: 0 18px; }
  .wizard-foot { padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .wizard-foot-right { flex: 1; justify-content: flex-end; }
  .wizard-btn { min-height: 42px; }
  .wiz-grid,
  .wiz-grid.three,
  .wiz-grid.four { grid-template-columns: 1fr; gap: 14px; }
  .wiz-column-options { grid-template-columns: 1fr; }
  .wiz-review-row { flex-direction: column; gap: 3px; }
  .wiz-review-row strong { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .wizard { animation: none; }
}

/* ------------------------------------------------------------------
   The setup wizard
------------------------------------------------------------------
   The lists a company picks from: what it follows, what its stages
   are, what it calls them, and what it counts.
------------------------------------------------------------------ */

.setup-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.setup-pick {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--wiz-line);
  border-radius: var(--wiz-radius);
  background: var(--wiz-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.setup-pick:hover { border-color: var(--wiz-primary); }
.setup-pick.is-on { border-color: var(--wiz-primary); background: var(--wiz-soft); }
.setup-pick input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--wiz-primary); flex: none; }
.setup-pick-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setup-pick-text strong { font-size: 13px; font-weight: 700; color: var(--wiz-text); }
.setup-pick-text .muted { font-size: 11px; line-height: 1.45; color: var(--wiz-muted); }
.setup-pick-tag {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--wiz-line);
  color: var(--wiz-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.setup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.setup-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--wiz-line);
  border-radius: 999px;
  background: var(--wiz-soft);
  color: var(--wiz-text);
  font-size: 12px;
  font-weight: 600;
}

.setup-chip-x {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--wiz-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.setup-chip-x:hover { background: var(--wiz-line); color: var(--wiz-text); }

.setup-column {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.2fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--wiz-line);
}

.setup-column:last-child { border-bottom: 0; }

.setup-card {
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--wiz-line);
  border-radius: var(--wiz-radius);
  background: var(--wiz-soft);
}

.setup-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.setup-card-head .wiz-input { flex: 1; }

/* ------------------------------------------------------------------
   The offer
------------------------------------------------------------------ */

.setup-offer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.setup-offer-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 16px;
  background: var(--surface, #fff);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.setup-offer-card h2 { margin: 4px 0 12px; font-size: 20px; font-weight: 800; }
.setup-offer-card p { margin: 0 0 12px; font-size: 13px; line-height: 1.6; color: var(--text, #334155); }
.setup-offer-card p.muted { color: var(--muted, #64748b); font-size: 12px; }
.setup-offer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 620px) {
  .setup-column { grid-template-columns: 1fr; }
  .setup-offer-card { padding: 22px; }
}

.setup-pick-choices {
  font-size: 11px;
  color: var(--wiz-muted);
  opacity: 0.85;
}

.setup-add {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--wiz-line);
  border-radius: var(--wiz-radius);
  background: var(--wiz-soft);
}

.setup-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
