/* ============================================================
   CostMed – Hospital San Juan
   Hoja de estilos principal
   Paleta: Blanco | #0F2544 azul marino | #00BFA6 teal
   Tipografía: Montserrat
   ============================================================ */

/* ── Importar fuentes ── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,500&display=swap');

/* ── Variables CSS ── */
:root {
  /* Colores principales */
  --color-bg:           #F7F9FC;
  --color-sidebar:      #0F2544;
  --color-sidebar-alt:  #0d1f3a;
  --color-teal:         #00BFA6;
  --color-teal-dark:    #00a891;
  --color-teal-light:   #E0FFF9;
  --color-navy:         #0F2544;

  /* Texto */
  --color-text-primary:   #1A2B4A;
  --color-text-secondary: #6B7A99;
  --color-text-muted:     #A0AEC0;
  --color-text-inverted:  #FFFFFF;

  /* Estado */
  --color-success:        #22C55E;
  --color-success-light:  #F0FDF4;
  --color-error:          #EF4444;
  --color-error-light:    #FEF2F2;
  --color-warning:        #F59E0B;
  --color-warning-light:  #FFFBEB;
  --color-info:           #3B82F6;
  --color-info-light:     #EFF6FF;

  /* Superficies */
  --color-white:  #FFFFFF;
  --color-border: #E2E8F0;
  --color-hover:  #F0FDF9;
  --color-card:   #FFFFFF;

  /* Tipografía */
  --font-heading: 'Montserrat', -apple-system, sans-serif;
  --font-body:    'Montserrat', -apple-system, sans-serif;

  /* Radios */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

  /* Sidebar */
  --sidebar-width:          260px;
  --sidebar-collapsed-width: 72px;
  --header-height:          64px;

  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-width: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-text-primary);
  line-height: 1.3;
}

a { color: var(--color-teal); text-decoration: none; }
a:hover { color: var(--color-teal-dark); }

img { max-width: 100%; display: block; }

/* ── Layout Principal ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-sidebar);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
  z-index: 100;
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Logo en sidebar */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
  overflow: hidden;
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--color-teal);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.sidebar-brand-text {
  overflow: hidden;
  transition: opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar-brand-text h1 {
  font-family: var(--font-heading);
  font-size: 15px; font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.sidebar-brand-text span {
  font-size: 11px; color: rgba(255,255,255,0.45);
  white-space: nowrap; display: block;
}

.sidebar.collapsed .sidebar-brand-text { opacity: 0; width: 0; }

/* Navegación */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  padding: 8px 20px 4px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
  transition: opacity var(--transition-slow);
}

.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item {
  display: flex; align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 0;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
}

.nav-item.active {
  color: #fff;
  background: rgba(0,191,166,0.15);
}

/* Barra indicadora izquierda en item activo */
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--color-teal);
}

.nav-item-icon {
  width: 20px; height: 20px;
  flex-shrink: 0; display: flex;
  align-items: center; justify-content: center;
  font-size: 17px;
}

.nav-item-label {
  flex: 1;
  overflow: hidden;
  transition: opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar.collapsed .nav-item-label { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .nav-section-title { pointer-events: none; }

/* Badge contador */
.nav-badge {
  background: var(--color-teal);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: opacity var(--transition-slow);
}

.sidebar.collapsed .nav-badge { opacity: 0; }

/* Footer del sidebar */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 16px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover { background: rgba(255,255,255,0.07); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--color-teal), #0099ff);
  border-radius: 50%; display: flex;
  align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.user-info {
  flex: 1; overflow: hidden;
  transition: opacity var(--transition-slow);
}

.user-info .user-name {
  font-size: 13px; font-weight: 600;
  color: #fff; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.user-info .user-role {
  font-size: 11px; color: rgba(255,255,255,0.45);
}

.sidebar.collapsed .user-info { opacity: 0; width: 0; }

/* Botón colapsar sidebar */
.sidebar-toggle {
  position: absolute;
  right: -12px; top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--color-text-secondary);
  font-size: 12px;
  transition: all var(--transition-fast);
  z-index: 101;
}

.sidebar-toggle:hover {
  background: var(--color-teal);
  color: #fff;
  border-color: var(--color-teal);
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow), width var(--transition-slow);
  overflow-x: hidden;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
}

/* ── HEADER ── */
.page-header {
  height: var(--header-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}

.header-breadcrumb {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--color-text-secondary);
}

.header-breadcrumb .current {
  color: var(--color-text-primary);
  font-weight: 600;
}

