/* ==================== 7. MODAIS E TOAST ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.ativo {
  display: flex;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);

  /* NOVAS REGRAS: Limita a altura e adiciona rolagem */
  max-height: 90vh;
  overflow-y: auto;
}

/* Barra de rolagem estilizada dentro do modal */
.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  /* Garante que os botões fiquem visíveis mesmo com rolagem */
  padding-top: 16px;
  border-top: 1px solid var(--border);
  /* Uma linha sutil para separar */
}

.modal-actions button {
  width: auto;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--txt);
  color: var(--bg);
  padding: 16px 24px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  transition: 0.3s;
  z-index: 9999;
}

.toast.on {
  opacity: 1;
}


/* ===== Padrão único dos modais (todas as telas) ===== */
.modal-overlay .modal-content, .modal-overlay .modal-box { position: relative; }
.modal-overlay .md-x { position: absolute; top: 14px; right: 14px; z-index: 3; width: 34px; height: 34px; padding: 0; margin: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; cursor: pointer; background: rgba(148, 163, 184, 0.14); color: var(--muted); border: 0; box-shadow: none; }
.modal-overlay .md-x:hover { background: rgba(148, 163, 184, 0.26); color: var(--txt); }
.modal-overlay .modal-content > h2:first-of-type, .modal-overlay .modal-box > h2:first-of-type { padding-right: 44px; }
/* botão principal (Salvar/Confirmar) sempre laranja; o de excluir/sair continua vermelho */
.modal-overlay .modal-actions button:not(.ghost):not(.md-x):not([style*="red"]):not([style*="ef4444"]):not(.perigo):not(.danger),
.modal-overlay .ghost ~ button:not(.ghost):not(.md-x):not([style*="red"]):not([style*="ef4444"]):not(.perigo):not(.danger) {
  background: linear-gradient(135deg, #ff6a1a, #ffa04a) !important; color: #fff !important; border: 0 !important; box-shadow: 0 8px 20px rgba(255, 106, 26, 0.28);
}