*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition), color var(--transition);
}

/* =========================================================
   BARRA DE DESPLAZAMIENTO GLOBAL INSTITUCIONAL (Scrollbar)
   ========================================================= */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

input, button, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.hidden {
  display: none !important;
}

/* =========================================================
   MODAL DE CONFIRMACIÓN INSTITUCIONAL (Estilo Institucional)
   ========================================================= */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.confirm-overlay:not(.open) {
  display: none !important;
}

.confirm-overlay.open {
  display: flex !important;
}

/* =========================================================
   MODAL OVERLAY GLOBAL
   ========================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active,
.modal-overlay.open {
  display: flex !important;
}

.confirm-box {
  background: #ffffff;
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius-lg, 8px);
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: confirmPopIn 0.15s ease-out;
}

@keyframes confirmPopIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.confirm-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.confirm-header .modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 0 4px;
}

.confirm-header .modal-close:hover {
  color: #0f172a;
}

.confirm-body {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 16px;
}

.confirm-icon-q {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e0efe9;
  color: var(--color-primary, #1a3734);
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.confirm-msg {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.45;
}

.confirm-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-confirm-yes {
  padding: 7px 22px;
  background: var(--color-primary, #1a3734) !important;
  color: #ffffff !important;
  border: 1px solid var(--color-primary, #1a3734) !important;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(26, 55, 52, 0.15);
  transition: all 0.15s ease;
}

.btn-confirm-yes:hover {
  background: #142a27 !important;
  transform: translateY(-1px);
}

.btn-confirm-no {
  padding: 7px 20px;
  background: #ffffff !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-confirm-no:hover {
  background: #f1f5f9 !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
}

/* =========================================================
   MODAL DE INFORMACIÓN / ATENCIÓN / ERROR (Estilo Institucional)
   ========================================================= */
.clinica-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.clinica-modal-overlay:not(.open) {
  display: none !important;
}

.clinica-modal-overlay.open {
  display: flex !important;
}

.clinica-modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg, 10px);
  border: 1px solid #cbd5e1;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: confirmPopIn 0.15s ease-out;
}

.clinica-modal-hdr {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clinica-modal-body {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #1e293b;
  font-size: 0.95rem;
  line-height: 1.45;
}

.clinica-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e0efe9;
  color: var(--color-primary, #1a3734);
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.clinica-modal-ftr {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 12px 16px;
  display: flex;
  justify-content: flex-end;
}

.btn-clinica-accept {
  padding: 7px 24px;
  background: var(--color-primary, #1a3734) !important;
  color: #ffffff !important;
  border: 1px solid var(--color-primary, #1a3734) !important;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(26, 55, 52, 0.15);
  transition: all 0.15s ease;
}

.btn-clinica-accept:hover {
  background: #142a27 !important;
  transform: translateY(-1px);
}

/* =========================================================
   SISTEMA INSTITUCIONAL DE ALERTAS Y TOASTS (Armendáriz)
   ========================================================= */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 460px;
  width: calc(100% - 48px);
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-left: 5px solid var(--color-primary, #1a3734);
  opacity: 0;
  transform: translateX(40px) scale(0.96);
  transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-msg {
  flex: 1;
  color: #1e293b;
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

/* 1. Verde (#1a3734 / Éxito / Tareas realizadas y procesos completados) */
.toast-success {
  border-left-color: #1a3734 !important;
  border-top-color: #e2e8f0;
  border-right-color: #e2e8f0;
  border-bottom-color: #e2e8f0;
}
.toast-success .toast-icon {
  background: #e0efe9 !important;
  color: #1a3734 !important;
}

/* 2. Amarillo / Ámbar (#d97706 / Procesos en espera, pendientes o advertencias) */
.toast-warning {
  border-left-color: #d97706 !important;
  border-top-color: #fef3c7;
  border-right-color: #fef3c7;
  border-bottom-color: #fef3c7;
}
.toast-warning .toast-icon {
  background: #fef3c7 !important;
  color: #d97706 !important;
}

/* 3. Rojo Clínico (#dc2626 / Errores o procesos que no se pudieron hacer) */
.toast-error {
  border-left-color: #dc2626 !important;
  border-top-color: #fee2e2;
  border-right-color: #fee2e2;
  border-bottom-color: #fee2e2;
}
.toast-error .toast-icon {
  background: #fee2e2 !important;
  color: #dc2626 !important;
}
