.wizard-page {
  display: grid;
  gap: 20px;
  position: relative;
}

.wizard-page .forms-page-title-row {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.wizard-page .forms-page-actions {
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
}

.wizard-page .forms-page-action-buttons {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.wizard-page .forms-page-action-buttons:empty {
  display: none;
}

.wizard-page-status {
  text-align: right;
}

.wizard-page-status .approval-status {
  font-size: 16px;
}

.wizard-page-status .approval-status.is-success {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--fg-soft);
}

.wizard-page-status .wizard-status-note {
  font-size: 15px;
}

.wizard-page-heading {
  display: grid;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
}

.wizard-page .page-title {
  font-size: clamp(calc(38px - 2pt), calc(6vw - 2pt), calc(56px - 2pt));
  min-width: 0;
}

.wizard-page-subline {
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: clamp(calc(38px - 14pt), calc(6vw - 14pt), calc(56px - 14pt));
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0;
}

.wizard-list-table td.wizard-wrap-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.wizard-list-table tbody tr:focus-visible {
  outline: 2px solid var(--line-strong);
  outline-offset: -2px;
}

.updated-created {
  align-items: stretch;
  display: inline-flex;
  gap: 0.4em;
  white-space: nowrap;
}

.updated-created-pair,
.updated-created-sep {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.updated-created-pair {
  align-items: center;
  text-align: center;
}

.updated-created-sep {
  align-items: center;
  justify-content: space-between;
}

.updated-created-time,
.updated-created-date,
.updated-created-sep span {
  display: block;
  line-height: 1.25;
}

.wizard-status-note {
  color: var(--mute);
  display: block;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  margin-top: 3px;
  text-transform: uppercase;
}

.wizard-form {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1100px;
  min-width: 0;
}

.wizard-form .wizard-form-host,
.wizard-form-host.input-form-fields-grid {
  display: grid;
  gap: 18px 20px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr);
}

.wizard-form-host > .wizard-form-fields {
  display: grid;
  gap: 18px 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wizard-form .input-form-group-box {
  grid-column: 1 / -1;
  margin: 0;
}

.wizard-form-skeleton-row {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  border-radius: 8px;
  grid-column: 1 / -1;
  min-height: 4rem;
}

[data-theme="dark"] .wizard-form-skeleton-row {
  background: color-mix(in srgb, var(--fg) 14%, transparent);
}

.wizard-form .input-form-related-record {
  margin-top: 4px;
}

.wizard-form .input-form-related-record.is-lookups-locked [data-related-mode="existing"],
.wizard-form .input-form-related-record.is-lookups-locked [data-related-search] {
  cursor: not-allowed;
  opacity: 0.6;
}

.wizard-form .input-form-related-record.is-lookups-locked .input-form-related-combobox [data-related-search],
.wizard-form .input-form-related-record.is-lookups-locked [data-related-toggle] {
  cursor: not-allowed;
  opacity: 1;
}

.wizard-form .input-form-related-modes button {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.wizard-form [data-related-edit],
.wizard-form [data-related-change],
.wizard-form [data-open-sales-contract],
.wizard-form [data-change-first-call-contract] {
  border-radius: 8px;
}

.wizard-form .input-form-related-record,
.wizard-form .input-form-related-create,
.wizard-form .input-form-related-existing,
.wizard-form .input-form-related-create-grid {
  max-width: none;
  width: 100%;
}

.wizard-form .input-form-related-create {
  gap: 18px;
}

.wizard-form .input-form-related-create-grid {
  gap: 18px 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wizard-form .input-form-related-create-grid > .field,
.wizard-form .input-form-related-create-grid > .input-form-field {
  min-width: 0;
}

.wizard-form .input-form-related-create label > span,
.wizard-form .input-form-related-existing label > span,
.wizard-form .google-address-lookup-label,
.wizard-form .sub-customer-toggle,
.wizard-form .sub-customer-toggle span {
  color: var(--fg-soft);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-transform: none;
}

.wizard-form .input-form-nok-name-row {
  gap: 12px 16px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 25%);
  max-width: 100%;
  min-width: 0;
}

.wizard-form .input-form-nok-name-row .sub-customer-toggle {
  min-height: 46px;
  min-width: 0;
}

.wizard-form .input-form-related-kind-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
}

.wizard-form .input-form-related-create input,
.wizard-form .input-form-related-existing input {
  font-size: 16px;
  width: 100%;
}

.wizard-form .input-form-related-combobox {
  max-width: none;
}

.wizard-form [data-field-group="funeral_director_interment"] .input-form-related-existing {
  max-width: none;
  width: 100%;
}

.wizard-form [data-field-group="funeral_director_interment"] .input-form-related-combobox {
  justify-self: start;
  margin-right: auto;
  max-width: 50%;
  width: 50%;
}

.wizard-form [data-field-group="funeral_director_interment"] .input-form-related-combobox .input-form-related-results {
  max-width: 200%;
  min-width: 100%;
  right: auto;
  width: max-content;
}

@media (max-width: 640px) {
  .wizard-form [data-field-group="funeral_director_interment"] .input-form-related-combobox {
    max-width: 100%;
    width: 100%;
  }

  .wizard-form [data-field-group="funeral_director_interment"] .input-form-related-combobox .input-form-related-results {
    max-width: 100%;
    width: 100%;
  }
}

.wizard-form .input-form-related-combobox input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.wizard-form .sub-customer-toggle input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
}

.wizard-form [data-input-form-products],
.wizard-form [data-input-form-down-payments],
.wizard-form [data-input-form-assignments],
.wizard-form .input-form-product-grid,
.wizard-form .input-form-finance-box {
  overflow-x: auto;
}

.wizard-form .input-form-select-grid {
  gap: 20px;
}

.wizard-form .field.is-wide,
.wizard-form .input-form-field.is-wide {
  grid-column: 1 / -1;
}

.wizard-form .input-form-related-create-grid > .input-form-field:has([data-field-key="funeral_home_address"]),
.wizard-form .input-form-related-create-grid > .input-form-field:has([data-field-key="funeral_home_apartment_number"]) {
  grid-column: span 1;
}

.wizard-form .datetime-stepper-shell {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 12px;
}

.wizard-form .datetime-stepper-time-value,
.wizard-form .datetime-stepper-date-value {
  background: transparent;
  border: 0;
  color: #000;
  font-size: 16px;
  min-width: 0;
}

.wizard-form .datetime-stepper-time-value {
  min-width: 6.5rem;
  width: 6.5rem;
}

.wizard-form .datetime-stepper-date-value {
  padding: 10px 0 10px 12px;
  width: 100%;
}

.wizard-form .datetime-stepper-time-value::-webkit-calendar-picker-indicator {
  display: none;
}

.wizard-stepper-scroll {
  margin: -4px -4px 0;
  overflow-x: auto;
  padding: 4px 4px 8px;
  scroll-snap-type: x proximity;
}

.wizard-stepper {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  position: relative;
  width: 100%;
}

.wizard-step:not(:last-child)::after {
  background: var(--line-strong);
  content: "";
  height: 1px;
  left: 100%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
}

.wizard-step {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-soft);
  cursor: pointer;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 88px;
  min-width: 0;
  padding: 10px 8px 14px;
  position: relative;
  scroll-snap-align: center;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
  width: 100%;
  z-index: 1;
}

