/* ── Layout CSS — Sidebar + Header Global ── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');
@import url('/theme-dark.css?v=44a727dd');

:root {
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-light: #f0f9ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 278px;
  /* Aire alrededor del panel de cristal del sidebar. --sidebar-w sigue siendo
     el CARRIL reservado (lo que .layout-main deja libre a la izquierda); el
     panel vive dentro de ese carril con este margen a cada lado, así flotar el
     sidebar no obliga a recalcular nada del contenido. */
  --sidebar-gap: 14px;
  /* Ancho del cajón móvil. Lo comparten el propio cajón y el scrim, que se
     retira exactamente esa distancia para no descubrir página sin desenfocar. */
  --drawer-w: 320px;
}

* {
  box-sizing: border-box;
}

html, body {
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  padding: 0;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar, body::-webkit-scrollbar {
  display: none;
}

/* ── Sidebar ──────────────────────────────────────────────────────────
   En PC no es una columna pegada al borde: es una TARJETA de cristal
   flotante con la misma receta que las cartas del Inicio —superficie
   translúcida con desenfoque, tinte azul que entra por la esquina
   superior y muere antes de la mitad, filo de cristal de 1px y sombra
   con halo cian por detrás—. La geometría sale de --sidebar-gap; el
   carril (--sidebar-w) no cambia, así que .layout-main sigue igual. */
#sidebar {
  position: fixed;
  top: var(--sidebar-gap);
  left: var(--sidebar-gap);
  width: calc(var(--sidebar-w) - var(--sidebar-gap) * 2);
  height: calc(100vh - var(--sidebar-gap) * 2);
  border-radius: 22px;
  background:
    radial-gradient(125% 40% at 6% -6%, rgba(14, 165, 233, 0.16) 0%, rgba(14, 165, 233, 0.055) 40%, transparent 74%),
    radial-gradient(100% 26% at 96% 104%, rgba(8, 145, 178, 0.10), transparent 72%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 249, 255, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 0;
  margin: 0;
  transition: width 0.25s ease, left 0.25s ease;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  box-shadow:
    0 0 100px rgba(8, 145, 178, 0.10),
    0 20px 50px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(8, 145, 178, 0.05);
}

/* Filo de cristal: hairline que entra por arriba-izquierda y se disuelve
   antes de la esquina opuesta, para que el borde no recorte el panel
   contra el fondo. Va por máscara (mismo truco que las tarjetas del
   Inicio) y sustituye a la antigua raya vertical del borde derecho, que
   ya no tiene sentido con el panel flotando. */
#sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(155deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.4) 26%,
    rgba(8, 145, 178, 0.12) 58%,
    transparent 84%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.05rem 1.15rem 0.95rem;
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(120deg, var(--primary-hover) 0%, var(--primary) 50%, #0ea5e9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  letter-spacing: -0.02em;
}

/* La marca va SUELTA sobre el sidebar: el PNG de la cruz lleva alfa
   (tools/gen-icons.js), así que no necesita chip blanco debajo — ese cuadro era
   justo lo que hacía que el logo se leyera como un recorte pegado encima. */
.sb-logo span:first-child {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-logo svg,
.sb-logo img {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

/* ── Bloque de identidad (sidebar) ──────────────────────────────────
   Superficie plana, borde de 1px y sin cristal: la especialidad va como
   label en mayúsculas sobre el nombre (nada de píldora) y el cian solo
   aparece en el avatar y en ese label. */
.sb-profile {
  margin: 0.6rem 0.75rem 0.85rem;
  padding: 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  position: relative;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, rgba(15, 23, 42, 0.09));
  border-radius: 14px;
  box-shadow: none;
  transition: border-color 0.15s ease;
}

.sb-profile:hover {
  border-color: rgba(8, 145, 178, 0.28);
}

/* En PC el bloque de identidad va SUELTO sobre el sidebar (igual expandido que
   colapsado): sin tarjeta, sin borde y sin fondo detrás del avatar. La
   superficie tipo cristal se queda solo en el drawer de celular
   (.mobile-sidebar .sb-profile). El borde se mantiene en `transparent` en vez
   de quitarlo para que no haya salto de 1px entre estados. */
#sidebar .sb-profile,
#sidebar .sb-profile:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.sb-profile-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
}

.sb-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: none;
  flex-shrink: 0;
}

.sb-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--card, #ffffff);
  box-shadow: none;
}

.sb-user-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1;
}

.sb-specialty {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--primary-hover);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.4;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-specialty:empty {
  display: none;
}

.sb-user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  margin: 0;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.sb-clinic {
  font-size: 0.765rem;
  font-weight: 500;
  color: #64748b;
  text-align: left;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.9rem 0.7rem;
  gap: 0.75rem;
  margin: 0;
  list-style: none;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sb-section {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sb-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #94a3b8;
  padding: 0.4rem 0.9rem 0.32rem;
  margin: 0;
}

.sb-nav::-webkit-scrollbar {
  display: none;
}

.sb-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.56rem 0.9rem;
  border-radius: 12px;
  font-size: 0.97rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  margin: 0.05rem 0;
  width: 100%;
  letter-spacing: -0.005em;
}

