/* ================================================================
   SISTEMA DE DISEÑO v2 — Apple-style · Médica Sur / Holiday Inn
   Mismos nombres de clase, nuevo lenguaje visual.
   Para regresar a v1: renombrar app_v1_backup.css → app.css
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Azul institucional Médica Sur */
  --ap-blue:        #0033A1;
  --ap-blue-dark:   #002878;
  --ap-blue-light:  #eef3fb;
  --ap-navy:        #001a52;

  /* Grises Apple */
  --ap-white:       #FFFFFF;
  --ap-gray-50:     #f9f9fb;
  --ap-gray-100:    #f2f2f7;
  --ap-gray-200:    #e5e5ea;
  --ap-gray-400:    #8e8e93;
  --ap-gray-600:    #48484a;
  --ap-gray-800:    #1c1c1e;

  /* Funcionales */
  --ms-warm-green:  #34c759;
  --ms-warm-coral:  #ff3b30;
  --ms-warm-sand:   #f2ece4;
  --ms-warm-bg:     #fafaf8;
  --ms-warm-accent: #d4a574;
  --ms-error:       #ff3b30;
  --ms-error-hover: #d70015;
  --ms-success:     #34c759;
  --ms-warning:     #ff9500;

  /* Tipografía */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display',
               'Segoe UI', Arial, sans-serif;

  /* Layout */
  --container-max: 1160px;
  --container-px:  28px;

  /* Radios */
  --ap-radius:    18px;
  --ap-radius-sm: 12px;
  --ms-radius:    14px;
  --radius-pill:  980px;
  --radius-badge: 20px;
  --radius-icon:  12px;
  --radius-sm:    12px;
  --radius-md:    14px;
  --radius-lg:    16px;
  --radius-xl:    18px;
  --radius-cert:  16px;

  /* Sombras */
  --shadow-xs:    0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.06);
  --shadow-md:    0 4px 20px rgba(0,0,0,.07);
  --shadow-hover: 0 12px 36px rgba(0,0,0,.12);
  --shadow-nav:   0 1px 0 rgba(0,0,0,.08);
  --shadow-service: 0 8px 24px rgba(0,51,161,.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.10);

  /* Transición */
  --ap-transition: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Grid */
  --grid-gap:    20px;
  --grid-gap-sm: 12px;
  --grid-gap-md: 16px;
  --grid-gap-lg: 32px;
  --grid-mt:     40px;
  --section-py:  56px;

  color-scheme: light;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ap-gray-800);
  background: var(--ap-gray-100);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Contenedor ─────────────────────────────────────────────── */
.ms-main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 2rem var(--container-px);
}

/* ── Navbar ─────────────────────────────────────────────────── */
.ms-navbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(200%) blur(20px);
  -webkit-backdrop-filter: saturate(200%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--container-px);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background .3s, box-shadow .3s;
}
.ms-navbar.scrolled {
  background: rgba(255,255,255,0.96);
  box-shadow: var(--shadow-nav);
}

.ms-navbar .nav-link {
  font-size: .8rem;
  font-weight: 500;
  color: var(--ap-gray-600);
  padding: .3rem .7rem !important;
  border-radius: 8px;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.ms-navbar .nav-link:hover,
.ms-navbar .nav-link.active {
  color: var(--ap-blue);
  background: var(--ap-blue-light);
}
.ms-navbar .dropdown-menu {
  border: 1px solid var(--ap-gray-200);
  border-radius: var(--ap-radius-sm);
  box-shadow: var(--shadow-md);
  padding: .4rem;
  min-width: 210px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
}
.ms-navbar .dropdown-item {
  font-size: .82rem;
  font-weight: 500;
  color: var(--ap-gray-600);
  border-radius: 8px;
  padding: .45rem .7rem;
  transition: background .12s, color .12s;
}
.ms-navbar .dropdown-item:hover {
  background: var(--ap-blue-light);
  color: var(--ap-blue);
}
.ms-navbar .dropdown-divider { border-color: var(--ap-gray-200); margin: .3rem 0; }

/* ── Usuario / Avatar ───────────────────────────────────────── */
.ms-user-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--ap-gray-600);
}
.ms-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ap-blue-light), #d0e2ff);
  color: var(--ap-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,51,161,.15);
}
.ms-role-badge {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--ap-blue-light);
  color: var(--ap-blue);
  border-radius: var(--radius-badge);
  padding: 2px 7px;
}
.ms-btn-logout {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ap-gray-600);
  border: 1px solid var(--ap-gray-200);
  border-radius: var(--ap-radius-sm);
  padding: .28rem .7rem;
  background: transparent;
  text-decoration: none;
  transition: all .15s;
}
.ms-btn-logout:hover {
  background: #fff2f2;
  border-color: var(--ms-error);
  color: var(--ms-error);
}

/* ── Cards ──────────────────────────────────────────────────── */
.ms-card {
  background: var(--ap-white);
  border: none;
  border-radius: var(--ap-radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow .35s var(--ap-transition),
              transform .35s var(--ap-transition);
}
.ms-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}
.ms-card-header {
  padding: 1.1rem 1.4rem .75rem;
  border-bottom: 1px solid var(--ap-gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ms-card-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--ap-gray-800);
  margin: 0;
}
.ms-card-body       { padding: 1.4rem; }
.ms-card-body-flush { padding: 0; }

/* ── KPI Cards ──────────────────────────────────────────────── */
.ms-kpi {
  background: var(--ap-white);
  border: none;
  border-radius: var(--ap-radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-md);
  min-height: 100px;
  transition: box-shadow .35s var(--ap-transition),
              transform .35s var(--ap-transition);
}
.ms-kpi:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}
.ms-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  transition: transform .3s var(--ap-transition);
}
.ms-kpi:hover .ms-kpi-icon { transform: scale(1.1); }
.ms-kpi-icon.blue  { background: linear-gradient(135deg,#dbeafe,var(--ap-blue-light)); color: var(--ap-blue); }
.ms-kpi-icon.green { background: linear-gradient(135deg,#d1fae5,#a7f3d0); color: #059669; }
.ms-kpi-icon.amber { background: linear-gradient(135deg,#fef3c7,#fde68a); color: #d97706; }
.ms-kpi-icon.coral { background: linear-gradient(135deg,#fee2e2,#fecaca); color: #dc2626; }
.ms-kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--ap-gray-400);
  margin-bottom: .1rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ms-kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--ap-gray-800);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
}
.ms-kpi-sub { font-size: .7rem; color: var(--ap-gray-400); margin-top: .1rem; }

/* ── Botones ────────────────────────────────────────────────── */
.ms-btn {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  font-family: var(--font-main);
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: .48rem 1.15rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s var(--ap-transition);
  white-space: nowrap;
  letter-spacing: -.01em;
}
.ms-btn:hover  { transform: scale(1.02); text-decoration: none; }
.ms-btn:active { transform: scale(0.98); }

.ms-btn-primary {
  background: var(--ap-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,51,161,.25);
}
.ms-btn-primary:hover {
  background: var(--ap-blue-dark);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,51,161,.35);
}
.ms-btn-success {
  background: #1a7f4b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,127,75,.25);
}
.ms-btn-success:hover { background: #155f39; color: #fff; }
.ms-btn-danger {
  background: #c0392b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,.25);
}
.ms-btn-danger:hover { background: #a93226; color: #fff; }
.ms-btn-ghost {
  background: var(--ap-gray-100);
  color: var(--ap-gray-600);
  border: 1px solid var(--ap-gray-200);
}
.ms-btn-ghost:hover { background: var(--ap-gray-200); color: var(--ap-gray-800); }
.ms-btn-sm {
  font-size: .76rem;
  padding: .3rem .8rem;
}

/* ── Tablas ─────────────────────────────────────────────────── */
.ms-table-wrap { overflow-x: auto; border-radius: 0 0 var(--ap-radius) var(--ap-radius); }
.ms-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ms-table thead th {
  background: var(--ap-gray-50);
  border-bottom: 1px solid var(--ap-gray-200);
  padding: .65rem .95rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ap-gray-400);
  white-space: nowrap;
}
.ms-table tbody td {
  padding: .7rem .95rem;
  border-bottom: 1px solid var(--ap-gray-100);
  color: var(--ap-gray-800);
  vertical-align: middle;
}
.ms-table tbody tr:last-child td { border-bottom: none; }
.ms-table tbody tr { transition: background .12s; }
.ms-table tbody tr:nth-child(odd) td { background: #fff; }
.ms-table tbody tr:nth-child(even) td { background: var(--ap-blue-light); }
.ms-table tbody tr:hover td { background: #dce8f8; }
.ms-table tfoot td {
  padding: .7rem .95rem;
  font-weight: 700;
  background: var(--ap-gray-50);
  border-top: 1.5px solid var(--ap-gray-200);
}

/* ── Badges ─────────────────────────────────────────────────── */
.ms-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  border-radius: var(--radius-badge);
  padding: 3px 9px;
}
.ms-badge-entrada { background: #d1fae5; color: #065f46; }
.ms-badge-salida  { background: #fee2e2; color: #991b1b; }
.ms-badge-blue    { background: var(--ap-blue-light); color: var(--ap-blue); }
.ms-badge-warning { background: #fef3c7; color: #92400e; }
.ms-badge-gray    { background: var(--ap-gray-100); color: var(--ap-gray-600); }
.ms-badge-danger  { background: #fee2e2; color: #991b1b; }

/* ── Alertas de stock por empaque ───────────────────────────── */
.ms-badge-alerta-urgente {
  background: #b91c1c !important;
  color: #fff !important;
  font-weight: 700;
}
.ms-badge-alerta-urgente-pulse {
  animation: ms-urgente-pulse 1.8s ease-in-out infinite;
}
@keyframes ms-urgente-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(185, 28, 28, 0); }
}
.ms-badge-alerta-critica { background: #fecaca; color: #7f1d1d; font-weight: 700; }
.ms-badge-alerta-media   { background: #fef3c7; color: #92400e; font-weight: 600; }
.ms-badge-alerta-baja    { background: #e8e8ed; color: #52525b; }

/* ── Centro de notificaciones ───────────────────────────────── */
.ms-notif-wrap { position: relative; flex-shrink: 0; }
.ms-notif-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: .45rem .55rem;
  border-radius: 10px;
  color: var(--ap-gray-600);
  font-size: 1.15rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.ms-notif-bell:hover { background: var(--ap-gray-100); color: var(--ap-blue); }
.ms-notif-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #b91c1c;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ap-white);
}
.ms-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(400px, calc(100vw - 1.5rem));
  background: #fff;
  border: 1px solid var(--ap-gray-200);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .12);
  z-index: 1100;
  overflow: hidden;
}
.ms-notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .95rem 1rem;
  border-bottom: 1px solid var(--ap-gray-100);
}
.ms-notif-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ap-gray-900);
  flex-shrink: 0;
}
.ms-notif-header-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
}
.ms-notif-mark-all {
  background: none;
  border: none;
  color: var(--ap-blue);
  font-size: .7rem;
  font-weight: 600;
  cursor: pointer;
  padding: .25rem .35rem;
  border-radius: 6px;
  white-space: nowrap;
}
.ms-notif-mark-all:hover { background: var(--ap-blue-light); }
.ms-notif-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--ap-gray-500);
  text-decoration: none;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.ms-notif-settings:hover {
  background: var(--ap-gray-100);
  color: var(--ap-gray-700);
}
.ms-notif-panel-body {
  max-height: 460px;
  overflow-y: auto;
  padding: .85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #fff;
}
.ms-notif-section { display: flex; flex-direction: column; gap: .55rem; }
.ms-notif-section-label {
  margin: 0;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ap-gray-400);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ms-notif-section-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.ms-notif-panel-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--ap-gray-100);
  background: #fff;
  text-align: center;
}
.ms-notif-more-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: none;
  border: none;
  color: var(--ap-gray-600);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 6px;
}
.ms-notif-more-link:hover:not(:disabled) { color: var(--ap-blue); }
.ms-notif-more-link:disabled { opacity: .6; cursor: default; }
.ms-notif-card {
  position: relative;
  display: grid;
  grid-template-columns: 4px auto 1fr auto;
  align-items: center;
  gap: 0 .65rem;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: .75rem .85rem .75rem 0;
  border: 1px solid #e8ecf1;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.ms-notif-card:hover {
  border-color: #d5dde8;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .06);
}
.ms-notif-card:focus-visible {
  outline: 2px solid var(--ap-blue);
  outline-offset: 2px;
}
.ms-notif-card--unread {
  background: linear-gradient(90deg, #eff6ff 0%, #f8fbff 100%);
  border-color: #60a5fa;
  box-shadow: 0 2px 12px rgba(37, 99, 235, .12);
}
.ms-notif-card--unread .ms-notif-card-title {
  color: #0f172a;
  font-weight: 800;
}
.ms-notif-card--unread.ms-notif-urgente {
  background: linear-gradient(90deg, #fef2f2 0%, #fff8f8 100%);
  border-color: #f87171;
  box-shadow: 0 2px 12px rgba(220, 38, 38, .12);
}
.ms-notif-card--read {
  background: #fff;
  border-color: #e8ecf1;
}
.ms-notif-card--read .ms-notif-card-title {
  font-weight: 600;
  color: #64748b;
}
.ms-notif-card--read .ms-notif-stock-line,
.ms-notif-card--read .ms-notif-time {
  color: #94a3b8;
}
.ms-notif-unread-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 2px #fff;
  animation: ms-notif-pulse 1.8s ease-in-out infinite;
}
.ms-notif-urgente.ms-notif-card--unread .ms-notif-unread-dot {
  background: #dc2626;
}
.ms-notif-unread-label {
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #1d4ed8;
  background: #dbeafe;
  padding: .12rem .38rem;
  border-radius: 999px;
  line-height: 1.2;
}
.ms-notif-urgente.ms-notif-card--unread .ms-notif-unread-label {
  color: #b91c1c;
  background: #fee2e2;
}
@keyframes ms-notif-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: .75; }
}
.ms-notif-card-accent {
  align-self: stretch;
  width: 4px;
  border-radius: 12px 0 0 12px;
  margin: -1px 0 -1px -1px;
}
.ms-notif-urgente .ms-notif-card-accent { background: #dc2626; }
.ms-notif-critica .ms-notif-card-accent { background: #ea580c; }
.ms-notif-media .ms-notif-card-accent { background: #f97316; }
.ms-notif-baja .ms-notif-card-accent { background: #eab308; }
.ms-notif-atendida .ms-notif-card-accent { background: #16a34a; }
.ms-notif-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.ms-notif-card-icon.ms-notif-baja    { background: #fef9c3; color: #a16207; }
.ms-notif-card-icon.ms-notif-media   { background: #ffedd5; color: #ea580c; }
.ms-notif-card-icon.ms-notif-critica { background: #ffedd5; color: #ea580c; }
.ms-notif-card-icon.ms-notif-urgente { background: #fee2e2; color: #dc2626; }
.ms-notif-card-icon.ms-notif-atendida { background: #dcfce7; color: #16a34a; }
.ms-notif-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.ms-notif-card-title {
  margin: 0;
  font-size: .86rem;
  font-weight: 700;
  color: var(--ap-gray-900);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.ms-notif-card-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem .5rem;
}
.ms-notif-stock-line {
  font-size: .74rem;
  color: var(--ap-gray-500);
  line-height: 1.3;
}
.ms-notif-nivel-badge {
  flex-shrink: 0;
  font-size: .62rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 999px;
  letter-spacing: .03em;
  white-space: nowrap;
  line-height: 1.2;
}
.ms-notif-baja .ms-notif-nivel-badge, .ms-notif-nivel-badge.ms-notif-baja { background: #fef3c7; color: #a16207; }
.ms-notif-media .ms-notif-nivel-badge, .ms-notif-nivel-badge.ms-notif-media { background: #ffedd5; color: #c2410c; }
.ms-notif-critica .ms-notif-nivel-badge, .ms-notif-nivel-badge.ms-notif-critica { background: #ffedd5; color: #c2410c; }
.ms-notif-urgente .ms-notif-nivel-badge, .ms-notif-nivel-badge.ms-notif-urgente { background: #fee2e2; color: #dc2626; }
.ms-notif-atendida .ms-notif-nivel-badge, .ms-notif-nivel-badge.ms-notif-atendida { background: #dcfce7; color: #15803d; }
.ms-notif-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: .15rem;
  flex-shrink: 0;
  padding-left: .25rem;
}
.ms-notif-time {
  font-size: .68rem;
  color: var(--ap-gray-400);
  white-space: nowrap;
  line-height: 1.2;
}
.ms-notif-chevron {
  font-size: .72rem;
  color: var(--ap-gray-300);
}
.ms-notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ap-gray-400);
  font-size: .85rem;
  background: #fafbfc;
  border-radius: 11px;
  border: 1px dashed var(--ap-gray-200);
}

.ms-alerta-row--highlight {
  background: #dbeafe !important;
  box-shadow: inset 0 0 0 2px #3b82f6;
  transition: background .3s ease;
}

.ms-alerta-info-toast-stack {
  position: fixed;
  top: calc(var(--navbar-h, 64px) + 12px);
  right: 16px;
  z-index: 1200;
  width: min(520px, calc(100vw - 2rem));
  pointer-events: none;
}
.ms-alerta-info-toast {
  position: relative;
  pointer-events: auto;
  display: grid;
  grid-template-columns: 4px auto 1fr auto;
  align-items: start;
  gap: 0 .75rem;
  padding: .9rem 2.6rem .9rem 0;
  background: #fffef8;
  border: 1px solid #e8e4d4;
  border-radius: 12px;
  box-shadow: 0 10px 36px rgba(15, 23, 42, .12);
  animation: ms-toast-in .25s ease-out;
}
.ms-alerta-info-toast--ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  box-shadow: 0 10px 36px rgba(22, 163, 74, .12);
}
.ms-alerta-info-toast--ok .ms-alerta-info-toast-accent {
  background: #16a34a;
}
.ms-alerta-info-toast--ok .ms-alerta-info-toast-icon {
  background: #22c55e;
  color: #fff;
}
.ms-alerta-info-toast--ok .ms-alerta-info-toast-desc strong {
  color: #15803d;
}
.ms-alerta-info-toast-accent {
  align-self: stretch;
  width: 4px;
  border-radius: 12px 0 0 12px;
  margin: -1px 0 -1px -1px;
  background: #ca8a04;
}
.ms-alerta-info-toast-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #eab308;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: .1rem;
}
.ms-alerta-info-toast-body {
  min-width: 0;
}
.ms-alerta-info-toast-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .5rem;
  margin-bottom: .45rem;
  font-size: .86rem;
  color: #334155;
  line-height: 1.35;
}
.ms-alerta-info-toast-name {
  font-weight: 700;
  color: #0f172a;
}
.ms-alerta-info-toast-code {
  font-size: .72rem;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  padding: .12rem .42rem;
  border-radius: 6px;
}
.ms-alerta-info-toast-sep {
  width: 1px;
  height: 14px;
  background: #cbd5e1;
  flex-shrink: 0;
}
.ms-alerta-info-toast-head-msg {
  color: #475569;
}
.ms-alerta-info-toast-desc {
  margin: 0;
  font-size: .8rem;
  color: #64748b;
  line-height: 1.45;
}
.ms-alerta-info-toast-desc strong {
  color: #a16207;
  font-weight: 700;
}
.ms-alerta-info-toast-close {
  position: absolute;
  top: .55rem;
  right: .55rem;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.ms-alerta-info-toast-close:hover {
  background: #e2e8f0;
  color: #334155;
}

.ms-alert-toast-stack {
  position: fixed;
  top: calc(var(--navbar-h, 64px) + 12px);
  right: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  width: min(400px, calc(100vw - 2rem));
  pointer-events: none;
}
.ms-alert-toast {
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 36px rgba(15, 23, 42, .14);
  border: 1px solid #e8ecf1;
  overflow: hidden;
  animation: ms-toast-in .25s ease-out;
}
.ms-alert-toast-close {
  position: absolute;
  top: .55rem;
  right: .55rem;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  line-height: 1;
  transition: background .15s, color .15s;
}
.ms-alert-toast-close:hover {
  background: #e2e8f0;
  color: #334155;
}
.ms-alert-toast-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: .75rem;
  padding: .9rem 2.5rem .85rem .9rem;
}
.ms-alert-toast-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  align-self: center;
}
.ms-alert-toast-icon.ms-notif-baja    { background: #fef9c3; color: #ca8a04; }
.ms-alert-toast-icon.ms-notif-media   { background: #ffedd5; color: #ea580c; }
.ms-alert-toast-icon.ms-notif-critica { background: #fee2e2; color: #dc2626; }
.ms-alert-toast-icon.ms-notif-urgente { background: #fee2e2; color: #dc2626; }
.ms-alert-toast-center {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-self: center;
}
.ms-alert-toast-name {
  font-size: .95rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.ms-alert-toast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.ms-alert-toast-chip {
  font-size: .68rem;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: .15rem .45rem;
  border-radius: 6px;
  line-height: 1.2;
}
.ms-alert-toast-chip--codigo {
  color: #2563eb;
  background: #eff6ff;
}
.ms-alert-toast-desc {
  margin: 0;
  font-size: .76rem;
  color: #64748b;
  line-height: 1.35;
}
.ms-alert-toast-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: .35rem;
  padding-left: .75rem;
  border-left: 1px solid #e2e8f0;
  flex-shrink: 0;
  min-width: 72px;
}
.ms-alert-toast-badge {
  font-size: .62rem;
  font-weight: 700;
  padding: .18rem .5rem;
  border-radius: 999px;
  letter-spacing: .03em;
  white-space: nowrap;
  line-height: 1.2;
}
.ms-alert-toast-baja .ms-alert-toast-badge,
.ms-alert-toast-badge.ms-notif-baja { background: #fef3c7; color: #a16207; }
.ms-alert-toast-media .ms-alert-toast-badge,
.ms-alert-toast-badge.ms-notif-media { background: #ffedd5; color: #c2410c; }
.ms-alert-toast-critica .ms-alert-toast-badge,
.ms-alert-toast-badge.ms-notif-critica { background: #fee2e2; color: #991b1b; }
.ms-alert-toast-urgente .ms-alert-toast-badge,
.ms-alert-toast-badge.ms-notif-urgente { background: #fee2e2; color: #dc2626; }
.ms-alert-toast-stock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.ms-alert-toast-stock-label {
  font-size: .68rem;
  color: #94a3b8;
}
.ms-alert-toast-stock-num {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}
.ms-alert-toast-date {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .65rem;
  color: #94a3b8;
  white-space: nowrap;
}
.ms-alert-toast-footer {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem .85rem;
  border-top: 1px solid transparent;
  font-size: .72rem;
  color: #64748b;
}
.ms-alert-toast-footer-icon {
  flex-shrink: 0;
  font-size: .85rem;
  opacity: .85;
}
.ms-alert-toast-footer-text {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.ms-alert-toast-footer-link {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  color: #2563eb;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ms-alert-toast-footer-link:hover { text-decoration: underline; }
.ms-alert-toast-footer-baja {
  background: #fffbeb;
  border-top-color: #fde68a;
  border-left: 4px solid #eab308;
}
.ms-alert-toast-footer-media {
  background: #fff7ed;
  border-top-color: #fed7aa;
  border-left: 4px solid #f97316;
}
.ms-alert-toast-footer-critica {
  background: #fef2f2;
  border-top-color: #fecaca;
  border-left: 4px solid #ef4444;
}
.ms-alert-toast-footer-urgente {
  background: #fef2f2;
  border-top-color: #fecaca;
  border-left: 4px solid #dc2626;
}
@keyframes ms-toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Formularios ────────────────────────────────────────────── */
.ms-form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ap-gray-600);
  margin-bottom: .32rem;
  display: block;
}
.ms-input, .ms-select {
  width: 100%;
  font-family: var(--font-main);
  font-size: .88rem;
  color: var(--ap-gray-800);
  background: var(--ap-white);
  border: 1.5px solid var(--ap-gray-200);
  border-radius: var(--ap-radius-sm);
  padding: .58rem .9rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.ms-input:focus, .ms-select:focus {
  border-color: var(--ap-blue);
  box-shadow: 0 0 0 3px rgba(0,51,161,.1);
}
.ms-input::placeholder { color: var(--ap-gray-400); }
.ms-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.4rem;
  cursor: pointer;
}
.ms-form-hint  { font-size: .74rem; color: var(--ap-gray-400); margin-top: .28rem; }
.ms-form-error { font-size: .74rem; color: var(--ms-error);    margin-top: .28rem; }

/* ── Alertas flash ──────────────────────────────────────────── */
.ms-alert {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .85rem 1rem;
  border-radius: var(--ap-radius-sm);
  font-size: .86rem;
  font-weight: 500;
  margin-bottom: 1rem;
  border-left: 3.5px solid transparent;
}
.ms-alert-success { background: #ecfdf5; border-color: #059669; color: #065f46; }
.ms-alert-danger  { background: #fff2f2; border-color: var(--ms-error); color: #7f1d1d; }
.ms-alert-warning { background: #fffbeb; border-color: var(--ms-warning); color: #78350f; }
.ms-alert-info    { background: var(--ap-blue-light); border-color: var(--ap-blue); color: var(--ap-navy); }

/* ── Login ──────────────────────────────────────────────────── */
.ms-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--ap-gray-100) 0%, #e8eef8 100%);
  padding: 1rem;
}
.ms-login-card {
  width: 100%;
  max-width: 400px;
  background: var(--ap-white);
  border: none;
  border-radius: var(--ap-radius);
  padding: 2.5rem 2.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.1);
}
.ms-login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1.75rem;
}
.ms-login-logo img { height: 40px; width: auto; }
.ms-login-title { font-size: 1.05rem; font-weight: 700; color: var(--ap-gray-800); text-align: center; margin: 0; }
.ms-login-sub   { font-size: .8rem;   color: var(--ap-gray-400); text-align: center; margin: 0; }

/* ── Separador ──────────────────────────────────────────────── */
.ms-divider { border: none; border-top: 1px solid var(--ap-gray-200); margin: 1.1rem 0; }

/* ── Títulos / Eyebrow ──────────────────────────────────────── */
.ms-page-title {
  font-size: clamp(1.25rem, 2.8vw, 1.55rem);
  font-weight: 800;
  color: var(--ap-gray-800);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
}
.ms-eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ap-blue);
  margin-bottom: .2rem;
}

/* ── Código inline ──────────────────────────────────────────── */
code {
  font-size: .8em;
  color: var(--ap-blue);
  background: var(--ap-blue-light);
  border-radius: 6px;
  padding: 1px 5px;
}

/* ── Empty state ────────────────────────────────────────────── */
.ms-empty { text-align: center; padding: 2.5rem 1rem; color: var(--ap-gray-400); }
.ms-empty i { font-size: 2.2rem; display: block; margin-bottom: .6rem; opacity: .4; }

/* ── Scroll personalizado ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ap-gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ap-gray-400); }

/* ── Scroll reveal ──────────────────────────────────────────── */
.ms-reveal,
[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .6s var(--ap-transition),
              transform .6s var(--ap-transition);
}
.ms-reveal.visible,
.ms-reveal.revealed,
[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}
.ms-reveal:nth-child(2) { transition-delay: .08s; }
.ms-reveal:nth-child(3) { transition-delay: .16s; }
.ms-reveal:nth-child(4) { transition-delay: .24s; }

/* ── Glassmorphism ──────────────────────────────────────────── */
.ms-glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255,255,255,0.4);
}
.ms-glass-dark {
  background: rgba(0,26,82,0.65);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
}

/* ── Modal ──────────────────────────────────────────────────── */
.ms-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.ms-modal-overlay.active { display: flex; }
.ms-modal {
  background: var(--ap-white);
  border-radius: var(--ap-radius);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ms-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--ap-gray-200);
  flex-shrink: 0;
}
.ms-modal-title { font-size: .98rem; font-weight: 700; color: var(--ap-gray-800); margin: 0; }
.ms-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--ap-gray-400); font-size: 1.1rem; padding: .2rem;
  border-radius: 7px; transition: background .12s, color .12s;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
}
.ms-modal-close:hover { background: var(--ap-gray-100); color: var(--ap-gray-600); }
.ms-modal-body { padding: 1.1rem 1.4rem; overflow-y: auto; }

/* ── Footer ─────────────────────────────────────────────────── */
.ms-footer {
  background: var(--ap-navy);
  color: rgba(255,255,255,0.6);
  padding: 48px 0 20px;
  margin-top: auto;
}
.ms-footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-px);
}
.ms-footer a { color: rgba(255,255,255,0.6); text-decoration: none; font-size: .83rem; transition: color .15s; }
.ms-footer a:hover { color: #fff; }
.ms-footer-bottom {
  max-width: var(--container-max);
  margin: 28px auto 0;
  padding: 16px var(--container-px) 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: .76rem;
  color: rgba(255,255,255,0.3);
}

/* ── Accesibilidad ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid rgba(0,100,255,.55);
  outline-offset: 2px;
  border-radius: 4px;
}
.ms-btn, .ms-btn-logout, button, [role="button"] { min-height: 44px; }
.ms-btn-sm { min-height: 34px; }

/* ── Misc ────────────────────────────────────────────────────── */
.ms-hero-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* ================================================================
   RESPONSIVE — Mobile-first breakpoints
   xs  < 480px   (teléfonos pequeños)
   sm  480–767px (teléfonos grandes)
   md  768–991px (tablets)
   lg  992–1199px (laptops)
   xl  ≥1200px   (escritorio)
   ================================================================ */

/* ── Base mobile-first: todo parte desde móvil ─────────────── */

/* Navbar compacta en cualquier pantalla pequeña */
@media (max-width: 991px) {
  .ms-navbar { padding: 0 1rem; height: 52px; }
  .ms-navbar-desktop { display: none !important; }
}
@media (min-width: 992px) {
  .ms-drawer, .ms-drawer-overlay, #btnDrawer { display: none !important; }
  .ms-navbar-desktop { display: flex; align-items: center; }
}

/* Contenedor principal */
@media (max-width: 767px) {
  .ms-main { padding: 1rem .875rem; }
}
@media (min-width: 768px) and (max-width: 991px) {
  .ms-main { padding: 1.25rem 1.25rem; }
}

/* ── KPI cards ──────────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-kpi {
    padding: 1rem 1.1rem;
    gap: .75rem;
    min-height: 80px;
  }
  .ms-kpi-icon { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 11px; }
  .ms-kpi-value { font-size: 1.5rem; }
  .ms-kpi-label { font-size: .66rem; }
}
@media (min-width: 480px) and (max-width: 767px) {
  .ms-kpi { padding: 1.1rem 1.2rem; }
  .ms-kpi-value { font-size: 1.6rem; }
}

/* ── Cards hover: deshabilitar en touch ─────────────────────── */
@media (hover: none) {
  .ms-card:hover, .ms-kpi:hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }
}

/* ── Botones ────────────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-btn { font-size: .8rem; padding: .44rem .95rem; }
  .ms-btn-sm { font-size: .72rem; padding: .28rem .7rem; }
  /* Botones full-width en pantallas muy pequeñas cuando están solos */
  .ms-btn-block-xs { width: 100%; justify-content: center; }
}

/* ── Tablas responsivas ─────────────────────────────────────── */
/* En móvil: scroll horizontal dentro del wrapper */
.ms-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Indicador visual de scroll */
  background:
    linear-gradient(to right, white 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.08), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.08), transparent) 0 100%;
  background-repeat: no-repeat;
  background-color: white;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

@media (max-width: 767px) {
  .ms-table { font-size: .8rem; min-width: 480px; }
  .ms-table thead th { padding: .55rem .75rem; font-size: .62rem; }
  .ms-table tbody td { padding: .6rem .75rem; }
}

/* ── Card headers en móvil ──────────────────────────────────── */
@media (max-width: 575px) {
  .ms-card-header {
    flex-wrap: wrap;
    gap: .5rem;
    padding: .9rem 1rem .6rem;
  }
  .ms-card-body { padding: 1rem; }
}

/* ── Títulos de página ──────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-page-title { font-size: 1.2rem; }
}

/* ── Login ──────────────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-login-card {
    padding: 1.75rem 1.25rem;
    border-radius: var(--ms-radius);
    box-shadow: none;
    border: 1px solid var(--ap-gray-200);
  }
  .ms-login-wrap { background: var(--ap-white); align-items: flex-start; padding-top: 2rem; }
}

/* ── Modal ──────────────────────────────────────────────────── */
@media (max-width: 575px) {
  .ms-modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--ms-radius) var(--ms-radius) 0 0;
    margin-top: auto;
  }
  .ms-modal-overlay { align-items: flex-end; padding: 0; }
}

/* ── Alertas flash ──────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-alert { font-size: .82rem; padding: .7rem .85rem; gap: .55rem; }
}

/* ── Badges ─────────────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-badge { font-size: .63rem; padding: 2px 7px; }
}

/* ── Formularios ────────────────────────────────────────────── */
@media (max-width: 479px) {
  .ms-input, .ms-select { font-size: .85rem; padding: .52rem .8rem; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .ms-reveal, [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ── Safe areas (iPhone notch / Dynamic Island) ──────────────── */
@supports (padding: env(safe-area-inset-top)) {
  .ms-navbar {
    padding-left:  max(var(--container-px), env(safe-area-inset-left));
    padding-right: max(var(--container-px), env(safe-area-inset-right));
  }
  .ms-main {
    padding-left:  max(.875rem, env(safe-area-inset-left));
    padding-right: max(.875rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
@media (min-width: 768px) {
  @supports (padding: env(safe-area-inset-top)) {
    .ms-main {
      padding-left:  max(var(--container-px), env(safe-area-inset-left));
      padding-right: max(var(--container-px), env(safe-area-inset-right));
    }
  }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .ms-navbar, .ms-drawer, .ms-drawer-overlay,
  #btnDrawer, .ms-btn, .ms-alert { display: none !important; }
  .ms-main { padding: 0; max-width: 100%; }
  .ms-card { box-shadow: none; border: 1px solid #ddd; border-radius: 4px; }
  body { background: #fff; font-size: .85rem; }
}

/* ── Utilidades ─────────────────────────────────────────────── */
.w-100 { width: 100% !important; }
.justify-content-center { justify-content: center !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* IE / Edge legacy fallback: sin backdrop-filter */
@supports not (backdrop-filter: blur(1px)) {
  .ms-navbar { background: rgba(255,255,255,0.98); }
  .ms-navbar .dropdown-menu { background: #fff; }
}

/* ================================================================
   CORRECCIONES RESPONSIVAS — templates inline
   ================================================================ */

/* Buscador autocomplete: no desbordarse en móvil */
[id$="Sugerencias"],
#invActualSug,
#filtroSugerencias,
#invSugerencias {
  min-width: 0 !important;
  max-width: calc(100vw - 2rem);
}

/* Filtros de historial/reportes: columnas apiladas en móvil */
@media (max-width: 575px) {
  #cardFiltro .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
  #cardFiltro .col-md-1 { flex: 0 0 100%; max-width: 100%; }
  #cardFiltro .col-md-1 .d-flex { width: 100%; }
  #cardFiltro .col-md-1 button,
  #cardFiltro .col-md-1 a { flex: 1; justify-content: center; }
}

/* Buscador: ancho adaptable en páginas de inventario */
@media (max-width: 575px) {
  /* Reemplazar max-width:35%/40% inline */
  div[style*="max-width:35%"],
  div[style*="max-width:40%"],
  div[style*="max-width: 35%"],
  div[style*="max-width: 40%"] {
    max-width: 100% !important;
  }
}

/* Headers de página: apilar en móvil */
@media (max-width: 479px) {
  .d-flex.justify-content-between.align-items-start {
    flex-direction: column;
    gap: .75rem;
  }
  /* Botones de exportar (Excel/PDF) en fila */
  .d-flex.gap-2.flex-wrap { flex-wrap: wrap; }
}

/* Tabla historial: columnas anchas fijas → scroll */
@media (max-width: 991px) {
  #tablaHistorial { min-width: 700px; }
  table.ms-table[style*="table-layout:fixed"] {
    table-layout: auto !important;
    min-width: 700px;
  }
}

/* Tabla inventario actual */
@media (max-width: 767px) {
  #tablaInv, #tablaInvActual { min-width: 600px; }
}

/* KPIs del dashboard: 2 columnas en tablet */
@media (min-width: 480px) and (max-width: 767px) {
  .col-sm-6.col-xl-3 { flex: 0 0 50%; max-width: 50%; }
}

/* Gráfica dashboard + alertas: full width en tablet/móvil */
@media (max-width: 991px) {
  .col-lg-7, .col-lg-5 { flex: 0 0 100%; max-width: 100%; }
}

/* Reportes mensual: select de mes no se desborda */
@media (max-width: 575px) {
  #selectMes { min-width: 0 !important; width: 100% !important; }
  #formFiltro .row { row-gap: .6rem; }
}

/* Formularios de entrada/salida/nuevo insumo */
@media (max-width: 575px) {
  .ms-login-card, .ms-card-body form .row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Tabla colgroup en historial: no aplicar anchos fijos en móvil */
@media (max-width: 991px) {
  colgroup col { width: auto !important; }
}

/* Card header con muchos botones: wrap en móvil */
@media (max-width: 575px) {
  .ms-card-header { flex-wrap: wrap; }
  .ms-card-header > div { min-width: 0; }
}

/* Tablas de reportes mensual: min-width para scroll correcto */
@media (max-width: 991px) {
  #tablaHistorial,
  .ms-table { min-width: 560px; }
}

/* Dashboard últimos movimientos: ocultar columna Usuario en móvil */
@media (max-width: 575px) {
  .ms-table th:last-child,
  .ms-table td:last-child { display: none; }
}

/* ── Drawer responsivo mejorado ─────────────────────────────── */
/* Táctil: agrandar áreas de toque */
@media (max-width: 991px) {
  .ms-drawer-nav a { min-height: 44px; }
  .ms-drawer-footer a { min-height: 44px; }
}

/* ── Chart.js canvas: no desbordarse ────────────────────────── */
#chartSalidas {
  max-width: 100%;
  touch-action: pan-y;
}

/* ── Formularios de exportar en mensual ─────────────────────── */
@media (max-width: 479px) {
  .d-flex.gap-2.mb-3 form { flex: 1; }
  .d-flex.gap-2.mb-3 form button { width: 100%; justify-content: center; }
}

/* ── Selector de mes en dashboard ───────────────────────────── */
@media (max-width: 479px) {
  #selectMes { font-size: .8rem !important; }
}

/* ── Botón hamburguesa: touch-friendly ──────────────────────── */
#btnDrawer {
  min-height: 44px;
  min-width: 44px;
}

/* ================================================================
   CROSS-BROWSER — compatibilidad Firefox, Safari, Edge legacy
   ================================================================ */

/* Firefox: scroll personalizado */
* { scrollbar-width: thin; scrollbar-color: var(--ap-gray-200) transparent; }

/* Safari: inputs sin estilo nativo */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: .5;
  cursor: pointer;
}

/* Edge/IE: backdrop-filter fallback (ya declarado arriba, reforzado) */
@supports not (backdrop-filter: blur(1px)) {
  .ms-navbar, .ms-glass { background: rgba(255,255,255,0.99) !important; }
}

/* Safari: evitar zoom en inputs < 16px */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  .ms-input, .ms-select, select, textarea, input {
    font-size: max(16px, 1em);
  }
}
/* Sobreescribir solo cuando hay espacio suficiente */
@media (min-width: 768px) {
  .ms-input, .ms-select { font-size: .88rem; }
}

/* ── Viewport height en móvil (iOS Safari 100vh bug) ────────── */
.ms-login-wrap { min-height: 100svh; min-height: 100vh; }

/* ── Barra de búsqueda (movimientos) ─────────────────────────── */
.ms-search-bar { position: relative; max-width: 320px; }
.ms-search-bar input { padding-left: 2.4rem; background: var(--ap-gray-100); border-color: transparent; }
.ms-search-bar input:focus { background: var(--ap-white); border-color: var(--ap-blue); }
.ms-search-bar .ms-search-icon {
  position: absolute; left: .85rem; top: 50%;
  transform: translateY(-50%);
  color: var(--ap-gray-400); font-size: .9rem;
  pointer-events: none;
}
