/* ============================================================
   modal.css — модальные окна и тосты
   ============================================================ */

.modal-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}
.modal-root .modal-overlay {
  pointer-events: auto;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}
.toast-root .toast {
  pointer-events: auto;
}

body.has-modal {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity var(--t);
  z-index: 1000;
}
.modal-overlay.is-open {
  opacity: 1;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--t);
}
.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1040px; }

.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  position: relative;
}

/* ИСПРАВЛЕНИЕ: жесткая фиксация шапки модалки */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-elevated);
  position: relative;
  z-index: 10;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
  border-left: 4px solid var(--accent);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t), transform var(--t);
}
.toast.is-open {
  opacity: 1;
  transform: translateY(0);
}

.toast-info    { border-left-color: var(--accent); }
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error   { border-left-color: var(--danger); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 8px;
  color: var(--text-muted);
}
.empty-icon {
  width: 40px;
  height: 40px;
  opacity: 0.6;
}
.empty-text {
  font-size: 14px;
}

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}
.skeleton-row {
  height: 14px;
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton-row:nth-child(2) { width: 85%; }
.skeleton-row:nth-child(3) { width: 65%; }
.skeleton-row:nth-child(4) { width: 75%; }
.skeleton-row:nth-child(5) { width: 55%; }

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }
  .modal {
    max-width: none;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: calc(100vh - 24px);
  }
  .modal-inner {
    max-height: calc(100vh - 24px);
  }
  .toast-root {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    min-width: 0;
    max-width: none;
  }
}