.header-breadcrumb .sep { color: var(--color-border); }

.header-actions {
  display: flex; align-items: center; gap: 8px;
}

.header-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 18px;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--color-teal-light);
  border-color: var(--color-teal);
  color: var(--color-teal);
}

/* Indicador de notificación */
.header-btn.has-notif { position: relative; }
.header-btn.has-notif::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--color-error);
  border-radius: 50%;
  border: 2px solid #fff;
  position: absolute; top: 6px; right: 6px;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  padding: 28px 28px 40px;
  min-width: 0;
  overflow-x: hidden;
}

.page-title-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}

.page-title {
  font-size: 24px; font-weight: 700;
  color: var(--color-text-primary);
}

.page-subtitle {
  font-size: 14px; color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ── CARDS ── */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 15px; font-weight: 700;
  color: var(--color-text-primary);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  background: #FAFBFC;
}

/* Cards de métricas */
.metric-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.metric-card-value {
  font-family: var(--font-heading);
  font-size: 26px; font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1;
}

.metric-card-label {
  font-size: 13px; color: var(--color-text-secondary);
  margin-top: 4px;
}

.metric-card-trend {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500;
  margin-top: 10px;
}

.trend-up   { color: var(--color-success); }
.trend-down { color: var(--color-error); }

/* ── GRID ── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 500;
  cursor: pointer; border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  position: relative; overflow: hidden;
}

.btn:active { transform: scale(0.97); }

/* Primary */
.btn-primary {
  background: var(--color-teal);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,191,166,0.3);
}
.btn-primary:hover { background: var(--color-teal-dark); color: #fff; }

/* Secondary */
.btn-secondary {
  background: var(--color-white);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }

/* Danger */
.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

/* Warning */
.btn-warning {
  background: var(--color-warning);
  color: #fff;
}
.btn-warning:hover { background: #d97706; color: #fff; }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

/* Tallas */
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-xl { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* Estado: cargando */
.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading .btn-text { opacity: 0; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Estado: éxito */
@keyframes checkmark { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.btn.success-anim { background: var(--color-success) !important; }
.btn.success-anim .btn-icon-check { animation: checkmark 0.2s ease; }

/* ── FORMULARIOS ── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.form-label .req { color: var(--color-error); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text-primary);
  background: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
}

.form-control:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(0,191,166,0.15);
}

.form-control.is-error {
  border-color: var(--color-error);
  animation: shake 0.4s ease;
}

.form-control.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.form-error {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--color-error);
  margin-top: 5px;
}

.form-hint {
  font-size: 12px; color: var(--color-text-muted);
  margin-top: 5px;
}

/* Input con icono */
.input-group { position: relative; }

.input-group .form-control {
  padding-left: 42px;
}

.input-group .input-icon {
  position: absolute; left: 14px;
  top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); font-size: 16px;
  pointer-events: none;
}

.input-group .input-action {
  position: absolute; right: 12px;
  top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--color-text-muted);
  font-size: 16px;
  transition: color var(--transition-fast);
}

.input-group .input-action:hover { color: var(--color-teal); }

/* Checkbox y radio */
.form-check {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}

.form-check-input {
  width: 18px; height: 18px;
  accent-color: var(--color-teal);
  cursor: pointer; flex-shrink: 0;
}

.form-check-label {
  font-size: 14px; color: var(--color-text-secondary);
}

/* Select */
select.form-control {
  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='%236B7A99' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* Textarea */
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* ── TABLAS ── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  max-width: 100%;
}

table.data-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead tr {
  background: #FAFBFC;
  border-bottom: 1px solid var(--color-border);
}

.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody tr:hover { background: var(--color-hover); }

.data-table tbody td {
  padding: 13px 16px;
  color: var(--color-text-primary);
  vertical-align: middle;
}

.data-table .col-actions {
  text-align: right;
  width: 1px; white-space: nowrap;
}

/* ── BADGES / ETIQUETAS ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: var(--color-success-light);  color: #16a34a; }
.badge-error    { background: var(--color-error-light);    color: #dc2626; }
.badge-warning  { background: var(--color-warning-light);  color: #d97706; }
.badge-info     { background: var(--color-info-light);     color: #2563eb; }
.badge-neutral  { background: #F1F5F9; color: var(--color-text-secondary); }
.badge-teal     { background: var(--color-teal-light);     color: #00897b; }

/* ── ALERTAS / TOASTS ── */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 14px; margin-bottom: 18px;
}

.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-body { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; }

.alert-success { background: var(--color-success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--color-error-light);   color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--color-warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--color-info-light);    color: #1e40af; border: 1px solid #bfdbfe; }

/* Toasts */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column;
  gap: 10px; align-items: flex-end;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  font-size: 14px;
  min-width: 280px; max-width: 380px;
  animation: toastIn 0.3s ease;
}

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

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

.toast.dismissing { animation: toastOut 0.3s ease forwards; }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; color: var(--color-text-primary); }
.toast-msg   { font-size: 13px; color: var(--color-text-secondary); }
.toast-close {
  color: var(--color-text-muted); cursor: pointer;
  font-size: 18px; flex-shrink: 0;
  transition: color var(--transition-fast);
}
.toast-close:hover { color: var(--color-text-primary); }

