:root {
  --bg: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d8d8de;
  --blue: #0066cc;
  --green: #0b7a3e;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.wizard { width: min(100%, 660px); }
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 0 16px;
  padding: 0;
  gap: 5px;
  list-style: none;
}
.steps button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 12px;
  padding: 9px 4px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(.72rem, 2.8vw, .86rem);
  font-weight: 600;
  white-space: nowrap;
}
.steps button span {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #e7e7ec;
  font-size: .73rem;
}
.steps button:not(:disabled):hover { background: #ebebf0; }
.steps button[aria-current="step"] { color: #004f9f; }
.steps button[aria-current="step"] span { background: #dcecff; }

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 490px;
  overflow: hidden;
  border: 1px solid #e6e6ea;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 18px 48px rgb(22 28 45 / 6%);
}

/* Live Pending Action Banner */
.pending-banner {
  border-bottom: 1px solid #e4eefb;
  background: #f3f8ff;
}
.pending-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--blue), #4da3ff, transparent);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.pending-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 20px;
  font-size: .83rem;
  font-weight: 600;
  color: #004f9f;
}
.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }
.pending-elapsed {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 500;
}

.pane {
  flex: 1;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 5vw, 38px);
  animation: enter .22s cubic-bezier(.2, .75, .3, 1) both;
}
@keyframes enter {
  from { opacity: 0; transform: translateX(var(--slide-from, 20px)); }
  to { opacity: 1; transform: translateX(0); }
}

h1 {
  margin: 0 0 20px;
  font-size: clamp(1.85rem, 5.2vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.08;
}
h1:focus { outline: none; }
form { margin: 0; }
.pane > form:not(.composer) { flex: 1; display: flex; flex-direction: column; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: .86rem;
  font-weight: 600;
}
label span { color: var(--muted); font-weight: 400; margin-inline-start: 4px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea {
  width: 100%;
  min-width: 0;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  color: inherit;
  line-height: 1.45;
}
textarea { resize: vertical; }
#task { min-height: 100px; max-height: 165px; resize: none; margin-bottom: 16px; }

.brief-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.upload { margin-top: 14px; }
.upload input { background: transparent; padding: 6px 0; font-size: .84rem; }
.upload input::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: #e7f2fe;
  color: #004f9f;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.actions {
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}
.actions .back { margin-right: auto; }
.primary, .text-button, .secondary {
  min-height: 41px;
  padding: 9px 15px;
  border: 0;
  border-radius: 11px;
  font-weight: 600;
  font-size: .89rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.primary { background: var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: #005bb8; }
.primary:disabled { background: #ebebf0; color: var(--muted); }
.secondary { background: #eaf3fd; color: #004f9f; }
.secondary:hover:not(:disabled) { background: #dcecff; }
.text-button { background: transparent; color: var(--blue); }
.text-button:hover:not(:disabled) { background: #f2f7fc; }
.small-link { font-size: .82rem; min-height: 32px; padding: 4px 10px; }

/* Step 2: Consult */
.chat {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 160px;
  overflow: auto;
  padding: 4px;
  margin: -4px -4px 12px;
}
.chat p {
  margin: 0;
  max-width: 92%;
  justify-self: start;
  background: #f0f0f3;
  padding: 9px 13px;
  border-radius: 13px;
  font-size: .89rem;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat p.user { justify-self: end; background: #e7f2fe; }
.examples { display: grid; gap: 8px; }
.example {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 13px;
  background: #e4e6eb;
  border: 1px solid #e4e6eb;
}
.example > div { background: #f8f8fa; padding: 10px 12px; }
.example h2 { margin: 0 0 5px; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.example p {
  margin: 0;
  max-height: 88px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: .84rem;
  line-height: 1.42;
}
.composer { display: flex; gap: 8px; align-items: end; margin-top: 12px; }
.composer textarea { resize: none; max-height: 96px; }
.send { align-self: stretch; }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* Step 3: Tiers, Splits & Checkout */
#tiers-view, #checkout-view, #payment-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.checkout-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
}
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input { accent-color: var(--blue); }
.tiers { display: grid; gap: 8px; }
.tier {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.tier:has(input:checked) { border-color: var(--blue); background: #f2f7fd; }
.tier input { width: auto; margin-top: 4px; accent-color: var(--blue); }
.tier-title { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: 6px; }
.tier-details { margin: 4px 0 0; padding-inline-start: 16px; font-size: .78rem; color: var(--muted); line-height: 1.45; }
.tier-price-col { text-align: right; white-space: nowrap; }
.tier-price-col strong { display: block; font-size: 1rem; }
.tier-price-col small { color: var(--muted); font-size: .74rem; }

.heading-row, .status-heading {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.status-heading p:first-child { min-width: 0; flex: 1; }
.price { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -.03em; }
.split-card, .deployment-card {
  min-width: 0;
  max-width: 100%;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border: 1px solid #e4e7ee;
  border-radius: 13px;
  background: #f9fafc;
  font-size: .82rem;
}
.split-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.split-pill {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #e7eaf0;
}
.split-pill span { display: block; font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-pill strong { font-size: .88rem; }
.subtle-line { margin: 4px 0 8px; color: var(--muted); font-size: .8rem; line-height: 1.4; overflow-wrap: anywhere; }
.checkout-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.sub-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e6e8ef;
}

/* Step 4: Train, Download & Verda Deployment */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e7f5ee;
  color: var(--green);
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.run-status { margin-top: 4px; min-width: 0; }
.status-heading p { margin: 0 0 9px; font-size: .9rem; font-weight: 600; }
.status-heading .percent { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #ebebf0;
}
progress::-webkit-progress-bar { background: #ebebf0; }
progress::-webkit-progress-value { background: var(--blue); border-radius: 10px; transition: width .25s ease; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 10px; }
.logs {
  max-height: 6.2rem;
  overflow: auto;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
}

.delivery-panel { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.delivery-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.deploy-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.kv-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: .8rem;
  min-width: 0;
}
.kv-row span { color: var(--muted); font-weight: 600; }
.kv-row code, .kv-row a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .76rem;
  color: var(--ink);
}
.copy-btn {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: .74rem;
  font-weight: 600;
}
.curl-box {
  margin: 8px 0 0;
  padding: 9px 11px;
  max-width: 100%;
  border-radius: 9px;
  background: #171923;
  color: #e9eef8;
  font-size: .72rem;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.45;
}

.error { margin: 10px 0 0; color: #a12020; font-size: .86rem; font-weight: 500; }
.sr-only, .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

button[data-loading]:disabled {
  background: var(--blue);
  color: #fff;
  opacity: .92;
}
button.secondary[data-loading]:disabled, button.text-button[data-loading]:disabled {
  background: #dcecff;
  color: #004f9f;
}
button[data-loading]:disabled::before {
  content: "";
  display: inline-block;
  width: .8em;
  height: .8em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: loading-spin .75s linear infinite;
}
@keyframes loading-spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .brief-fields, .split-grid, .example { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: 1fr auto; }
  .kv-row span { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .pane, .pending-bar, .pending-dot, button[data-loading]:disabled::before { animation: none; }
  progress::-webkit-progress-value { transition: none; }
}

#restore-status { display: none; }
.restoring-session #restore-status { display: block; }
.restoring-session .wizard > nav, .restoring-session .wizard > .stage { display: none; }

#delivery-choice { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; border: 0; padding: 0; margin: 0 0 1.25rem; }
#delivery-choice legend { margin-bottom: .5rem; font-weight: 600; }
#delivery-choice label { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
#delivery-choice input { width: auto; margin: 0; }
