.mts-service-modal-is-open {
  overflow: hidden;
}

#mts-service-modal-root {
  position: relative;
  z-index: 10000;
}

.mts-service-modal__overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(17, 24, 39, 0.45);
}

.mts-service-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 760px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 32px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  color: #111827;
  font-family: inherit;
}

.mts-service-modal__close,
.mts-service-modal__back {
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
}

.mts-service-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.mts-service-modal__close svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.mts-service-modal__close:hover {
  background: #f3f4f6;
  color: #111827;
}

.mts-service-modal__back {
  margin: -8px 0 14px;
  padding: 8px 0;
  font-size: 14px;
  line-height: 20px;
}

.mts-service-modal__back:hover {
  color: #f31331;
}

.mts-service-modal__header {
  padding: 0 48px 0 0;
  text-align: center;
}

.mts-service-modal__title {
  margin: 0 0 8px;
  color: #111827;
  font-size: 32px;
  font-weight: 700;
  line-height: 38px;
}

.mts-service-modal__subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
}

.mts-service-modal__form {
  margin: 24px 0 0;
}

.mts-service-modal__form--application {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 100%;
}

.mts-service-modal__cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mts-service-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 96px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.mts-service-card:hover {
  border-color: #ffb4b4;
  background: #fff7f7;
}

.mts-service-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: #f31331;
}

.mts-service-card__icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mts-service-card__content {
  min-width: 0;
}

.mts-service-card__title {
  display: block;
  margin: 0 0 4px;
  color: #111827;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
}

.mts-service-card__desc {
  display: block;
  color: #6b7280;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.mts-service-card__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mts-service-card__check {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 5px;
  background: #ffffff;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.mts-service-card__check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 7px;
  height: 12px;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  opacity: 0;
  transform: rotate(45deg);
}

.mts-service-card:has(.mts-service-card__input:focus-visible) {
  outline: 3px solid rgba(243, 19, 49, 0.28);
  outline-offset: 2px;
}

.mts-service-card.is-selected,
.mts-service-card:has(.mts-service-card__input:checked) {
  border-color: #f31331;
  background: #fff3f3;
  box-shadow: 0 0 0 1px rgba(243, 19, 49, 0.12);
}

.mts-service-card.is-selected .mts-service-card__title,
.mts-service-card:has(.mts-service-card__input:checked) .mts-service-card__title {
  font-weight: 700;
}

.mts-service-card.is-selected .mts-service-card__check,
.mts-service-card:has(.mts-service-card__input:checked) .mts-service-card__check {
  border-color: #f31331;
  background: #f31331;
}

.mts-service-card.is-selected .mts-service-card__check::after,
.mts-service-card:has(.mts-service-card__input:checked) .mts-service-card__check::after {
  opacity: 1;
}

.mts-service-modal__message {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin: 16px 0 12px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 13px;
  line-height: 18px;
}

.mts-service-modal__message--hidden {
  display: none;
}

.mts-service-modal__message-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid #9ca3af;
  border-radius: 50%;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.mts-service-modal__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: #f31331;
  color: #ffffff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.mts-service-modal__submit:hover:not(:disabled) {
  background: #e92a2a;
  box-shadow: 0 10px 24px rgba(243, 19, 49, 0.22);
}

.mts-service-modal__submit:disabled {
  background: #ffc9d0;
  color: #f31331;
  cursor: not-allowed;
  box-shadow: none;
}

.mts-service-modal__note {
  max-width: 440px;
  margin: 12px auto 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
}

.mts-service-modal__grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(120px, 3fr);
  gap: 16px;
}

.mts-service-modal__cell--full {
  grid-column: 1 / -1;
}

.mts-service-modal__cell--street {
  grid-column: 1 / 2;
}

.mts-service-modal__cell--house {
  grid-column: 2 / 3;
}

.mts-service-modal__field label {
  display: block;
  margin: 0 0 8px;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.mts-service-modal__field input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 16px;
  line-height: 24px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.mts-service-modal__field input:hover {
  border-color: #9ca3af;
}

.mts-service-modal__field input:focus {
  border-color: #f31331;
  outline: 3px solid rgba(243, 19, 49, 0.18);
}

.mts-service-modal__field input.is-error {
  border-color: #ef4444;
}

.mts-service-modal__field-error {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  color: #ef4444;
  font-size: 13px;
  line-height: 18px;
}

.mts-service-modal__agree {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f9fafb;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
}

.mts-service-modal__agree input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mts-service-modal__agree-check {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 5px;
  background: #ffffff;
}

.mts-service-modal__agree-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 7px;
  height: 12px;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  opacity: 0;
  transform: rotate(45deg);
}

.mts-service-modal__agree input:checked + .mts-service-modal__agree-check {
  border-color: #f31331;
  background: #f31331;
}