/* ── MODALES ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,37,68,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}

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

.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 17px; font-weight: 700;
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text-muted);
  font-size: 20px;
  transition: all var(--transition-fast);
  background: transparent; border: none;
}

.modal-close:hover { background: var(--color-bg); color: var(--color-text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── SKELETON LOADERS ── */
.skeleton {
  background: linear-gradient(90deg, #E2E8F0 25%, #EDF2F7 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-card  { height: 100px; }
.skeleton-row   { height: 48px; margin-bottom: 1px; }

/* ── PAGINACIÓN ── */
.pagination {
  display: flex; align-items: center;
  gap: 4px; flex-wrap: wrap;
}

.page-btn {
  min-width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  padding: 0 8px;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.page-btn:hover { background: var(--color-teal-light); border-color: var(--color-teal); color: var(--color-teal); }
.page-btn.active { background: var(--color-teal); border-color: var(--color-teal); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── BARRA DE BÚSQUEDA ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative; flex: 1; min-width: 200px;
}

.search-input-wrapper .form-control {
  padding-left: 40px;
}

.search-icon {
  position: absolute; left: 13px;
  top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); font-size: 16px;
  pointer-events: none;
}

/* ── TABS ── */
.tabs {
  display: flex; border-bottom: 2px solid var(--color-border);
  margin-bottom: 20px; overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer; border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover { color: var(--color-teal); }
.tab-btn.active { color: var(--color-teal); border-bottom-color: var(--color-teal); font-weight: 600; }

/* ── AUTH LAYOUT ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: var(--color-bg);
}

.auth-panel-left {
  width: 420px; min-height: 100vh;
  background: linear-gradient(160deg, #0F2544 0%, #0d3060 60%, #0a2040 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 40px;
  position: relative; overflow: hidden;
}

.auth-panel-left::before {
  content: '';
  position: absolute; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,191,166,0.15) 0%, transparent 70%);
  top: -100px; right: -100px;
}

.auth-panel-left::after {
  content: '';
  position: absolute; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(0,191,166,0.1) 0%, transparent 70%);
  bottom: -50px; left: -50px;
}

.auth-panel-right {
  flex: 1; display: flex;
  align-items: center; justify-content: center;
  padding: 40px 24px;
}

.auth-box {
  width: 100%; max-width: 420px;
}

.auth-logo-block {
  text-align: center; margin-bottom: 32px;
}

.auth-logo-icon {
  width: 64px; height: 64px;
  background: var(--color-teal);
  border-radius: var(--radius-xl);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 16px;
}

.auth-box h2 {
  font-size: 26px; font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.auth-box .auth-subtitle {
  font-size: 14px; color: var(--color-text-secondary);
}

/* ── PROGRESS BAR ── */
.progress-bar-wrapper {
  background: var(--color-border);
  border-radius: var(--radius-full);
  height: 8px; overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-teal), #00e5cc);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* ── DIVIDER ── */
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--color-text-muted); font-size: 13px;
  margin: 20px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1; height: 1px;
  background: var(--color-border);
}

/* ── UTILIDADES ── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1        { gap: 4px; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.gap-6        { gap: 24px; }
.flex-1       { flex: 1; }
.flex-wrap    { flex-wrap: wrap; }

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-sm      { font-size: 13px; }
.text-xs      { font-size: 11px; }
.text-lg      { font-size: 16px; }
.text-xl      { font-size: 18px; }

.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }

.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted     { color: var(--color-text-muted); }
.text-teal      { color: var(--color-teal); }
.text-success   { color: var(--color-success); }
.text-error     { color: var(--color-error); }
.text-warning   { color: var(--color-warning); }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-0  { padding: 0 !important; }
.p-4  { padding: 16px; }
.p-5  { padding: 20px; }
.p-6  { padding: 24px; }

.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rounded { border-radius: var(--radius-md); }
.rounded-full { border-radius: var(--radius-full); }
.shadow-sm { box-shadow: var(--shadow-sm); }

.opacity-50 { opacity: 0.5; }

/* Separador */
.hr { border: none; border-top: 1px solid var(--color-border); margin: 16px 0; }

/* ── RESPONSIVE ── */

/* Tablet grande / desktop pequeño */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-content { padding: 20px; }
}