.wizard-step:disabled,
.wizard-step[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.72;
}

.wizard-step-icon {
  display: grid;
  height: 18px;
  place-items: center;
}

.wizard-step-label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.wizard-step.is-complete {
  background: var(--bg);
  border-color: var(--line-strong);
  color: var(--fg);
}

.wizard-step.is-current {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.wizard-step:hover:not(:disabled):not([aria-disabled="true"]) {
  background: color-mix(in srgb, var(--fg) 8%, var(--surface));
}

.wizard-step.is-complete:hover:not(:disabled):not([aria-disabled="true"]) {
  background: color-mix(in srgb, var(--fg) 8%, var(--surface));
  border-color: var(--fg-soft);
}

.wizard-step.is-current:hover:not(:disabled):not([aria-disabled="true"]) {
  background: color-mix(in srgb, var(--bg) 16%, var(--fg));
  border-color: color-mix(in srgb, var(--bg) 16%, var(--fg));
}

.wizard-step:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.wizard-footer {
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  position: sticky;
  z-index: 8;
}

.wizard-save-status {
  color: var(--mute);
  font-size: 12px;
}

.wizard-form [data-field-group="state-permit"] .input-form-group-body {
  align-items: stretch;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
}

.wizard-form [data-field-group="state-permit"] .input-form-group-body > p,
.wizard-form [data-field-group="state-permit"] .wizard-camera,
.wizard-form [data-field-group="state-permit"] .wizard-permit-actions,
.wizard-form [data-field-group="state-permit"] .wizard-permit-preview {
  grid-column: 1 / -1;
  margin: 0;
}

.wizard-form [data-field-group="state-permit"] .input-form-group-body > p {
  color: var(--mute);
  font-size: 13px;
}

.wizard-permit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wizard-permit-actions > .btn-ghost,
.wizard-permit-actions > .btn-primary {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.wizard-permit-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.wizard-permit-preview.is-attached {
  align-items: stretch;
  display: grid;
  gap: 12px;
}

.wizard-permit-preview-media img {
  background: #111;
  border-radius: 8px;
  display: block;
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
}

.wizard-permit-preview-media iframe {
  background: #fff;
  border: 0;
  border-radius: 8px;
  display: block;
  height: 560px;
  max-width: 100%;
  width: 100%;
}

.wizard-permit-preview-media.is-loading::before {
  color: var(--mute);
  content: "Loading preview…";
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.wizard-permit-preview-media.is-loading iframe {
  background: var(--surface);
}

.wizard-permit-preview-meta {
  align-items: center;
  display: flex;
  gap: 12px;
}

.wizard-permit-preview-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-permit-preview-fallback {
  color: var(--mute);
  font-size: 13px;
}

.wizard-permit-preview-fallback p {
  margin: 0 0 8px;
}

.wizard-permit-preview .btn-compact {
  flex-shrink: 0;
  margin-left: auto;
}

.wizard-check {
  align-items: center;
  display: flex;
  gap: 8px;
}

.wizard-camera video {
  background: #111;
  border-radius: 8px;
  max-width: 480px;
  width: 100%;
}

.wizard-confirm {
  align-items: center;
  background: rgba(26, 24, 20, 0.45);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 24px;
  position: fixed;
  z-index: 40;
}

.wizard-confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 12px;
  max-width: 460px;
  padding: 20px;
}

@media (max-width: 880px) {
  .wizard-form [data-field-group="state-permit"] .input-form-group-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .wizard-stepper {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    min-width: 100%;
    width: max-content;
  }

  .wizard-page .forms-page-actions,
  .wizard-page .forms-page-action-buttons {
    justify-content: flex-end;
    width: auto;
  }

  .wizard-page .forms-page-action-buttons .btn-primary,
  .wizard-page .forms-page-action-buttons .btn-ghost {
    flex: none;
  }

  .wizard-page .page-title {
    font-size: clamp(calc(26px - 2pt), calc(8vw - 2pt), calc(34px - 2pt));
  }

  .wizard-page-subline {
    font-size: clamp(calc(26px - 14pt), calc(8vw - 14pt), calc(34px - 14pt));
  }

  .wizard-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .wizard-footer .btn-primary,
  .wizard-footer .btn-ghost {
    width: 100%;
  }
}

@keyframes wizard-cemetery-required-flash {
  0%, 100% {
    outline-color: rgba(196, 57, 43, 0.95);
  }
  50% {
    outline-color: rgba(196, 57, 43, 0.28);
  }
}

.wizard-form .field.is-cemetery-required select {
  animation: wizard-cemetery-required-flash 1.6s ease-in-out infinite;
  outline: 1px solid #c4392b;
  outline-offset: 2px;
}

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

  .wizard-form .field.is-cemetery-required select {
    animation: none;
  }
}

.wizard-form .input-form-group-box.is-collapsed.is-mandatory-complete {
  background: var(--bg);
  border-color: var(--line-strong);
}

.wizard-page:has(.field-group-progress-lane) .input-form-group-box {
  scroll-margin-top: 16px;
}

.field-group-progress-lane {
  pointer-events: none;
  position: absolute;
  z-index: 4;
}

.field-group-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-inline: auto;
  max-height: calc(100vh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px;
  pointer-events: auto;
  position: sticky;
  top: 24px;
  width: clamp(200px, 12vw, 260px);
}

.field-group-progress-item {
  align-items: center;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-soft);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  gap: 8px;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 14px;
  text-align: left;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  width: 100%;
}

.field-group-progress-label {
  flex: 1 1 auto;
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
}

.field-group-progress-check {
  display: block;
  flex: 0 0 auto;
}

.field-group-progress-item:hover {
  background: color-mix(in srgb, var(--fg) 8%, var(--surface));
  border-color: var(--fg-soft);
}

.field-group-progress-item:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.field-group-progress-item.is-complete {
  background: var(--bg);
  border-color: var(--line-strong);
  color: var(--fg);
}

.field-group-progress-item.is-complete:hover {
  background: color-mix(in srgb, var(--fg) 8%, var(--surface));
  border-color: var(--fg-soft);
}

@media (max-width: 1599px) {
  .field-group-progress-lane {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-group-progress-item {
    transition: none;
  }
}