.sb-item:hover {
  background: rgba(8, 145, 178, 0.06);
  color: var(--primary-hover);
}

.sb-item.active {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.12) 0%, rgba(14, 165, 233, 0.10) 100%);
  color: var(--primary-hover);
  font-weight: 600;
  border-color: rgba(8, 145, 178, 0.16);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

/* Marcador del item activo. Ya no va a hueso contra el borde del sidebar
   (`left: -0.7rem` lo dejaba justo sobre el filo del panel): con el panel
   flotando se mete un poco hacia dentro y se redondea por los dos lados. */
.sb-item.active::before {
  content: '';
  position: absolute;
  left: -0.42rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3.5px;
  height: 22px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, #0ea5e9 100%);
  box-shadow: 0 0 12px rgba(8, 145, 178, 0.4);
}

.sb-item svg,
.sb-item .sb-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  opacity: 0.85;
}

.sb-item.active svg,
.sb-item.active .sb-icon { opacity: 1; }

.sb-logout {
  margin-top: auto;
  margin-bottom: 0.75rem;
  margin-left: 0.7rem;
  margin-right: 0.7rem;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sb-logout:hover {
  background: rgba(225, 29, 72, 0.06);
  color: #e11d48;
  border-color: rgba(225, 29, 72, 0.15);
}

.sb-logout svg,
#sidebarLogoutIcon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

/* El CSS manda sobre el tamaño que trae el <img> desde Icons.render(). */
#sbLogoIcon img,
#sbLogoIcon svg {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
  color: currentColor;
}

.mobile-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

#toggleIcon,
.sb-toggle svg {
  width: 16px;
  height: 16px;
  color: currentColor;
}

#hamburgerIcon,
#closeIcon,
.hamburger-icon,
.close-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  width: 24px;
  height: 24px;
}

#closeSidebarBtn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

/* ── Page Slide-In Animation ── */
@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Layout Main Content ── */
.layout-main {
  margin-left: var(--sidebar-w);
  margin-top: 0;
  margin-right: 0;
  margin-bottom: 0;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  background: var(--bg);
  box-sizing: border-box;
  transition: margin-left 0.3s ease;
  width: calc(100% - var(--sidebar-w));
  animation: pageSlideIn 0.15s ease forwards;
}

.layout-main.page-exit {
  animation: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  opacity: 0;
  transform: translateX(24px);
}

/* ── Remove old nav ── */
nav.old-nav {
  display: none;
}

/* ── Sidebar Collapse State ── */
.sb-toggle {
  display: none;
  width: 100%;
  padding: 0.75rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  transition: all 0.3s;
  flex-shrink: 0;
  pointer-events: auto;
  border-top: 1px solid var(--border);
  /* Es el último hijo a todo el ancho: sin esto sus esquinas cuadradas se
     salen del radio del panel de cristal. */
  border-radius: 0 0 21px 21px;
}

.sb-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sb-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s;
}

/* ── Responsive Collapse ── */
@media (max-width: 1400px) {
  /* Carril estrecho: el aire baja a 8px (a 14 el panel se quedaría sin
     ancho útil para el avatar) y el carril reservado pasa a 84px = 8 de
     aire + 68 de panel + 8 de separación con el contenido. */
  #sidebar {
    --sidebar-gap: 8px;
    width: 68px;
    z-index: 101;
  }

  #sidebar .sb-logo,
  #sidebar .sb-user-block,
  #sidebar .sb-section-label,
  #sidebar .sb-item span:last-child,
  #sidebar .sb-logout span:last-child {
    display: none;
  }

  #sidebar .sb-profile {
    padding: 0.6rem 0.5rem;
    gap: 0.5rem;
    align-items: center;
  }

  #sidebar .sb-profile-row {
    justify-content: center;
  }

  #sidebar .sb-profile::after { display: none; }

  #sidebar .sb-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
  }

  #sidebar .sb-item {
    justify-content: center;
    padding: 0.75rem;
  }

  #sidebar .sb-logout {
    justify-content: center;
    margin: 0.5rem;
    padding: 0.6rem;
  }

  .sb-toggle {
    display: flex;
  }

  #sidebar.expanded {
    --sidebar-gap: 14px;
    width: calc(var(--sidebar-w) - 28px);
  }

  #sidebar.expanded .sb-logo,
  #sidebar.expanded .sb-section-label,
  #sidebar.expanded .sb-item span:last-child,
  #sidebar.expanded .sb-logout span:last-child {
    display: block;
  }

  #sidebar.expanded .sb-user-block {
    display: flex;
  }

  #sidebar.expanded .sb-profile {
    padding: 0.7rem 0.75rem;
    gap: 0.5rem;
    align-items: stretch;
  }

  #sidebar.expanded .sb-profile::after { display: block; }

  #sidebar.expanded .sb-profile-row {
    justify-content: flex-start;
  }

  #sidebar.expanded .sb-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }

  #sidebar.expanded .sb-item {
    justify-content: flex-start;
    padding: 0.75rem 1rem;
  }

  #sidebar.expanded .sb-logout {
    justify-content: flex-start;
    margin: 0.75rem;
    padding: 0.6rem 0.75rem;
  }

  #sidebar.expanded .sb-toggle svg {
    transform: rotate(180deg);
  }

  .layout-main {
    margin-left: 84px;
    padding: 1.5rem 1rem 1.5rem 0.5rem;
    width: calc(100% - 84px);
  }

  #sidebar.expanded ~ .layout-main {
    margin-left: var(--sidebar-w);
    padding: 2rem 1.5rem;
    width: calc(100% - var(--sidebar-w));
  }
}