/* Tablet */
@media (max-width: 768px) {
  /* Sidebar: drawer deslizable */
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    width: var(--sidebar-width) !important;
  }

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

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,37,68,0.6);
    z-index: 99;
  }

  .sidebar-overlay.visible { display: block; }

  /* Main sin margen lateral */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Contenido */
  .page-content { padding: 14px 14px 32px; }
  .page-title { font-size: 20px; }
  .page-title-row { flex-direction: column; align-items: flex-start; }
  .page-title-row > div:last-child { width: 100%; }
  .page-title-row .flex { flex-wrap: wrap; }

  /* Grids colapsan a 1 columna */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }

  /* Header compacto */
  .page-header { padding: 0 14px; gap: 10px; }
  .header-breadcrumb { font-size: 12px; overflow: hidden; }
  .header-breadcrumb .sep:not(:last-of-type) ~ * { display: none; }

  /* Tablas scroll interno */
  .table-wrapper { border-radius: 0; }

  /* Cards */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header .input-group { width: 100% !important; }

  /* Formularios */
  .form-group { margin-bottom: 14px; }

  /* Auth */
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 24px 16px; }
  .auth-box { max-width: 100%; }

  /* Modales: pantalla completa en móvil */
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 95vh;
    max-width: 100% !important;
  }

  /* Métricas */
  .metric-card-value { font-size: 22px; }

  /* Botones en page-title-row: ancho completo en móvil */
  .page-title-row .btn { flex: 1; justify-content: center; min-width: 120px; }

  /* Paginación */
  .card-footer { flex-direction: column; gap: 10px; align-items: center; }

  /* Toasts */
  .toast-container { left: 12px; right: 12px; bottom: 16px; }
  .toast { min-width: unset; width: 100%; max-width: 100%; }

  /* Ocultar columnas auxiliares en tablas */
  .d-none-mobile { display: none !important; }

  /* Sidebar toggle desktop oculto */
  .d-lg-none  { display: flex !important; }
  .d-none.d-lg-flex { display: none !important; }
}

/* Móvil pequeño */
@media (max-width: 480px) {
  .page-content { padding: 10px 10px 28px; }
  .page-title { font-size: 18px; }
  .metric-card { padding: 14px; }
  .metric-card-value { font-size: 20px; }
  .metric-card-icon { width: 36px; height: 36px; margin-bottom: 10px; }

  /* Tabla: reducir padding celdas */
  .data-table thead th,
  .data-table tbody td { padding: 10px 10px; font-size: 13px; }

  /* Card body compacto */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 12px 14px; }

  /* Formulario en cols: 1 col siempre */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Badges compactos */
  .badge { font-size: 11px; padding: 2px 7px; }

  /* Filtros de búsqueda */
  .search-bar { flex-direction: column; }
  .search-input-wrapper { min-width: unset; width: 100%; }
}

/* ── ANIMACIONES GLOBALES ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-spin   { animation: spin 1s linear infinite; }
.animate-pulse  { animation: pulse 2s infinite; }

/* Dot de estado en vivo */
.live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--color-text-muted);
}

.live-dot::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--color-success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* ── DROP ZONE (importación) ── */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  transition: all var(--transition-base);
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--color-teal);
  background: var(--color-teal-light);
}

.drop-zone .drop-icon { font-size: 48px; margin-bottom: 12px; }
.drop-zone h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.drop-zone p { font-size: 13px; color: var(--color-text-secondary); }

/* ── UTILIDADES RESPONSIVE ── */
.d-none    { display: none !important; }
.d-lg-flex { display: none; }
@media (min-width: 769px) {
  .d-lg-none  { display: none !important; }
  .d-lg-flex  { display: flex !important; }
  .d-lg-block { display: block !important; }
}

/* Contenedor fluido sin overflow */
.overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.overflow-hidden  { overflow: hidden; }
.min-w-0          { min-width: 0; }
.w-full           { width: 100%; }
.max-w-full       { max-width: 100%; }

/* ── SCROLLBAR GLOBAL ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }
