body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 4, 15, 0.42);
  z-index: 200;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 210;
}

.modal-window {
  width: min(760px, calc(100vw - 32px));
  max-height: 88vh;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 4, 15, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-window-lg {
  width: min(860px, calc(100vw - 32px));
}

/* 🔥 CRITICAL FIX FOR SCROLLING */
.modal-form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid #edf2f7;
  background: #fff;
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--warning-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.modal-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--deep-harbor);
}

.modal-subtitle {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 680px;
}

.modal-close {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.modal-close:hover {
  background: var(--snowcap);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
}

.modal-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf2f7;
}

.modal-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.modal-section-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--deep-harbor);
}

.modal-form .form-grid {
  display: grid;
  gap: 16px 18px;
}

.modal-form .form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-form .form-grid.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.req {
  color: #c43b3b;
}

.field input,
.field select,
.field textarea,
.search-select-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

.field input[type="file"] {
  padding: 10px 12px;
  min-height: 44px;
}

.field textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-select-input:focus {
  outline: none;
  border-color: var(--pinnacle-blue);
  box-shadow: 0 0 0 3px rgba(45, 149, 234, 0.12);
}

.sensitive-wrap {
  position: relative;
}

.sensitive-wrap input {
  padding-right: 44px;
}

.sensitive-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.search-select {
  position: relative;
}

.search-select-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(10, 58, 98, 0.12);
  z-index: 20;
  display: none;
}

.search-select-results.active {
  display: block;
}

.search-select-option {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f4f8;
}

.search-select-option:last-child {
  border-bottom: 0;
}

.search-select-option:hover {
  background: var(--snowcap);
}

.form-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.modal-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid #edf2f7;
  background: #fff;
}

/* RESPONSIVE */

@media (max-width: 900px) {
  .modal-shell {
    padding: 16px;
  }

  .modal-window,
  .modal-window-lg {
    width: 100%;
    max-height: 90vh;
  }

  .modal-form .form-grid.two-col,
  .modal-form .form-grid.three-col {
    grid-template-columns: 1fr;
  }

  .modal-title {
    font-size: 22px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 640px) {
  .modal-shell {
    padding: 10px;
  }

  .modal-window,
  .modal-window-lg {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-header {
    padding: 16px 14px 12px;
  }

  .modal-body {
    padding: 14px;
  }

  .modal-footer {
    padding: 12px 14px 16px;
  }

  .modal-title {
    font-size: 20px;
  }

  .modal-subtitle {
    font-size: 12px;
  }

  .modal-section-title {
    font-size: 16px;
  }
}