/* ── Mobile Navigation (sticky top bar) ── */
#mobileNav {
  display: none;
}

/* ── Tabs: transparent at rest. The liquid glass lives on the BAR background
   (the whole header is the pane of glass), NOT per-tab — so the row never reads
   as "una fila de cajas". Only the active tab gets a glass pill, so it stays
   the unambiguous hero. Shared by items + hamburger. ── */
.mobile-nav-item,
.mobile-nav-hamburger {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  padding: 0.3rem 0.4rem;
  flex: 1;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent; /* matches the active pill box → no layout shift */
  border-radius: 13px;
  margin: 0;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.25s ease, color 0.25s ease;
}

/* Hover (pointer only): just a color shift — no chip. */
.mobile-nav-item:hover,
.mobile-nav-hamburger:hover {
  color: var(--primary);
  background: transparent;
}

/* Press: faint teal tap-feedback + springy squish. */
.mobile-nav-item:active,
.mobile-nav-hamburger:active {
  transform: scale(0.93);
  color: var(--primary);
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.10), rgba(6, 182, 212, 0.08));
}

/* Active tab: the bright glass pill — the only highlighted tab in the row. */
.mobile-nav-item.active {
  color: var(--primary);
  font-weight: 700;
  background:
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.45) 0%,
      rgba(255, 255, 255, 0.0) 40%),
    linear-gradient(135deg,
      rgba(8, 145, 178, 0.18) 0%,
      rgba(6, 182, 212, 0.14) 55%,
      rgba(56, 189, 248, 0.14) 100%);
  border: 1px solid rgba(8, 145, 178, 0.28);
  border-radius: 13px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 4px 12px rgba(8, 145, 178, 0.14);
}

/* Teal→cyan gradient on the SVG icons (mirrors the page heading style). */
.mobile-nav-item .mobile-icon svg,
.mobile-nav-item .mobile-icon svg *,
.mobile-nav-hamburger svg,
.mobile-nav-hamburger svg *,
.sidebar-menu-link svg,
.sidebar-menu-link svg *,
#notificationIcon svg,
#notificationIcon svg * {
  stroke: url(#mobileNavIconGradient);
}

.mobile-nav-item span:first-child {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-nav-item:active span:first-child {
  transform: scale(0.92);
}

.mobile-nav-item:hover span:first-child {
  transform: none;
}

.mobile-nav-item span:last-child {
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.mobile-nav-logout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.5rem;
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 12px;
  margin: 0;
  position: relative;
}

.mobile-nav-logout svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.5;
  transition: all 0.2s;
}

.mobile-nav-logout:active {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #e11d48;
  transform: scale(0.92);
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.15);
}

.mobile-nav-logout:active svg {
  color: #e11d48;
}

/* ── Hamburger Menu Button (icon sizing; chip styling shared above) ── */
.mobile-nav-hamburger svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-nav-hamburger:active svg {
  transform: scale(0.92);
}

.mobile-nav-hamburger:hover svg {
  transform: none;
}

/* ── Accessibility: keyboard focus ring ── */
.mobile-nav-item:focus-visible,
.mobile-nav-hamburger:focus-visible {
  outline: none;
  border-color: rgba(8, 145, 178, 0.55);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.9),
    0 0 0 4px rgba(8, 145, 178, 0.45);
}

/* ── prefers-reduced-motion: no press squish ── */
@media (prefers-reduced-motion: reduce) {
  .mobile-nav-item,
  .mobile-nav-hamburger {
    transition: color 0.15s ease;
  }
  .mobile-nav-item:active,
  .mobile-nav-hamburger:active {
    transform: none;
  }
}

/* ── Mobile Sidebar ── */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 199;
}

