:root {
  --app-vh: 100vh;
  --modal-shell-padding: clamp(12px, 2.2vw, 28px);
}

body.modal-open {
  overflow: hidden;
  padding-right: 0;
}

body:not(.landing-template) .modal {
  position: fixed;
  inset: 0;
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  place-items: center;
  padding: var(--modal-shell-padding);
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 2500;
}

body:not(.landing-template) .modal.is-open {
  display: grid !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

body:not(.landing-template) .modal-card {
  --modal-width: 780px;
  width: min(var(--modal-width), calc(100vw - (var(--modal-shell-padding) * 2)));
  margin: auto !important;
  align-self: center;
  max-height: min(940px, calc(var(--app-vh) - (var(--modal-shell-padding) * 2)));
  background: linear-gradient(180deg, #f8fafd 0%, #eef4fb 100%);
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32);
  overflow: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  animation: modalCardIn 0.18s ease;
}

body:not(.landing-template) .modal-card.modal-wide {
  --modal-width: 1180px;
}

body:not(.landing-template) .modal-entity-detail .modal-card--entity-detail {
  --modal-width: 1180px;
  overflow: hidden;
  background: linear-gradient(180deg, #f9fbff 0%, #f1f5fb 100%);
  border: 1px solid rgba(203, 213, 225, 0.82);
  border-radius: 22px;
  box-shadow: 0 26px 44px -30px rgba(15, 23, 42, 0.88), 0 16px 24px -20px rgba(15, 23, 42, 0.2);
}

body:not(.landing-template) .modal-entity-detail .entity-detail-frame-wrap {
  padding: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.62), rgba(241, 246, 253, 0.9));
}

body:not(.landing-template) .modal-entity-detail .modal-header--entity-detail {
  position: static;
  top: auto;
  z-index: auto;
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  background: #ffffff;
}

body:not(.landing-template) .modal-entity-detail .modal-close--entity-detail {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #dbe4f2;
  background: #f8fbff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

body:not(.landing-template) .modal-entity-detail .modal-close--entity-detail:hover,
body:not(.landing-template) .modal-entity-detail .modal-close--entity-detail:focus-visible {
  border-color: #c5d4ec;
  background: #eef4ff;
  color: #334155;
}

body:not(.landing-template) .modal-entity-detail .entity-detail-frame {
  min-height: clamp(460px, 74vh, 860px);
  border: 1px solid rgba(203, 213, 225, 0.84);
  border-radius: 18px;
  box-shadow: 0 16px 24px -24px rgba(15, 23, 42, 0.72), inset 0 0 0 1px rgba(226, 232, 240, 0.65);
}

body:not(.landing-template) .modal-card.modal-compact {
  --modal-width: 560px;
}

body:not(.landing-template) .modal-card > .modal-header {
  margin: 0;
}

body:not(.landing-template) .modal-header {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.14);
  background: linear-gradient(132deg, rgba(37, 99, 235, 0.2), rgba(14, 165, 164, 0.14));
}

body:not(.landing-template) .modal-card > .form,
body:not(.landing-template) .modal-card > .import-hub {
  flex: 0 0 auto;
  min-height: auto;
}

body:not(.landing-template) .modal .form,
body:not(.landing-template) .modal .import-hub {
  overflow: visible;
  padding: 20px 24px 24px;
  gap: 16px;
}

body:not(.landing-template) .modal .form + .form {
  border-top: 1px solid rgba(15, 23, 42, 0.18);
  margin-top: 6px;
  padding-top: 20px;
}

body:not(.landing-template) .modal-card > .note {
  margin: 0;
  padding: 12px 24px 0;
  background: transparent;
}

body:not(.landing-template) .modal .table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

body:not(.landing-template) .modal .form-actions,
body:not(.landing-template) .modal .step-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.12);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

body:not(.landing-template) .stepper.stepper-ready {
  display: grid;
  gap: 18px;
}

body:not(.landing-template) .stepper-progress {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(248, 250, 252, 0.9);
}

body:not(.landing-template) .stepper-progress__item {
  min-width: 0;
}

body:not(.landing-template) .stepper-progress__button {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

body:not(.landing-template) .stepper-progress__button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

body:not(.landing-template) .stepper-progress__index {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex: 0 0 auto;
}

body:not(.landing-template) .stepper-progress__label {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body:not(.landing-template) .stepper-progress__item.is-active .stepper-progress__button {
  border-color: rgba(37, 99, 235, 0.62);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.16);
}

body:not(.landing-template) .stepper-progress__item.is-complete .stepper-progress__button {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
}

body:not(.landing-template) .stepper-progress__item.is-complete .stepper-progress__index {
  border-color: rgba(16, 185, 129, 0.75);
  background: rgba(16, 185, 129, 0.18);
}

body:not(.landing-template) .stepper .step {
  display: none;
}

body:not(.landing-template) .stepper .step.is-active {
  display: grid;
  gap: 14px;
  animation: modalStepFade 0.18s ease;
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalStepFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  body:not(.landing-template) .stepper-progress {
    display: flex;
    overflow-x: auto;
    grid-template-columns: none;
  }

  body:not(.landing-template) .stepper-progress__item {
    flex: 0 0 min(230px, 70vw);
  }
}

@media (max-width: 720px) {
  body:not(.landing-template) .modal {
    place-items: center;
    --modal-shell-padding: 8px;
    padding: 8px;
  }

  body:not(.landing-template) .modal-card {
    width: min(100vw - 16px, 1000px);
    max-height: calc(var(--app-vh) - 16px);
    border-radius: 16px;
  }

  body:not(.landing-template) .modal-header {
    padding: 14px 16px;
  }

  body:not(.landing-template) .modal .form,
  body:not(.landing-template) .modal .import-hub {
    padding: 14px 16px 18px;
  }

  body:not(.landing-template) .modal-entity-detail .modal-card--entity-detail {
    width: calc(100vw - 16px);
    max-height: calc(var(--app-vh) - 16px);
  }

  body:not(.landing-template) .modal-entity-detail .modal-header--entity-detail {
    padding: 14px 14px 12px;
  }

  body:not(.landing-template) .modal-entity-detail .entity-detail-frame-wrap {
    padding: 8px;
  }

  body:not(.landing-template) .modal-entity-detail .entity-detail-frame {
    min-height: clamp(340px, 64vh, 680px);
    border-radius: 12px;
  }
}
