.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 33, 61, .45);
}
.modal__dialog {
  position: relative;
  width: 46rem;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(20, 33, 61, .28);
}
.modal__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px 18px 32px;
  border-bottom: 1px solid var(--line-2);
}
.modal__title {
  margin-right: auto;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
}
.modal__close {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.modal__close:hover { background: #F2F5FA; color: var(--ink); }
.modal__controls {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 22px 32px 0;
}
.modal__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal__field label { font-size: 0.9375rem; color: var(--ink); white-space: nowrap; }
.modal__field > .modal__field-select.select { width: 6.25rem; }
.modal__field .modal__field-select.select { min-height: 42px; }
.modal__hint {
  flex: 0 0 auto;
  padding: 14px 32px 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted-3);
}
.modal__foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px 24px;
  padding: 18px 24px;
  border-top: 1px solid var(--line-2);
}
.modal__cancel {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.9688rem;
  font-weight: 600;
  cursor: pointer;
}
.modal__cancel:hover { color: var(--brand-dark); }
@media (max-width: 600px), (max-height: 620px) {
  .modal__dialog { overflow-y: auto; overscroll-behavior: contain; }
  .modal__foot {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: var(--surface);
    border-radius: 0 0 12px 12px;
  }
}

.modal__dialog--narrow { width: 34rem; }
.modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 32px 8px;
}
.modal__done {
  flex: 1 1 auto;
  padding: 32px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.modal__done:focus { outline: none; }
.modal__done h3 { font-size: 1.25rem; font-weight: 700; }
.modal__done p {
  max-width: 28rem; font-size: 0.9688rem; line-height: 1.5; color: var(--muted);
}
.modal__done-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__done-icon svg { width: 26px; height: 26px; }
@media (max-width: 600px) {
  .modal { padding: 12px; }
  .modal__dialog { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .modal__head { padding: 14px 12px 12px 18px; }
  .modal__controls { padding: 16px 18px 0; }
  .modal__hint { padding: 12px 18px 0; }
  .modal__foot { padding: 12px 18px; }
  .modal__foot .modal__foot-btn.btn { flex: 1 1 auto; }
  .modal__body { padding: 16px 18px 8px; }
  .modal__done { padding: 24px 18px 16px; }
}

@media (max-width: 600px), (max-height: 620px) {
  .modal__body { flex: none; overflow: visible; }
}