/* El scrim se detiene en el canto izquierdo del cajón: si lo cubriera, el vidrio
   del cajón estaría desenfocando una capa negra al 40% YA desenfocada — un campo
   uniforme, que por mucho blur que le eches sigue siendo un campo uniforme, y el
   panel se veía plano. Pero ese hueco no puede aparecer de golpe: se abre
   DESLIZANDO, con la misma duración y la misma curva que el cajón, así su canto
   derecho coincide con el canto izquierdo del cajón en todos los frames.
   Antes era un `right: 320px` fijo: al empezar a abrir quedaba al descubierto
   una franja de página sin desenfocar, con un corte vertical inmóvil, hasta que
   el cajón terminaba de llegar. */
.mobile-sidebar-overlay.active {
  display: block;
  transform: translateX(calc(-1 * var(--drawer-w)));
  animation: overlayIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Al cerrar, el scrim vuelve a taparlo todo acompañando al cajón que sale. Sin
   esto se ocultaba de golpe y la página aparecía nítida antes de tiempo: el
   mismo corte, en sentido contrario. */
.mobile-sidebar-overlay.closing {
  display: block;
  transform: translateX(0);
  opacity: 0;
  pointer-events: none;
  animation: overlayOut 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes overlayIn {
  from {
    opacity: 0;
    transform: translateX(0);
  }
  to {
    opacity: 1;
    transform: translateX(calc(-1 * var(--drawer-w)));
  }
}

@keyframes overlayOut {
  from {
    opacity: 1;
    transform: translateX(calc(-1 * var(--drawer-w)));
  }
  to {
    opacity: 0;
    transform: translateX(0);
  }
}

.mobile-sidebar {
  position: fixed;
  top: 0;
  width: var(--drawer-w);
  height: 100vh;
  /* Lámina de vidrio: veladura fina + desenfoque de lo que queda detrás (el
     scrim y la página). El canto izquierdo lleva el reflejo. */
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(240, 247, 251, 0.52) 100%);
  -webkit-backdrop-filter: saturate(180%) blur(26px);
  backdrop-filter: saturate(180%) blur(26px);
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.16);
  /* Se desliza con transform (compositado en GPU): animar `right` obligaba a
     recalcular layout en cada frame y se notaba el tirón. Sin will-change ni
     backface-visibility, que fuerzan una promoción de capa más agresiva.
     El scroll lo hace .mobile-sidebar-content, no este contenedor: dejarlo
     scrollable aquí (overflow-y + -webkit-overflow-scrolling) creaba una capa
     de scroll propia, otro escenario donde WebKit deja de pintar el vidrio. */
  right: 0;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow: hidden;
  /* Drawer a pantalla completa: respeta notch arriba y home indicator abajo. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Sin backdrop-filter no hay vidrio posible: lámina opaca para que el menú siga
   siendo legible sobre el contenido. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .mobile-sidebar {
    background: var(--card);
    border-left: 1px solid var(--border);
  }
}

.mobile-sidebar.active {
  transform: translateX(0);
}

.mobile-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(8, 145, 178, 0.05) 100%);
}

.mobile-sidebar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.mobile-sidebar-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: inherit;
}

.mobile-sidebar-close:active {
  background: var(--primary-light);
  color: var(--primary);
}

.mobile-sidebar-close svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.mobile-sidebar-content {
  flex: 1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  overflow-y: auto;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 0.5rem;
}

#notificationPanel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.notification-item-content {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 1rem;
  border-left: 3px solid var(--primary);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.notification-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.notification-item-text {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.notification-item-time {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* Cerrar Sesión en el drawer: misma TARJETA que los demás botones (clase
   .sidebar-menu-link → cajita de icono, chevron, tamaños), pero en ROJO porque
   es una acción destructiva. <button> centra por defecto → forzamos text-align
   izquierda. Selector compuesto (.sidebar-menu-link.sidebar-logout-link) para
   ganarle en especificidad a .sidebar-menu-link sin depender del orden. */
.sidebar-logout-link {
  width: 100%;
  text-align: left;
}
.sidebar-menu-link.sidebar-logout-link {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.18);
  background:
    linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(248, 113, 113, 0.03) 100%),
    rgba(255, 255, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 3px 10px -5px rgba(220, 38, 38, 0.14);
}
.sidebar-menu-link.sidebar-logout-link > span:first-child {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.16) 0%, rgba(248, 113, 113, 0.10) 100%);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.22);
}
.sidebar-menu-link.sidebar-logout-link::after {
  border-right-color: rgba(220, 38, 38, 0.55);
  border-top-color: rgba(220, 38, 38, 0.55);
}
.sidebar-menu-link.sidebar-logout-link:hover {
  border-color: rgba(220, 38, 38, 0.32);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 8px 22px -8px rgba(220, 38, 38, 0.28);
}
.sidebar-menu-link.sidebar-logout-link:hover::after {
  border-right-color: #dc2626;
  border-top-color: #dc2626;
}