.mts-service-modal__agree input:checked + .mts-service-modal__agree-check::after {
  opacity: 1;
}

.mts-service-modal__agree input:focus-visible + .mts-service-modal__agree-check {
  outline: 3px solid rgba(243, 19, 49, 0.28);
  outline-offset: 2px;
}

.mts-service-modal__agree--error {
  color: #ef4444;
  background: #fff7f7;
}

.mts-service-modal__agree--error .mts-service-modal__agree-check {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.mts-service-modal__agree-error {
  display: block;
  min-height: 18px;
  margin: -4px 0 6px;
  color: #ef4444;
  font-size: 13px;
  line-height: 18px;
}

.connection-window__agree {
  max-width: 560px;
  margin: 25px 0;
}

.mts-service-modal__success {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 0 4px;
  text-align: center;
}

.mts-service-modal__submit.is-loading {
  gap: 10px;
  pointer-events: none;
}

.mts-service-modal__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: mts-service-spin 0.7s linear infinite;
}

@keyframes mts-service-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 768px) {
  .mts-legacy-application-active #modal-wrapper .connect-request,
  .mts-legacy-application-active .remodal .connect-request {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px;
    border-radius: 16px;
    background: #ffffff;
    color: #111827;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  }

  .mts-legacy-application-active #modal-wrapper .connect-request h4,
  .mts-legacy-application-active .remodal .connect-request h4 {
    margin: 0 0 8px;
    color: #111827;
    font-size: 32px;
    font-weight: 700;
    line-height: 38px;
    text-align: center;
    text-transform: none;
  }

  .mts-legacy-application-active #modal-wrapper .connect-request > p,
  .mts-legacy-application-active .remodal .connect-request > p {
    margin: 0 0 24px;
    color: #6b7280;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
  }

  .mts-legacy-application-active #modal-wrapper .connect-form .row,
  .mts-legacy-application-active .remodal .connect-form .row {
    row-gap: 16px;
  }

  .mts-legacy-application-active #modal-wrapper .input-connect input,
  .mts-legacy-application-active .remodal .input-connect input,
  .mts-legacy-application-active #modal-wrapper .input-connect textarea,
  .mts-legacy-application-active .remodal .input-connect textarea {
    min-height: 52px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    color: #111827;
    font-size: 16px;
    line-height: 24px;
  }

  .mts-legacy-application-active #modal-wrapper .input-connect input:focus,
  .mts-legacy-application-active .remodal .input-connect input:focus {
    border-color: #f31331;
    outline: 3px solid rgba(243, 19, 49, 0.18);
  }

  .mts-legacy-application-active #modal-wrapper .connect-request h5,
  .mts-legacy-application-active .remodal .connect-request h5 {
    margin: 0 0 10px;
    color: #111827;
    font-size: 16px;
    font-weight: 600;
    line-height: 22px;
  }

  .mts-legacy-application-active #modal-wrapper .form-agree,
  .mts-legacy-application-active .remodal .form-agree {
    margin: 8px 0 16px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #f9fafb;
  }

  .mts-legacy-application-active #modal-wrapper .btn--submit,
  .mts-legacy-application-active .remodal .btn--submit {
    width: 100%;
    min-height: 52px;
    border-radius: 12px;
    background: #f31331;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
  }
}

@media (max-width: 767px) {
  .mts-service-modal__overlay {
    align-items: flex-end;
    padding: 16px;
  }

  .mts-service-modal__dialog {
    width: 100%;
    max-width: 390px;
    max-height: calc(100dvh - 32px);
    padding: 20px;
    border-radius: 16px;
  }

  .mts-service-modal__header {
    padding-right: 44px;
    text-align: left;
  }

  .mts-service-modal__title {
    font-size: 24px;
    line-height: 30px;
  }

  .mts-service-modal__subtitle {
    font-size: 14px;
    line-height: 20px;
  }

  .mts-service-modal__form {
    margin-top: 20px;
  }

  .mts-service-modal__form--application {
    overflow-y: auto;
    padding-right: 2px;
  }

  .mts-service-modal__grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .mts-service-modal__cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mts-service-card {
    grid-template-columns: 44px minmax(0, 1fr) 24px;
    min-height: 88px;
    padding: 12px;
  }

  .mts-service-card__icon {
    width: 44px;
    height: 44px;
  }

  .mts-service-card__icon svg {
    width: 32px;
    height: 32px;
  }

  .mts-service-card__title {
    font-size: 15px;
    line-height: 20px;
  }

  .mts-service-card__desc {
    font-size: 12px;
    line-height: 17px;
  }

  .mts-service-modal__message {
    margin-top: 12px;
    margin-bottom: 10px;
  }

  .mts-service-modal__submit {
    position: sticky;
    bottom: 0;
    min-height: 48px;
  }

  .mts-service-modal__note {
    font-size: 12px;
    line-height: 17px;
  }
}
