.sys-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  /* Por encima de todo: Ajustes de Mensajes (6000), overlay de operación (99990) y
     modales del odontograma (~100071). Debajo quedaba invisible y se quedaba el foco. */
  z-index: 200000;
  padding: 16px;
}

.sys-alert-overlay.is-open,
.sys-alert-overlay.is-closing {
  display: flex;
}

.sys-alert-overlay.is-open {
  animation: sysAlertFadeIn 0.22s ease both;
}

.sys-alert-overlay.is-closing {
  animation: sysAlertFadeOut 0.28s ease 0.12s both;
  pointer-events: none;
}

.sys-alert-modal {
  width: min(400px, 100%);
  background: #ffffff;
  border: 1px solid #dbe5f0;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
  text-align: center;
}

.sys-alert-overlay.is-open .sys-alert-modal {
  animation: sysAlertBounceIn 0.6s both;
}

.sys-alert-overlay.is-closing .sys-alert-modal {
  animation: sysAlertBounceOut 0.4s both;
}

.sys-alert-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 6px;
}

/* Icono grande centrado con "pop" al abrir (dialogos de Mensaje). */
.sys-alert-icon {
  --alert-accent: #2563eb;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--alert-accent);
  color: #ffffff;
}

.sys-alert-overlay.is-open .sys-alert-icon {
  animation: sysAlertIconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

.sys-alert-icon svg {
  width: 30px;
  height: 30px;
}

.sys-alert-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.sys-alert-body {
  padding: 4px 22px 18px;
}

.sys-alert-message {
  margin: 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}

.sys-alert-input-wrap {
  margin-top: 10px;
  display: none;
}

.sys-alert-input-wrap.is-open {
  display: block;
}

.sys-alert-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

.sys-alert-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.sys-alert-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 20px 20px;
}