/* Mini-tarjeta tipo .sb-notif-card pero compacta (icono 36px, una sola línea)
   para que el notif card —que tiene icono 42px y subtítulo— quede claramente
   más grande y siga siendo el item destacado del drawer. */
.sidebar-menu-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.85rem;
  border-radius: 13px;
  border: 1px solid rgba(8, 145, 178, 0.12);
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.06) 0%, rgba(14, 165, 233, 0.025) 100%),
    rgba(255, 255, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 3px 10px -5px rgba(8, 145, 178, 0.1);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease, background 0.22s ease;
}

/* Bloque del icono (primer <span> del link) */
.sidebar-menu-link > span:first-child {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.18) 0%, rgba(14, 165, 233, 0.12) 100%);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(8, 145, 178, 0.22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 4px 10px -5px rgba(8, 145, 178, 0.22);
  transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease;
}

.sidebar-menu-link svg {
  width: 18px;
  height: 18px;
}

/* Anula el stroke gradient global (línea ~650) — adentro de la cajita
   teal queda lavado. currentColor sigue el color del bloque del icono. */
.sidebar-menu-link > span:first-child svg,
.sidebar-menu-link > span:first-child svg * {
  stroke: currentColor;
}

.sidebar-menu-link > span:last-child {
  flex: 1;
  min-width: 0;
}

/* Chevron CSS — espeja el del notif card sin tocar el HTML/JS */
.sidebar-menu-link::after {
  content: '';
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-right: 2px solid #94a3b8;
  border-top: 2px solid #94a3b8;
  transform: rotate(45deg);
  margin-right: 4px;
  transition: border-color 0.22s ease, transform 0.22s ease;
}

.sidebar-menu-link:hover {
  border-color: rgba(8, 145, 178, 0.24);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 8px 22px -8px rgba(8, 145, 178, 0.25);
  transform: translateY(-1px);
}

.sidebar-menu-link:hover::after {
  border-color: var(--primary);
  transform: rotate(45deg) translate(2px, -2px);
}

.sidebar-menu-link:active { transform: scale(0.98); }

@media (max-width: 860px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
    background: var(--card);
  }
  #sidebar {
    display: none;
  }
  .mobile-nav-hamburger {
    display: flex !important;
  }
  #mobileNav {
    display: flex;
    position: fixed;
    /* Isla de vidrio FLOTANTE: cuelga DEBAJO del notch con márgenes laterales,
       esquinas redondeadas y sombra difusa — separada del contenido, sin líneas
       duras. El top arranca tras el safe-area + un pequeño aire. */
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 8px;
    right: 8px;
    width: auto;
    height: 66px;
    z-index: 100;
    align-items: center;
    justify-content: space-around;
    gap: 0.3rem;
    padding: 0.4rem 0.4rem;
    margin: 0;
    border-radius: 20px;

    /* Vidrio translúcido + desenfoque del contenido que pasa por detrás.
       Veladura en el MISMO gris-azulado claro de la página (no blanco puro) y
       con menos opacidad/saturación → el blur deja pasar el tono real del fondo,
       así el header lee como "la misma superficie esmerilada" y deja de
       recortarse como una tarjeta blanca sobre el fondo (--bg #f1f5f9). */
    background: rgba(244, 248, 251, 0.62);
    -webkit-backdrop-filter: saturate(135%) blur(20px);
    backdrop-filter: saturate(135%) blur(20px);
    /* Sin borde ni reflejo blanco arriba: solo sombra difusa para el flotado.
       Sombra ASENTADA: poco offset + blur corto + baja opacidad → la isla flota
       apenas lo justo sin "saltar" ni leerse despegada de la pantalla. */
    border: none;
    box-shadow:
      0 4px 14px -8px rgba(15, 23, 42, 0.16),     /* sombra suave, cercana */
      0 1px 3px rgba(15, 23, 42, 0.05);           /* contacto sutil al borde */
  }

  /* Sin backdrop-filter: subir opacidad para que las etiquetas sigan legibles. */
  @supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    #mobileNav {
      background: rgba(244, 248, 251, 0.96);
    }
  }
  .mobile-nav-logout {
    border-left: none !important;
  }
  .layout-main {
    margin: 0;
    padding: 0 1.5rem;
    /* 86px (alto barra + aire) + el safe-area que la barra ahora ocupa arriba */
    padding-top: calc(86px + env(safe-area-inset-top, 0px));
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .content {
    padding: 0.75rem !important;
    padding-top: calc(86px + env(safe-area-inset-top, 0px)) !important;
    margin: 0 !important;
    width: 100% !important;
  }
  .sb-toggle {
    display: none;
  }
}

