/* ── Modal ── */
#modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  pointer-events: none;
  visibility: hidden;
}
#modal.is-open {
  pointer-events: auto;
  visibility: visible;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  transition: background 200ms ease;
  cursor: pointer;
}
#modal.is-open .modal__backdrop {
  background: rgba(0,0,0,0.5);
}
.modal__dialog {
  position: relative; z-index: 1;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
}
#modal.is-open .modal__dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}
/* Размеры */
.modal__dialog--small  { max-width: 380px; }
.modal__dialog--medium { max-width: 560px; }
.modal__dialog--large  { max-width: 780px; }

.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.modal__title {
  font-size: 1rem; font-weight: 600; color: #1a1a1a;
}
.modal__close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  font-size: 1.25rem; cursor: pointer;
  background: none; border: none; color: #888;
  transition: background 0.15s, color 0.15s;
}
.modal__close:hover { background: #f0f0f0; color: #333; }
.modal__body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal__loader {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem 1rem;
}
@keyframes modal-spin { to { transform: rotate(360deg); } }
.loader {
  display: block; width: 28px; height: 28px;
  border: 2.5px solid #e0e0e0;
  border-top-color: #01696f;
  border-radius: 50%;
  animation: modal-spin 0.7s linear infinite;
}
.modal__error {
  text-align: center; padding: 2rem;
  color: #888; font-size: 0.875rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.btn-link {
  background: none; border: none; color: #01696f;
  text-decoration: underline; cursor: pointer;
  font-size: 0.875rem; padding: 0; font-family: inherit;
}
body.modal-open { overflow: hidden; }

/* Мобильные — слайд снизу */
@media (max-width: 480px) {
  #modal { align-items: flex-end; padding: 0; }
  .modal__dialog {
    border-radius: 12px 12px 0 0;
    max-width: 100%;
    transform: translateY(100%);
  }
  #modal.is-open .modal__dialog { transform: translateY(0); }
}