.sys-alert-btn {
  min-width: 96px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.sys-alert-btn.is-cancel {
  background: #e2e8f0;
  color: #334155;
}

.sys-alert-btn:hover {
  filter: brightness(0.96);
}

.sys-alert-btn.is-cancel:hover {
  background: #cbd5e1;
  filter: none;
}

.sys-alert-btn:active {
  transform: translateY(1px);
}

.sys-alert--info .sys-alert-icon {
  --alert-accent: #2563eb;
}

.sys-alert--info .sys-alert-btn.is-primary {
  background: #2563eb;
}

.sys-alert--success .sys-alert-icon {
  --alert-accent: var(--success, #16a34a);
}

.sys-alert--success .sys-alert-btn.is-primary {
  background: var(--success, #16a34a);
}

.sys-alert--warning .sys-alert-icon {
  --alert-accent: #f59e0b;
}

.sys-alert--warning .sys-alert-btn.is-primary {
  background: #ea580c;
}

.sys-alert--error .sys-alert-icon {
  --alert-accent: var(--danger, #dc2626);
}

.sys-alert--error .sys-alert-btn.is-primary {
  background: var(--danger, #dc2626);
}

@keyframes sysAlertFadeIn {
  from { opacity: 0; }
}

@keyframes sysAlertFadeOut {
  to { opacity: 0; }
}

@keyframes sysAlertBounceIn {
  0% { opacity: 0; transform: scale(0.3); animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); }
  50% { opacity: 1; transform: scale(1.06); }
  70% { transform: scale(0.95); }
  85% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes sysAlertBounceOut {
  20% { transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 0; transform: scale(0.3); }
}

@keyframes sysAlertIconPop {
  from { transform: scale(0); }
}

@media (prefers-reduced-motion: reduce) {
  .sys-alert-overlay.is-open,
  .sys-alert-overlay.is-closing,
  .sys-alert-overlay.is-open .sys-alert-modal,
  .sys-alert-overlay.is-closing .sys-alert-modal,
  .sys-alert-overlay.is-open .sys-alert-icon {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
  }
}

/* Temas oscuros (dark / vampire) */
.dark-mode .sys-alert-modal {
  background: var(--app-surface, #0f172a);
  border: 1px solid var(--app-border, #26354a);
}

.dark-mode .sys-alert-title {
  color: var(--app-text, #e2e8f0);
}

.dark-mode .sys-alert-message {
  color: var(--app-text-muted, #9ca3af);
}

.dark-mode .sys-alert-input {
  background: var(--app-background, #0b1220);
  border-color: var(--app-border, #26354a);
  color: var(--app-text, #e2e8f0);
}

.dark-mode .sys-alert-btn.is-cancel {
  background: var(--app-nav-hover-bg, #1e293b);
  color: var(--app-text, #e2e8f0);
}

.dark-mode .sys-alert-btn.is-cancel:hover {
  background: var(--app-border, #334155);
}

.dark-mode .sys-alert-modal {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Tema princess */
body[data-theme="princess"] .sys-alert-modal { background: #ffe8f4; border: 1px solid #ff9cce; }
body[data-theme="princess"] .sys-alert-title { color: #631f50; }
body[data-theme="princess"] .sys-alert-message { color: #845872; }
body[data-theme="princess"] .sys-alert-input { background: #ffd8ec; border-color: #ff9cce; color: #4a2340; }
body[data-theme="princess"] .sys-alert-btn.is-cancel { background: #ffd7ec; color: #6b1f4f; }
body[data-theme="princess"] .sys-alert-btn.is-cancel:hover { background: #ffc2df; }

/* =====================================================
   TOASTS (window.showToast en uiAlerts.js)
===================================================== */
.sys-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.sys-toast {
  --toast-accent: #2563eb;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px 14px;
  background: #ffffff;
  border: 1px solid #dbe5f0;
  border-left: 4px solid var(--toast-accent);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
  cursor: pointer;
  pointer-events: auto;
  animation: sysToastIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.sys-toast.is-leaving,
.sys-toast.is-bump.is-leaving {
  animation: sysToastOut 0.28s ease forwards;
  pointer-events: none;
}

.sys-toast.is-bump {
  animation: sysToastBump 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sys-toast-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sys-toast-icon svg {
  width: 15px;
  height: 15px;
}

.sys-toast-body {
  min-width: 0;
  padding-top: 3px;
}

.sys-toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.sys-toast-message {
  font-size: 13px;
  line-height: 1.4;
  color: #334155;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.sys-toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: var(--toast-accent);
  opacity: 0.55;
  transform-origin: left;
  animation: sysToastBar 4s linear forwards;
}

.sys-toast:hover .sys-toast-bar {
  animation-play-state: paused;
}

.sys-toast--info { --toast-accent: #2563eb; }
.sys-toast--success { --toast-accent: var(--success, #16a34a); }
.sys-toast--warning { --toast-accent: #ea580c; }
.sys-toast--error { --toast-accent: var(--danger, #dc2626); }

.sys-toast--info .sys-toast-icon { background: #dbeafe; color: #1d4ed8; }
.sys-toast--success .sys-toast-icon { background: #dcfce7; color: #166534; }
.sys-toast--warning .sys-toast-icon { background: #ffedd5; color: #9a3412; }
.sys-toast--error .sys-toast-icon { background: #fee2e2; color: #991b1b; }

@keyframes sysToastIn {
  from { opacity: 0; transform: translateX(110%); }
}

@keyframes sysToastOut {
  to { opacity: 0; transform: translateX(110%); }
}

@keyframes sysToastBump {
  40% { transform: scale(1.03); }
}

@keyframes sysToastBar {
  to { transform: scaleX(0); }
}

/* Temas oscuros (dark / vampire) */
.dark-mode .sys-toast {
  background: var(--app-surface, #0f172a);
  border-color: var(--app-border, #26354a);
  border-left-color: var(--toast-accent);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.dark-mode .sys-toast-title { color: var(--app-text, #e2e8f0); }
.dark-mode .sys-toast-message { color: var(--app-text-muted, #9ca3af); }
.dark-mode .sys-toast--info .sys-toast-icon { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.dark-mode .sys-toast--success .sys-toast-icon { background: rgba(22, 163, 74, 0.2); color: #86efac; }
.dark-mode .sys-toast--warning .sys-toast-icon { background: rgba(234, 88, 12, 0.2); color: #fdba74; }
.dark-mode .sys-toast--error .sys-toast-icon { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }

/* Tema princess */
body[data-theme="princess"] .sys-toast { background: #ffe8f4; border-color: #ff9cce; border-left-color: var(--toast-accent); }
body[data-theme="princess"] .sys-toast-title { color: #631f50; }
body[data-theme="princess"] .sys-toast-message { color: #845872; }

@media (prefers-reduced-motion: reduce) {
  .sys-toast,
  .sys-toast.is-leaving,
  .sys-toast.is-bump {
    animation-duration: 0.01ms !important;
  }
}