/* ──────────────────────────────────────────────────────────────────────
   FIX: el header (#mobileNav, fijo arriba) tapaba el contenido.
   El nav mide 64px + safe-area (notch/Dynamic Island), pero CADA página fija su
   propio padding-top de <main> con valores en px que NO incluyen el inset (y
   algunos ni cubren los 64px) → en iPhone con notch el contenido quedaba debajo.
   Este override central GARANTIZA el espacio correcto en todas:
   · especificidad (1,1,1) + !important → gana a las reglas inline por página;
   · `#mobileNav ~` → solo aplica cuando el nav existe (no toca login/landing);
   · incluye env(safe-area-inset-top); en Android/desktop el inset es 0 → 80px.
   Solo afecta padding-top; respeta padding horizontal/inferior de cada página.
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  /* :not(.chat-main) → el chat (mensajes) es full-bleed y ancla su header de
     conversación pegado al nav; define su propio padding en mensajes.css. */
  #mobileNav ~ main.layout-main:not(.chat-main) {
    padding-top: calc(86px + env(safe-area-inset-top, 0px)) !important;
  }
}

/* ── Desktop: Hide Mobile Sidebar ── */
@media (min-width: 861px) {
  .mobile-sidebar-overlay,
  .mobile-sidebar,
  .mobile-nav-hamburger {
    display: none !important;
  }
}

/* ── Page Loader Overlay ── */
@keyframes skeleton-shine {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

@media (max-width: 860px) {
  .page-loader {
    transition: opacity 0.15s ease;
  }
}

.page-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.page-loader-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(8, 145, 178, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  will-change: transform;
  backface-visibility: hidden;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page-loader-text {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.stat-skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 0%,
    #f0f5ff 50%,
    var(--border) 100%
  );
  background-size: 1000px 100%;
  animation: skeleton-shine 2s infinite;
  border-radius: 8px;
  height: 2.5rem;
  min-width: 120px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

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

/* ── Doctor Notification Bell (sidebar + mobile + panel + toast) ── */
.sb-logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-right: 0.85rem;
}
.sb-logo-row .sb-logo {
  flex: 1;
  padding-right: 0;
}

.sd-notif-bell {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: 1px solid rgba(8, 145, 178, 0.18);
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.10) 0%, rgba(14, 165, 233, 0.06) 100%),
    rgba(255, 255, 255, 0.7);
  color: var(--primary-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 2px 8px -2px rgba(8, 145, 178, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.sd-notif-bell:hover {
  border-color: rgba(8, 145, 178, 0.32);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 6px 18px -6px rgba(8, 145, 178, 0.32);
  transform: translateY(-1px);
}
.sd-notif-bell:active {
  transform: scale(0.96);
}
.sd-notif-bell .sd-notif-bell-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sd-notif-bell .sd-notif-bell-icon svg,
.sd-notif-bell .sd-notif-bell-icon svg * { stroke: currentColor; }
/* El icono se pinta a 18px desde JS; en el sidebar de escritorio la campana es
   más grande, así que el trazo sube con ella. */
#sidebar .sd-notif-bell .sd-notif-bell-icon svg { width: 20px; height: 20px; }

.sd-notif-bell.has-unread { color: #be123c; border-color: rgba(244, 63, 94, 0.28); }
.sd-notif-bell.has-unread .sd-notif-bell-icon {
  animation: sd-bell-wiggle 1.6s ease-in-out infinite;
  transform-origin: 50% 10%;
}
@keyframes sd-bell-wiggle {
  0%, 60%, 100% { transform: rotate(0); }
  68% { transform: rotate(-14deg); }
  76% { transform: rotate(11deg); }
  82% { transform: rotate(-7deg); }
  88% { transform: rotate(4deg); }
  94% { transform: rotate(0); }
}

.sd-notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  box-shadow:
    0 0 0 2px var(--card),
    0 6px 14px -4px rgba(225, 29, 72, 0.55);
  animation: sd-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sd-notif-badge[hidden] { display: none !important; }
@keyframes sd-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
.sd-notif-badge::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.45);
  z-index: -1;
  animation: sd-badge-pulse 1.8s ease-out infinite;
}
@keyframes sd-badge-pulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Collapsed sidebar: hide bell to keep nav clean */
@media (max-width: 1400px) {
  #sidebar .sb-logo-row { justify-content: center; padding-right: 0; }
  #sidebar .sd-notif-bell:not(.sd-notif-bell--mobile) { display: none; }
  #sidebar.expanded .sb-logo-row { justify-content: space-between; padding-right: 0.85rem; }
  #sidebar.expanded .sd-notif-bell:not(.sd-notif-bell--mobile) { display: inline-flex; }
}

/* Mobile bell removed from top nav — notifications live inside the hamburger drawer */
.sd-notif-bell--mobile { display: none !important; }

/* ── Notifications "companion card" — sits below the doctor profile,
   mirrors its glass-card vocabulary, and carries its own live state. */
.sidebar-section--notif {
  /* Tighten the gap to the profile card so they read as a pair. */
  margin-top: -0.4rem;
}

.sb-notif-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(8, 145, 178, 0.12);
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.06) 0%, rgba(14, 165, 233, 0.025) 100%),
    rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 4px 14px -6px rgba(8, 145, 178, 0.12);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease, background 0.22s ease;
}

.sb-notif-card:hover {
  border-color: rgba(8, 145, 178, 0.24);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 8px 22px -8px rgba(8, 145, 178, 0.28);
  transform: translateY(-1px);
}

.sb-notif-card:active { transform: scale(0.98); }

/* Iconic block on the left — square, gradient, mirrors the avatar's weight */
.sb-notif-icon-wrap {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
}

.sb-notif-icon {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.18) 0%, rgba(14, 165, 233, 0.12) 100%);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(8, 145, 178, 0.22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 6px 14px -6px rgba(8, 145, 178, 0.28);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.sb-notif-icon svg,
.sb-notif-icon svg * { stroke: currentColor; }

/* Pulse halo behind the icon — only visible when there's something to read */
.sb-notif-icon-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 17px;
  background: rgba(244, 63, 94, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

/* Centre column */
.sb-notif-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}
.sb-notif-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.012em;
  line-height: 1.2;
}
.sb-notif-status {
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.22s ease;
}

/* Right trail: badge + chevron, stacked */
.sb-notif-trail {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.sb-notif-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 4px 12px -3px rgba(225, 29, 72, 0.55);
  animation: sd-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sb-notif-badge[hidden] { display: none !important; }
.sb-notif-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: transform 0.22s ease, color 0.22s ease;
}
.sb-notif-chevron svg,
.sb-notif-chevron svg * { stroke: currentColor; }
.sb-notif-card:hover .sb-notif-chevron {
  color: var(--primary);
  transform: translateX(2px);
}

/* ── Active state: there is something unread. Warm tint + animated pulse. */
.sb-notif-card.has-unread {
  border-color: rgba(244, 63, 94, 0.28);
  background:
    linear-gradient(135deg, rgba(244, 63, 94, 0.08) 0%, rgba(251, 113, 133, 0.04) 100%),
    rgba(255, 255, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 6px 20px -8px rgba(244, 63, 94, 0.22);
}
.sb-notif-card.has-unread .sb-notif-icon {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.22) 0%, rgba(251, 113, 133, 0.14) 100%);
  color: #e11d48;
  border-color: rgba(244, 63, 94, 0.30);
  animation: sd-bell-wiggle 1.8s ease-in-out infinite;
  transform-origin: 50% 22%;
}
.sb-notif-card.has-unread .sb-notif-icon-pulse {
  animation: sb-notif-halo 1.8s ease-out infinite;
}
.sb-notif-card.has-unread .sb-notif-status {
  color: #e11d48;
  font-weight: 600;
}
.sb-notif-card.has-unread:hover {
  border-color: rgba(244, 63, 94, 0.45);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 10px 26px -10px rgba(244, 63, 94, 0.36);
}

@keyframes sb-notif-halo {
  0% { opacity: 0; transform: scale(0.9); }
  50% { opacity: 0.55; }
  100% { opacity: 0; transform: scale(1.25); }
}

/* ── Notification Panel (dropdown / sheet) ── */
.sd-notif-panel {
  position: fixed;
  /* En móvil cuelga bajo la barra superior, que ahora incluye el safe-area. */
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 96px - env(safe-area-inset-top, 0px)));
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 24px 60px -16px rgba(15, 23, 42, 0.28),
    0 8px 24px -8px rgba(8, 145, 178, 0.18);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.sd-notif-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.sd-notif-panel[hidden] { display: none !important; }
@media (min-width: 861px) {
  .sd-notif-panel {
    top: 12px;
    bottom: auto;
    left: calc(var(--sidebar-w) + 12px);
    right: auto;
    transform-origin: top left;
    transform: translateY(-8px) scale(0.98);
    max-height: min(560px, calc(100vh - 24px));
  }
  .sd-notif-panel.open { transform: translateY(0) scale(1); }
}
@media (min-width: 861px) and (max-width: 1400px) {
  .sd-notif-panel { left: 82px; }
  #sidebar.expanded ~ .sd-notif-panel { left: calc(var(--sidebar-w) + 12px); }
}

.sd-notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(8, 145, 178, 0.08);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(8, 145, 178, 0.10), transparent 55%),
    rgba(255,255,255,0.6);
}
.sd-notif-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.sd-notif-panel-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}
.sd-notif-panel-title-icon svg,
.sd-notif-panel-title-icon svg * { stroke: currentColor; }
.sd-notif-panel-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.sd-notif-panel-close:hover { background: rgba(15,23,42,0.06); color: var(--text); }
.sd-notif-panel-close svg,
.sd-notif-panel-close svg * { stroke: currentColor; }

.sd-notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
}

.sd-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1.5rem;
  gap: 0.4rem;
}
.sd-notif-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.10), rgba(14, 165, 233, 0.06));
  border: 1px solid rgba(8, 145, 178, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 0.35rem;
}
.sd-notif-empty-icon svg, .sd-notif-empty-icon svg * { stroke: currentColor; }
.sd-notif-empty-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.sd-notif-empty-text {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 220px;
  line-height: 1.4;
}

.sd-notif-item {
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.75rem 0.7rem 0.85rem;
  border-radius: 12px;
  cursor: default;
  transition: background 0.15s ease;
  margin: 0.15rem 0;
}
.sd-notif-item + .sd-notif-item { margin-top: 0.2rem; }
.sd-notif-item:hover { background: rgba(8, 145, 178, 0.045); }
.sd-notif-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  margin-top: 0.55rem;
  align-self: flex-start;
  flex-shrink: 0;
}
.sd-notif-item.unread .sd-notif-item-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.18), 0 0 8px rgba(8, 145, 178, 0.4);
  animation: sd-notif-dot-pulse 1.8s ease-in-out infinite;
}
@keyframes sd-notif-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.18), 0 0 8px rgba(8, 145, 178, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.10), 0 0 12px rgba(8, 145, 178, 0.55); }
}

.sd-notif-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
}
.sd-notif-item.is-confirm .sd-notif-item-icon {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.28);
}
.sd-notif-item.is-decline .sd-notif-item-icon {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #b91c1c;
  border: 1px solid rgba(225, 29, 72, 0.28);
}
.sd-notif-item-icon svg, .sd-notif-item-icon svg * { stroke: currentColor; }

.sd-notif-item-body { min-width: 0; }
.sd-notif-item-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.sd-notif-item.is-confirm .sd-notif-item-title { color: #047857; }
.sd-notif-item.is-decline .sd-notif-item-title { color: #b91c1c; }
.sd-notif-item-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-notif-item-meta {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.sd-notif-item-sep { opacity: 0.5; }

.sd-notif-panel-footer {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid rgba(8, 145, 178, 0.08);
  background: rgba(248, 252, 255, 0.7);
}
.sd-notif-clear {
  width: 100%;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-hover);
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sd-notif-clear:hover { background: rgba(8, 145, 178, 0.08); }

/* ── Toast stack (top right) ── */
.sd-notif-toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 1200;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}
@media (max-width: 860px) {
  /* Bottom-anchored en móvil: el top (72px) chocaba con el hero y los toasts
     (pointer-events:auto) tapaban "Nueva Cita" / "Nuevo paciente". */
  .sd-notif-toast-stack {
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

.sd-notif-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 18px 36px -12px rgba(15, 23, 42, 0.24),
    0 4px 14px -4px rgba(8, 145, 178, 0.18);
  opacity: 0;
  transform: translateX(24px) scale(0.96);
  transition: opacity 0.28s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.sd-notif-toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), #0ea5e9);
}
.sd-notif-toast--confirm::before {
  background: linear-gradient(180deg, #10b981, #047857);
}
.sd-notif-toast--decline::before {
  background: linear-gradient(180deg, #f43f5e, #be123c);
}
.sd-notif-toast.show {
  opacity: 1;
  transform: translateX(0) scale(1);
}
.sd-notif-toast-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sd-notif-toast--confirm .sd-notif-toast-icon {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #047857;
}
.sd-notif-toast--decline .sd-notif-toast-icon {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #b91c1c;
}
.sd-notif-toast-icon svg, .sd-notif-toast-icon svg * { stroke: currentColor; }
.sd-notif-toast-body { flex: 1; min-width: 0; }
.sd-notif-toast-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.1rem;
}
.sd-notif-toast-text {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-notif-toast-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.sd-notif-toast-close {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.sd-notif-toast-close:hover { background: rgba(15,23,42,0.06); color: var(--text); }
.sd-notif-toast-close svg, .sd-notif-toast-close svg * { stroke: currentColor; }

/* ───────────────────────────────────────────────────────────────
   KPI cards with icon tile — match the Inicio/dashboard stat-card
   layout (horizontal: cyan icon tile + body). Scoped to .kpis so it
   only affects the admin KPI grids (doctors, confirmaciones,
   consentimientos, recordatorios). Requires each .kpi to contain a
   .kpi-tile (the icon) and a .kpi-main wrapper around label/value/trend.
   `.kpis .kpi` (2 classes) outranks each page's `.kpi` (1 class), so the
   horizontal layout wins regardless of stylesheet order.
   ─────────────────────────────────────────────────────────────── */
.kpis .kpi {
  flex-direction: row !important;
  align-items: center;
  gap: 18px;
  padding: 22px;
}
.kpis .kpi .kpi-tile {
  width: 56px; height: 56px; flex: 0 0 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
  box-shadow:
    0 8px 24px rgba(8, 145, 178, .28),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}
.kpis .kpi .kpi-tile svg { width: 26px; height: 26px; }
.kpis .kpi .kpi-main {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
