/* ==========================================================================
   CSS PRINCIPAL - SISTEMA DE ASISTENCIA Y COORDINACIÓN DE SERVIDORES
   Diseño Premium Glassmorphism con Modo Dual (Oscuro Predeterminado)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Paleta de Colores (Tema Oscuro por defecto) - Pure Black Mode */
  --bg-app: #000000;
  --bg-sidebar: rgba(10, 10, 10, 0.85);
  --bg-card: rgba(18, 18, 18, 0.75);
  --bg-card-hover: rgba(28, 28, 28, 0.85);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  /* Toast variables */
  --bg-toast: rgba(15, 15, 15, 0.95);
  --border-toast: rgba(255, 255, 255, 0.09);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Colores de Acento */
  --accent-primary: #8b5cf6;       /* Violeta */
  --accent-primary-rgb: 139, 92, 246;
  --accent-secondary: #06b6d4;     /* Cian */
  --accent-success: #10b981;       /* Esmeralda */
  --accent-warning: #f59e0b;       /* Ámbar */
  --accent-danger: #ef4444;        /* Rojo/Rosa */
  
  /* Sombras y Efectos Optimizados para Rendimiento */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --glass-blur: blur(8px); /* Reducido para mejor rendimiento */
  --transition-smooth: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, fill 0.2s ease, opacity 0.2s ease;
  --transition-fast: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

/* Modo Claro */
body.light-theme {
  --bg-app: #fcfbf9; /* Off-white limpio con tono cálido */
  --bg-sidebar: rgba(240, 235, 216, 0.4); /* #f0ebd8 al 40% con efecto esmerilado */
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(116, 140, 171, 0.2); /* #748cab al 20% */
  --border-focus: rgba(62, 92, 118, 0.6); /* #3e5c76 al 60% */
  
  /* Variables de Toast para tema claro */
  --bg-toast: rgba(255, 255, 255, 0.95);
  --border-toast: rgba(116, 140, 171, 0.2);
  
  --text-primary: #1d2d44; /* Azul marino oscuro para títulos y texto principal */
  --text-secondary: #3e5c76; /* Azul acero para textos secundarios y subtítulos */
  --text-muted: #748cab; /* Azul pizarra claro para texto atenuado y detalles */
  
  --accent-primary: #3e5c76; /* Azul acero como acento principal */
  --accent-primary-rgb: 62, 92, 118;
  --accent-secondary: #748cab; /* Azul pizarra como acento secundario */
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 32px rgba(62, 92, 118, 0.06);
  --shadow-lg: 0 12px 48px rgba(62, 92, 118, 0.1);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Zero-transition class para cambio instantáneo de tema */
.disable-transitions,
.disable-transitions * {
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -o-transition: none !important;
  -ms-transition: none !important;
  transition: none !important;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body::before,
body::after {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  pointer-events: none;
  will-change: opacity;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fondo radial para modo oscuro */
body::before {
  background-image: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
                    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  opacity: 1;
}

/* Fondo radial para modo claro */
body::after {
  background-image: radial-gradient(at 0% 0%, rgba(116, 140, 171, 0.12) 0px, transparent 50%),
                    radial-gradient(at 100% 100%, rgba(62, 92, 118, 0.08) 0px, transparent 50%);
  opacity: 0;
}

body.light-theme::before {
  opacity: 0;
}

body.light-theme::after {
  opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}
body.light-theme ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.25);
}
body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   LAYOUT ESTRUCTURAL (Sidebar + Main Content)
   ========================================================================== */

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  /* backdrop-filter: var(--glass-blur); Desactivado por rendimiento */
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.45) transparent;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition-smooth);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.4);
  border-radius: 99px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.65);
}

body.light-theme .sidebar {
  scrollbar-color: rgba(62, 92, 118, 0.35) transparent;
}

body.light-theme .sidebar::-webkit-scrollbar-thumb {
  background: rgba(62, 92, 118, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
  flex-shrink: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
body.light-theme .brand-name {
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Nav Menu */
.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
  flex-shrink: 0;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
  fill: none;
  stroke-width: 2;
  transition: var(--transition-smooth);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}
body.light-theme .nav-link:hover {
  background: rgba(0, 0, 0, 0.02);
}

.nav-link:hover svg {
  stroke: var(--text-primary);
}

.nav-item.active .nav-link {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(6, 182, 212, 0.05));
  color: #fff;
  border-color: rgba(139, 92, 246, 0.25);
  box-shadow: var(--shadow-sm);
}
body.light-theme .nav-item.active .nav-link {
  background: linear-gradient(135deg, rgba(62, 92, 118, 0.08), rgba(116, 140, 171, 0.04));
  color: var(--accent-primary);
  border-color: rgba(62, 92, 118, 0.15);
}

.nav-item.active .nav-link svg {
  stroke: var(--accent-primary);
}

/* Sidebar Footer & Theme Toggle */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
}

.db-tools-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.25rem;
}

.db-tools-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.db-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 600;
  font-size: 0.9rem;
  width: 100%;
  flex-shrink: 0;
}
body.light-theme .theme-toggle-btn {
  background: rgba(0, 0, 0, 0.03);
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex-grow: 1;
  padding: 2.5rem;
  min-height: 100vh;
  width: calc(100% - 280px);
  transition: var(--transition-smooth);
}

/* Top Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  gap: 1rem;
}

.top-header-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.header-theme-btn {
  padding: 0.42rem 0.55rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.header-title h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ==========================================================================
   COMPONENTES DE BOTÓN Y CONTROLES (Inputs, Dropdowns)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}
body.light-theme .btn-secondary {
  background: rgba(0, 0, 0, 0.03);
}
body.light-theme .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.06);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-secondary), #0891b2);
  color: #fff;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}
.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-success), #059669);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-danger), #dc2626);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Inputs & Controles de Formulario */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background-color: rgba(20, 20, 20, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
  width: 100%;
}
body.light-theme .form-control {
  background-color: rgba(255, 255, 255, 0.9);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}
body.light-theme select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

/* ==========================================================================
   CARDS Y CONTENEDORES (Glassmorphism)
   ========================================================================== */

.card {
  background: var(--bg-card);
  /* backdrop-filter: var(--glass-blur); Desactivado para evitar lag en dispositivos menos potentes */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  min-width: 0; /* Previene desbordamientos en CSS Grid */
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  /* Se elimina box-shadow en hover para ahorrar recursos de repintado */
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ==========================================================================
   VISTA: DASHBOARD
   ========================================================================== */

/* Grid de Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.15rem;
  color: var(--text-primary);
}

/* Colores de Icono de Métricas */
.m-primary { background: rgba(139, 92, 246, 0.15); color: var(--accent-primary); border: 1px solid rgba(139, 92, 246, 0.2); }
.m-secondary { background: rgba(6, 182, 212, 0.15); color: var(--accent-secondary); border: 1px solid rgba(6, 182, 212, 0.2); }
.m-success { background: rgba(16, 115, 81, 0.15); color: var(--accent-success); border: 1px solid rgba(16, 115, 81, 0.2); }
.m-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-warning); border: 1px solid rgba(245, 158, 11, 0.2); }

.m-primary svg, .m-secondary svg, .m-success svg, .m-warning svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Dashboard Analytics Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Chart Container & Custom SVG Chart */
.chart-container {
  height: 240px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding-top: 1.5rem;
  position: relative;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  width: 12%;
}

.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-primary), rgba(139, 92, 246, 0.2));
  border-radius: 6px 6px 0 0;
  transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  min-height: 5px;
}

.chart-bar:hover {
  filter: brightness(1.2);
}

.chart-tooltip {
  position: absolute;
  top: -30px;
  background: #000;
  color: #fff;
  padding: 2px 6px;
  font-size: 0.75rem;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
  transform: translateY(5px);
  white-space: nowrap;
}

.chart-bar:hover .chart-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.chart-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  width: 100%;
}

/* Progress bar global */
.progress-container {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 0.5rem 0;
}
body.light-theme .progress-container {
  background: rgba(0, 0, 0, 0.05);
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.progress-bar.success {
  background: linear-gradient(90deg, var(--accent-success), #34d399);
}

/* Recent Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.activity-info {
  flex-grow: 1;
}

.activity-title {
  font-size: 0.85rem;
  font-weight: 500;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   VISTA: SERVIDORES (Lista, Fichas, Búsqueda)
   ========================================================================== */

.filters-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
  min-width: 250px;
}

.search-input-wrapper svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}

.search-input-wrapper .form-control {
  padding-left: 2.75rem;
  width: 100%;
}

.filters-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Lista Compacta de Servidores */
.servidores-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.servidor-card {
  position: relative;
  overflow: hidden;
  padding: 0.75rem 1rem !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, border-color 0.2s ease;
  background: var(--surface);
  border: 1px solid var(--border-color);
}

.servidor-card:hover {
  background-color: var(--bg-card-hover) !important;
  border-color: var(--border-focus);
}

.servidor-info-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.servidor-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.servidor-name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.servidor-badge-role {
  align-self: flex-start;
  margin-top: 0.2rem;
}

.servidor-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.detail-item svg {
  width: 13px;
  height: 13px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}

.servidor-details-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.4rem;
}

.detail-compact-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.02);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

body.light-theme .detail-compact-item {
  background: rgba(0, 0, 0, 0.02);
}

.servidor-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.4rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-coordinador {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
body.light-theme .badge-coordinador {
  background: rgba(62, 92, 118, 0.08);
  color: #3e5c76;
  border-color: rgba(62, 92, 118, 0.18);
}

.badge-capitan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.25);
}
body.light-theme .badge-capitan {
  background: rgba(116, 140, 171, 0.12);
  color: #1d2d44;
  border-color: rgba(116, 140, 171, 0.25);
}

.badge-servidor {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
body.light-theme .badge-servidor {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}

.badge-activo {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-inactivo {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Areas chips */
.chip-area {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  color: #fff;
  display: inline-block;
}

/* ==========================================================================
   VISTA: CALENDARIO (Agendamiento por Área)
   ========================================================================== */

.calendario-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(240px, 22vw, 320px);
  gap: clamp(0.75rem, 1.5vw, 1.5rem);
  align-items: start;
}

.card.calendario-main-card {
  padding: clamp(0.85rem, 1.5vw, 1.5rem);
}

.card#calendario-sidebar-card {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  align-self: start;
  z-index: 100;
  padding: clamp(0.85rem, 1.4vw, 1.35rem);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

#cal-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.cal-drag-servers-list {
  max-height: clamp(220px, calc(100vh - 330px), 440px);
  max-height: clamp(220px, calc(100dvh - 330px), 440px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.35rem;
}

@media (max-width: 1100px) {
  .calendario-layout {
    grid-template-columns: 1fr;
  }
  #calendario-sidebar-card {
    position: static;
    max-height: none;
  }
  .cal-drag-servers-list {
    max-height: 360px;
  }
}

/* Toolbar y Subvistas del Calendario */
.cal-toolbar-header {
  flex-wrap: wrap;
  gap: clamp(0.6rem, 1.1vw, 1rem);
  margin-bottom: clamp(0.75rem, 1.3vh, 1.25rem);
  align-items: center;
}

.cal-toolbar-title {
  flex: 1 1 220px;
  min-width: 0;
}

.cal-toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  flex: 1 1 420px;
  justify-content: flex-end;
}

.cal-filter-input {
  flex: 1 1 clamp(120px, 14vw, 175px);
  min-width: 115px;
  font-size: clamp(0.78rem, 0.85vw, 0.85rem);
  padding: clamp(0.34rem, 0.5vw, 0.44rem) clamp(0.55rem, 0.8vw, 0.7rem);
}

.cal-filter-select {
  flex: 1 1 clamp(115px, 13vw, 165px);
  min-width: 110px;
  font-size: clamp(0.78rem, 0.85vw, 0.85rem);
  padding: clamp(0.34rem, 0.5vw, 0.44rem) 2rem clamp(0.34rem, 0.5vw, 0.44rem) clamp(0.55rem, 0.8vw, 0.7rem);
  background-position: right 0.65rem center;
  background-size: 1rem;
}

.cal-filter-tiempo {
  flex: 1 1 clamp(135px, 15vw, 180px);
  font-weight: 500;
}

.cal-view-toggle {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cal-view-toggle .btn-toggle {
  padding: clamp(0.34rem, 0.5vw, 0.44rem) clamp(0.55rem, 0.9vw, 0.8rem);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: clamp(0.76rem, 0.85vw, 0.85rem);
  font-weight: 600;
  white-space: nowrap;
}

.cal-view-toggle .btn-toggle + .btn-toggle {
  border-left: 1px solid var(--border-color);
}

.cal-subview-pane {
  padding: clamp(0.35rem, 0.9vw, 0.9rem) 0 0 0;
}

.cal-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: clamp(0.6rem, 1.2vh, 1rem);
}

.cal-nav-label {
  margin: 0;
  font-weight: 700;
  text-transform: capitalize;
  font-size: clamp(0.92rem, 1.2vw, 1.1rem);
  text-align: center;
}

.eventos-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card.evento-card {
  border-left: 4px solid var(--accent-primary);
  margin-bottom: clamp(0.45rem, 0.9vh, 0.75rem);
  padding: 0;
  overflow: hidden;
}

.evento-card-header {
  padding: clamp(0.7rem, 1.15vw, 1rem) clamp(0.85rem, 1.4vw, 1.25rem);
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.evento-card-body {
  padding: clamp(0.75rem, 1.2vw, 1rem) clamp(0.85rem, 1.4vw, 1.25rem);
}

.evento-card-title {
  font-size: clamp(0.92rem, 1.05vw, 1rem);
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.evento-card-meta {
  font-size: clamp(0.76rem, 0.84vw, 0.82rem);
  color: var(--text-muted);
  margin-top: 0.22rem;
  line-height: 1.4;
}

.evento-notas-block {
  margin-top: 0.45rem;
  padding: clamp(0.35rem, 0.7vw, 0.45rem) clamp(0.55rem, 0.9vw, 0.65rem);
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: clamp(0.76rem, 0.84vw, 0.82rem);
  color: var(--text-primary);
  line-height: 1.4;
}

.cal-proximo-header {
  padding: clamp(0.42rem, 0.8vw, 0.5rem) clamp(0.75rem, 1.2vw, 1rem);
  background: var(--accent-primary);
  color: white;
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  border-radius: 6px;
  font-size: clamp(0.92rem, 1.1vw, 1.05rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cal-proximo-spacer {
  height: 1px;
  background: var(--border-color);
  margin: clamp(1rem, 2vh, 1.75rem) 0;
}

.cal-mes-header {
  padding: clamp(0.42rem, 0.75vw, 0.5rem) clamp(0.75rem, 1.2vw, 1rem);
  background: var(--bg-card-hover);
  border-left: 4px solid var(--accent-primary);
  margin: clamp(0.9rem, 1.8vh, 1.4rem) 0 0.5rem 0;
  font-weight: 600;
  text-transform: capitalize;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: clamp(0.92rem, 1.1vw, 1.08rem);
}

.cal-mes-header-muted {
  border-left-color: var(--text-muted);
}

.cal-mes-header-past {
  padding: 0.4rem 0.8rem;
  background: var(--bg-card);
  border-left: 3px solid var(--text-muted);
  margin: 0.85rem 0 0.45rem 0;
  color: var(--text-muted);
  font-size: clamp(0.85rem, 1vw, 0.95rem);
}

.cal-past-details {
  margin: clamp(1.1rem, 2.2vh, 1.75rem) 0 0.75rem 0;
  background: var(--surface-alt);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
  overflow: hidden;
}

.cal-past-summary {
  padding: clamp(0.65rem, 1.2vw, 0.85rem) clamp(0.85rem, 1.4vw, 1.25rem);
  font-weight: 600;
  font-size: clamp(0.85rem, 0.95vw, 0.95rem);
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cal-past-body {
  padding: clamp(0.65rem, 1.2vw, 1rem);
}

@media (max-width: 720px) {
  .cal-toolbar-controls {
    justify-content: flex-start;
  }
  .cal-view-toggle {
    width: 100%;
  }
  .cal-view-toggle .btn-toggle {
    flex: 1 1 0;
    text-align: center;
  }
}

/* Ajuste automático para pantallas de baja altura efectiva (ej. notebooks con escala 125%–150%) */
@media (max-height: 820px) {
  .calendario-main-card,
  #calendario-sidebar-card {
    padding: 0.9rem 1rem;
  }
  .cal-toolbar-header {
    margin-bottom: 0.75rem;
  }
  .evento-card {
    margin-bottom: 0.5rem;
  }
  .evento-card-header {
    padding: 0.65rem 0.95rem;
  }
  .evento-card-body {
    padding: 0.7rem 0.95rem;
  }
  .cal-proximo-spacer {
    margin: 0.9rem 0;
  }
  .cal-mes-header {
    margin: 0.85rem 0 0.45rem 0;
    padding: 0.38rem 0.85rem;
    font-size: 0.96rem;
  }
}

.evento-time-place {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

.evento-lideres {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
}
body.light-theme .evento-lideres {
  background: rgba(0, 0, 0, 0.02);
}

.lider-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.lider-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 0.15rem;
}

.evento-servidores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.servidor-avatar-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}
body.light-theme .servidor-avatar-pill {
  background: rgba(0, 0, 0, 0.03);
}

.avatar-mini {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #fff;
  font-weight: bold;
}

/* ==========================================================================
   VISTA: ASISTENCIA (Real-time check-in)
   ========================================================================== */

.asistencia-control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.asistencia-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.asistencia-table-card {
  padding: 0;
  overflow: hidden;
}

.asistencia-table-wrapper {
  overflow-x: auto;
}

.asistencia-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.asistencia-table th, 
.asistencia-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.asistencia-table th {
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.1);
}
body.light-theme .asistencia-table th {
  background: rgba(0, 0, 0, 0.02);
}

.asistencia-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}
body.light-theme .asistencia-table tr:hover td {
  background: rgba(0, 0, 0, 0.005);
}

.asistencia-state-btns {
  display: flex;
  gap: 0.5rem;
}

.btn-state {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.btn-state.active-presente {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

.btn-state.active-ausente {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-state.active-tarde {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

/* Switch Toggle for Refreshments */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  transition: .4s;
  border-radius: var(--radius-full);
}
body.light-theme .slider {
  background-color: rgba(0, 0, 0, 0.1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

input:checked + .slider {
  background-color: var(--accent-success);
  border-color: rgba(16, 185, 129, 0.5);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--accent-success);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   VISTA: REFRIGERIOS
   ========================================================================== */

.refrigerio-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  max-width: 1200px;
}

.refrigerio-overview .card {
  padding: 1.15rem 0.85rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 82px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.refrigerio-overview .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.refrigerio-overview .card-progress-full {
  grid-column: 1 / -1 !important;
  display: block !important;
  text-align: left !important;
  padding: 0.9rem 1.25rem !important;
  min-height: auto !important;
}

@media (max-width: 1024px) {
  .refrigerio-overview {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .refrigerio-overview .stat-card-top {
    grid-column: span 2;
  }
  .refrigerio-overview .stat-card-bottom {
    grid-column: span 3;
  }
  .refrigerio-overview .card-progress-full {
    grid-column: span 6 !important;
  }
}

@media (max-width: 600px) {
  .refrigerio-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .refrigerio-overview .stat-card-top {
    grid-column: span 1;
  }
  .refrigerio-overview .stat-card-top:nth-child(3) {
    grid-column: span 2;
  }
  .refrigerio-overview .stat-card-bottom {
    grid-column: span 2;
  }
  .refrigerio-overview .card-progress-full {
    grid-column: span 2 !important;
  }
}

.alergias-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.alergia-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.alergia-name {
  font-weight: 600;
  color: #f87171;
}

.alergia-desc {
  color: var(--text-secondary);
}

/* ==========================================================================
   MODALES (Popups interactivos para Crear/Editar)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 8, 16, 0.75);
  /* backdrop-filter movido a .show para evitar lag extremo de GPU en Chrome */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
  /* backdrop-filter: blur(8px); Removido para evitar lag de GPU */
  background: rgba(5, 8, 16, 0.85); /* Oscurecemos para compensar la falta de blur */
}
body.light-theme .modal-backdrop.show {
  background: rgba(15, 23, 42, 0.45);
}

.modal-container {
  background: #121212; /* Fondo sólido oscuro para evitar transparencias y mejorar el contraste */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 550px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-container form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 100%;
  flex-grow: 1;
}
body.light-theme .modal-container {
  background: #ffffff; /* Fondo sólido blanco puro para el tema claro */
  border-color: rgba(116, 140, 171, 0.25);
}

.modal-backdrop.show .modal-container {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Checkbox Multiple List in Modals */
.checkbox-list {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-height: 160px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.9rem;
}

.checkbox-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.checkbox-item input {
  cursor: pointer;
}

/* ==========================================================================
   TOAST NOTIFICATIONS (Alertas emergentes rápidas)
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  background: var(--bg-toast);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-toast);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
}

.toast-success .toast-icon { background: var(--accent-success); }
.toast-success { border-left: 4px solid var(--accent-success); }

.toast-info .toast-icon { background: var(--accent-secondary); }
.toast-info { border-left: 4px solid var(--accent-secondary); }

.toast-warning .toast-icon { background: var(--accent-warning); }
.toast-warning { border-left: 4px solid var(--accent-warning); }

.toast-error .toast-icon { background: var(--accent-danger); }
.toast-error { border-left: 4px solid var(--accent-danger); }

.toast-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

.toast-message {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ==========================================================================
   UTILIDADES Y ESTADOS VACÍOS
   ========================================================================== */

.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  fill: none;
  margin-bottom: 1rem;
}

.empty-state-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.empty-state-desc {
  font-size: 0.85rem;
  max-width: 300px;
}

/* Animación de fade optimizada sin reflows */
.fade-in {
  animation: fadeIn 0.15s ease-out forwards;
  will-change: opacity;
}

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

/* Ocultar secciones inactivas */
.view-section {
  display: none;
}

.view-section.active-view {
  display: block;
}

/* Responsive sidebar for Tablets */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 80px;
    padding: 1.5rem 0.5rem;
    align-items: center;
  }
  
  .brand-name { display: none; }
  .nav-link { justify-content: center; padding: 0.75rem; }
  .nav-link span { display: none; }
  .theme-toggle-btn span { display: none; }
  .theme-toggle-btn { justify-content: center; padding: 0.75rem; width: 44px; }
  
  .main-content {
    margin-left: 80px;
    width: calc(100% - 80px);
    padding: 1.5rem;
  }
}

/* ============================================================
   STATS DE ASISTENCIA
   ============================================================ */
.asistencia-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-width: 80px;
}
.stat-num {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.stat-num.success-color { color: var(--accent-success); }
.stat-num.danger-color  { color: var(--accent-danger); }
.stat-num.warning-color { color: var(--accent-warning); }

/* Compatibilidad legacy con .acred-stats-grid si existiera */
.acred-stats-grid {
  display: contents;
}

/* ============================================================
   TABS DE ÁREA (Asistencia)
   ============================================================ */
#asistencia-area-tabs .btn.active {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.5);
  color: #a5b4fc;
}
body.light-theme #asistencia-area-tabs .btn.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.4);
  color: var(--accent-primary);
}

/* ============================================================
   ÁREA ROW EN MODAL EVENTOS
   ============================================================ */
.area-row {
  transition: border-color 0.2s ease;
}
.area-row:has(input:checked) {
  border-color: rgba(99,102,241,0.4) !important;
  background: rgba(99,102,241,0.04) !important;
}

/* ============================================================
   BADGES EXTRA
   ============================================================ */
.badge-administrador {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.25);
}
.badge-presente { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-ausente  { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-tarde    { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-invitado { background: rgba(100,116,139,0.15); color: #94a3b8; }

.btn-warning {
  background: linear-gradient(135deg, var(--accent-warning), #d97706);
  color: #fff;
}

/* ============================================================
   SURFACE ALT para formularios anidados
   ============================================================ */
.surface-alt, [style*="background: var(--surface-alt)"] {
  background: rgba(255,255,255,0.02) !important;
}
body.light-theme .surface-alt,
body.light-theme [style*="--surface-alt"] {
  background: rgba(0,0,0,0.02) !important;
}

/* ============================================================
   RESPONSIVE: tabla asistencia
   ============================================================ */
@media (max-width: 640px) {
  .asistencia-control-bar { flex-direction: column; align-items: stretch; }
  .asistencia-stat { min-width: 60px; padding: 0.4rem 0.6rem; }
}

/* ============================================================
   FICHA DE SERVIDOR: SECCIÓN TÍTULO + CHECKBOXES DE ÁREAS
   ============================================================ */
.form-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.areas-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.5rem;
}

.area-checkbox-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.area-checkbox-item:hover {
  background: rgba(255,255,255,0.04);
}

.area-checkbox-item:has(input:checked) {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.4);
}

.area-checkbox-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: #6366f1;
}

.area-chip-label {
  font-size: 0.82rem;
  font-weight: 500;
  padding-left: 0.4rem;
  color: var(--text-primary);
}

.group-select {
  display: none;
  font-size: 0.78rem !important;
  padding: 0.35rem 2rem 0.35rem 0.6rem !important;
  margin-top: 0.25rem;
  width: 100%;
  border-radius: 6px;
  background-position: right 0.6rem center !important;
  background-size: 0.9rem !important;
  height: auto !important;
  line-height: 1.2 !important;
  border: 1px solid var(--border-color);
  background-color: rgba(20, 20, 20, 0.6) !important;
}

body.light-theme .group-select {
  background-color: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .area-checkbox-item:hover {
  background: rgba(0,0,0,0.03);
}
body.light-theme .area-checkbox-item:has(input:checked) {
  background: rgba(99,102,241,0.07);
}

/* ============================================================
   TOGGLE RUT / PASAPORTE
   ============================================================ */
.doc-type-toggle {
  display: flex;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.doc-tab {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.doc-tab.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

body.light-theme .doc-type-toggle {
  background: rgba(0,0,0,0.06);
}

/* ============================================================
   INPUT CON VALIDADOR INLINE (RUT / CÓDIGO)
   ============================================================ */
.input-validated-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-validated-wrapper .form-control {
  flex: 1;
}

.rut-status {
  font-size: 1rem;
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.rut-status.valid   { color: var(--accent-success); }
.rut-status.invalid { color: var(--accent-danger);  }

.field-feedback {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.25rem;
  min-height: 1rem;
}
.field-feedback.success { color: var(--accent-success); }
.field-feedback.error   { color: var(--accent-danger);  }

.input-error {
  border-color: var(--accent-danger) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important;
}

/* ============================================================
   BOTÓN GENERAR CÓDIGO
   ============================================================ */
.btn-gen-code {
  flex-shrink: 0;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(99,102,241,0.1);
  color: #a5b4fc;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-gen-code:hover {
  background: rgba(99,102,241,0.2);
  color: white;
}
body.light-theme .btn-gen-code {
  background: rgba(99,102,241,0.08);
  color: var(--accent-primary);
}

/* ============================================================
   BANNER DE ACTUALIZACIÓN
   ============================================================ */
.update-banner {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.95), rgba(10, 10, 10, 0.98));
  /* backdrop-filter movido a .show por lag */
  border: 1.5px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 99999;
  transform: translateY(150px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  max-width: 420px;
}

.update-banner.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.update-banner-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #8b5cf6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: update-pulse 2s infinite;
}

.update-banner-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes update-pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.update-banner-content {
  flex-grow: 1;
}

.update-banner-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.update-banner-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.update-banner-btn {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: background-color 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

.update-banner-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.45);
  background: linear-gradient(135deg, #9061f9, #4338ca);
}

.update-banner-btn:active {
  transform: translateY(0);
}

.update-banner-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.2s ease, background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.update-banner-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
}

body.light-theme .update-banner-close:hover {
  background: rgba(0, 0, 0, 0.08);
}

body.light-theme .update-banner {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.08), 0 0 20px rgba(99, 102, 241, 0.05);
}

@media (max-width: 480px) {
  .update-banner {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }
}

/* ============================================================
   GOOGLE CALENDAR STYLE GRID
   ============================================================ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background-color: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-day-header {
  background: var(--bg-card);
  padding: clamp(0.35rem, 0.6vw, 0.5rem) 0.25rem;
  text-align: center;
  font-weight: 600;
  font-size: clamp(0.68rem, 0.85vw, 0.85rem);
  color: var(--text-secondary);
  text-transform: uppercase;
  min-width: 0;
}

.calendar-day {
  background: var(--surface);
  min-width: 0;
  min-height: clamp(72px, 11vh, 110px);
  padding: clamp(0.2rem, 0.45vw, 0.35rem);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: background-color 0.2s ease;
}

.calendar-grid-week .calendar-day {
  min-height: clamp(130px, 22vh, 220px);
}

.calendar-day:hover {
  background: var(--bg-card-hover);
}

.calendar-day-empty {
  background: var(--bg-main);
}

.calendar-day-number {
  font-size: clamp(0.74rem, 0.85vw, 0.85rem);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
  padding-left: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.cal-week-day-name {
  display: none;
  text-transform: capitalize;
  color: var(--text-muted);
  font-weight: 700;
}

.calendar-day.today .calendar-day-number {
  background: var(--accent-primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.event-pill {
  font-size: clamp(0.66rem, 0.78vw, 0.76rem);
  line-height: 1.25;
  padding: clamp(0.18rem, 0.35vw, 0.28rem) clamp(0.28rem, 0.5vw, 0.45rem);
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  max-width: 100%;
}

.event-pill:hover {
  opacity: 0.85;
}

.btn-toggle {
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}
.btn-toggle.active {
  background: var(--bg-card-hover) !important;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .calendar-grid-week {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .calendar-grid-week .calendar-day-header {
    display: none;
  }
  .calendar-grid-week .calendar-day {
    min-height: 90px;
    padding: 0.5rem;
  }
  .calendar-grid-week .cal-week-day-name {
    display: inline;
  }
  .calendar-grid-week .calendar-day.today .calendar-day-number {
    width: auto;
    height: auto;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
  }
  .calendar-grid-week .calendar-day.today .cal-week-day-name {
    color: rgba(255, 255, 255, 0.9);
  }
}

/* ==========================================================================
   DISEÑO RESPONSIVO (Mobile-First / Adaptativo)
   ========================================================================== */

.mobile-close-sidebar-btn {
  display: none;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.light-theme .mobile-menu-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  /* Botón Hamburguesa visible y destacado */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }

  /* Ocultar Sidebar y prepararlo para deslizar con scroll interno */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .sidebar-backdrop.show {
    display: block;
    opacity: 1;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    background: var(--bg-app); /* Fondo sólido para que no se mezcle con el contenido */
    width: min(285px, 84vw);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 0.95rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 100;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-close-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: var(--transition-fast);
  }

  .mobile-close-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  body.light-theme .mobile-close-sidebar-btn {
    background: rgba(0, 0, 0, 0.03);
  }

  body.light-theme .mobile-close-sidebar-btn:hover {
    background: rgba(0, 0, 0, 0.06);
  }

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

  .brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-color);
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .nav-menu {
    gap: 0.2rem;
    flex-grow: 0;
    margin-bottom: 0.5rem;
  }

  .nav-link {
    padding: 0.56rem 0.75rem;
    font-size: 0.86rem;
    gap: 0.7rem;
  }

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

  .sidebar-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    gap: 0.55rem;
  }

  /* Panel de Base de Datos compacto en 2 columnas para Admin en móvil */
  .db-tools-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    margin-bottom: 0.15rem;
  }

  .db-tools-label {
    grid-column: 1 / -1;
    font-size: 0.68rem;
    margin-bottom: 0.05rem;
  }

  .db-action-buttons {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }

  .db-tools-panel button {
    padding: 0.42rem 0.5rem !important;
    font-size: 0.75rem !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .theme-toggle-btn {
    padding: 0.62rem 0.85rem;
    font-size: 0.85rem;
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.28);
  }

  body.light-theme .theme-toggle-btn {
    background: rgba(62, 92, 118, 0.08);
    border-color: rgba(62, 92, 118, 0.25);
  }

  /* Main content expandido */
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 0.9rem;
  }

  /* Ajustar top header armónico en celular */
  .top-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
    margin-bottom: 1.15rem;
  }

  .top-header-main {
    width: 100%;
    align-items: center;
    gap: 0.75rem;
  }

  .header-title {
    min-width: 0;
    flex: 1;
  }

  .header-title h1 {
    font-size: 1.35rem;
    line-height: 1.2;
  }

  .header-title p {
    font-size: 0.78rem;
    line-height: 1.35;
    margin-top: 0.15rem;
  }

  .header-actions {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-color);
  }

  /* Fila superior de sesión/utilidades (Rol, Notif, Tema, Guía, Perfil, Salir) */
  .header-actions .header-session-item {
    order: 1;
  }

  .header-actions #user-role-badge {
    font-size: 0.68rem !important;
    padding: 0.28rem 0.55rem !important;
    border-radius: 99px;
    letter-spacing: 0.3px;
    margin-right: auto;
  }

  .header-actions #btn-user-guide,
  .header-actions #btn-mi-perfil,
  .header-actions #btn-logout {
    padding: 0.36rem 0.6rem !important;
    font-size: 0.76rem !important;
  }

  .header-actions #btn-theme-header {
    padding: 0.36rem 0.5rem !important;
  }

  /* Botones dinámicos de vista del Administrador en grilla armónica de 2 columnas */
  .header-actions .dynamic-btn {
    order: 2;
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
    text-align: center;
    padding: 0.46rem 0.6rem !important;
    font-size: 0.78rem !important;
    white-space: nowrap;
  }

  .header-actions .btn-primary.dynamic-btn {
    flex: 1 1 100%;
    order: 3;
    font-weight: 600;
  }

  /* Grillas a 1 columna */
  .metrics-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Modales ocupan casi todo el ancho sin doble padding */
  .modal-container,
  .modal-content {
    width: 95%;
    max-width: none;
    padding: 0;
    max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .modal-header {
    padding: 1rem 1.15rem;
  }

  .modal-body {
    padding: 1rem 1.15rem;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 0.85rem 1.15rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  /* Filtros apilados */
  .filters-bar {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  .search-input-wrapper {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  /* Reducir títulos */
  .header-title h1 {
    font-size: 1.5rem;
  }
  
  /* Ajustar control bar de asistencia */
  .asistencia-control-bar {
    flex-direction: column;
    align-items: stretch !important;
  }
  .asistencia-control-bar .form-group {
    flex-direction: column;
  }
  .asistencia-control-bar button {
    width: 100%;
  }
  .filters-group {
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  #view-servidores .filters-group #btn-alertas-ausentismo {
    flex: 1 1 100%;
    justify-content: center;
    text-align: center;
  }
  #view-servidores .filters-group select {
    flex: 1 1 calc(50% - 0.3rem);
    min-width: 130px;
  }
  .asistencia-filters-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    width: 100%;
  }
  .asistencia-filters-group button {
    flex: 1 1 0;
    width: auto !important;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.4rem;
    font-size: 0.82rem;
  }

  /* Convertir tablas en tarjetas premium en móviles */
  .asistencia-table,
  .asistencia-table thead,
  .asistencia-table tbody,
  .asistencia-table tr,
  .asistencia-table th,
  .asistencia-table td {
    display: block;
    width: 100%;
  }

  .asistencia-table thead {
    display: none;
  }

  .asistencia-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.85rem;
    padding: 0.85rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: var(--transition-smooth);
  }

  body.light-theme .asistencia-table tr {
    background: var(--bg-card);
  }

  .asistencia-table tr:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  /* Cabeceras de acordeón de área en móvil mantienen su diseño limpio */
  .asistencia-table tr[data-area-header],
  .asistencia-table tr[data-acred-area-header] {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.55rem;
  }

  .asistencia-table tr[data-area-header] td,
  .asistencia-table tr[data-acred-area-header] td {
    display: block;
    border-bottom: none;
    padding: 0.5rem 0.4rem !important;
    margin-bottom: 0;
    min-height: auto;
  }

  /* El primer td (Nombre y Área) actúa como la cabecera de la tarjeta */
  .asistencia-table tr:not([data-area-header]):not([data-acred-area-header]) td:first-child,
  .asistencia-table td[data-label="Servidor"],
  .asistencia-table td[data-label="Servidor / Área"] {
    display: block;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.4rem;
    min-height: auto;
  }

  .asistencia-table td:first-child::before,
  .asistencia-table td[data-label="Servidor"]::before,
  .asistencia-table td[data-label="Servidor / Área"]::before {
    display: none; /* Oculta la etiqueta repetitiva */
  }

  .asistencia-table tr:not([data-area-header]):not([data-acred-area-header]) td:first-child strong,
  .asistencia-table td[data-label="Servidor"] strong,
  .asistencia-table td[data-label="Servidor / Área"] strong {
    font-size: 1.15rem;
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.2rem;
  }

  /* Resto de las celdas alineadas con etiquetas */
  .asistencia-table td {
    border: none;
    border-bottom: 1px dashed rgba(116, 140, 171, 0.1);
    padding: 0.5rem 0;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.5rem;
  }

  body.light-theme .asistencia-table td {
    border-bottom: 1px dashed rgba(0, 0, 0, 0.05);
  }

  .asistencia-table td:last-child {
    border-bottom: none;
  }

  .asistencia-table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    text-align: left;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
  }

  /* Alineación de controles e inputs a la derecha */
  .asistencia-table td > * {
    text-align: right;
    justify-content: flex-end;
  }

  /* Ajustar los botones de estado de asistencia en móvil */
  .asistencia-table td[data-label="Estado de Asistencia"] {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: auto;
    padding: 1rem 0;
  }

  .asistencia-table td[data-label="Estado de Asistencia"]::before {
    margin-bottom: 0.25rem;
  }

  .asistencia-table td[data-label="Estado de Asistencia"] > div {
    width: 100%;
    display: flex;
    justify-content: flex-start; /* Alinea los botones a la izquierda para mejor alcance */
    gap: 0.75rem;
  }

  .asistencia-table td[data-label="Estado de Asistencia"] button {
    flex: 1; /* Hace que los botones ocupen el mismo ancho */
    padding: 0.6rem !important;
    font-size: 1rem !important;
    max-width: 80px;
  }

  /* Ajustar checkboxes de Acreditación y Colación en móvil */
  .asistencia-table td[data-label="Acreditación"],
  .asistencia-table td[data-label="Colación"],
  .asistencia-table td[data-label="Devolución"] {
    min-height: auto;
  }

  .asistencia-table td[data-label="Acreditación"] label,
  .asistencia-table td[data-label="Colación"] label,
  .asistencia-table td[data-label="Devolución"] label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    justify-content: flex-end;
  }

  .asistencia-table td[data-label="Acreditación"] input[type="checkbox"],
  .asistencia-table td[data-label="Colación"] input[type="checkbox"],
  .asistencia-table td[data-label="Devolución"] input[type="checkbox"] {
    transform: scale(1.5) !important; /* Checkboxes más grandes para pantallas táctiles */
    margin-right: 0.5rem;
  }

  .asistencia-state-btns {
    justify-content: flex-end;
  }

  .asistencia-table td strong {
    font-size: 0.95rem;
  }
}

@media (max-width: 600px) {
  .calendar-day {
    min-height: 62px;
  }
  .calendar-day-number {
    font-size: 0.7rem;
  }
  .event-pill {
    font-size: 0.62rem;
    line-height: 1.2;
    padding: 0.14rem 0.22rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem;
  }
  .card {
    padding: 1rem;
  }
  .header-title h1 {
    font-size: 1.35rem;
  }
  .header-title p {
    font-size: 0.8rem;
  }
}

/* Sobrecargas personalizadas para el tema claro con la paleta profesional */
body.light-theme .brand-logo {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  box-shadow: 0 4px 15px rgba(62, 92, 118, 0.2);
}

body.light-theme .btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #1d2d44);
  box-shadow: 0 4px 15px rgba(62, 92, 118, 0.2);
}
body.light-theme .btn-primary:hover {
  box-shadow: 0 6px 20px rgba(62, 92, 118, 0.35);
}

body.light-theme .btn-accent {
  background: linear-gradient(135deg, var(--accent-secondary), #3e5c76);
  box-shadow: 0 4px 15px rgba(116, 140, 171, 0.2);
}
body.light-theme .btn-accent:hover {
  box-shadow: 0 6px 20px rgba(116, 140, 171, 0.35);
}

body.light-theme .form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(62, 92, 118, 0.15);
}

body.light-theme .card:hover {
  border-color: rgba(116, 140, 171, 0.3);
}

@media print { 
  .sidebar, .topbar, #btn-export-acreditacion { display: none !important; } 
  .main-content { margin-left: 0 !important; padding: 0 !important; } 
  .card { box-shadow: none !important; border: 1px solid #ddd; } 
}

/* Evitar transiciones lentas y lag durante el cambio de tema */
body.theme-toggling,
body.theme-toggling * {
  transition: none !important;
}

/* Acordeón para observaciones de asistencia */
.justificacion-detalle-collapse {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out, background-color 0.2s ease-out;
  background: rgba(255, 255, 255, 0.03);
}
body.light-theme .justificacion-detalle-collapse {
  background: rgba(0, 0, 0, 0.03);
}

/* Ficha de Servidor compacta para pantallas medianas/pequeñas */
#form-servidor .form-group {
  margin-bottom: 0.75rem;
  gap: 0.3rem;
}
#form-servidor .form-control {
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}
#form-servidor .form-section-title {
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
}
#form-servidor .form-label {
  font-size: 0.8rem;
}
#form-servidor .areas-checkbox-grid {
  gap: 0.5rem;
  margin-bottom: 1rem;
}
#modal-servidor-backdrop .modal-container {
  max-width: 680px;
  width: 95%;
}

/* ============================================================
   ACORDEÓN: Historial de Asistencia (Ficha de Servidor / Perfil)
   ============================================================ */
.srv-accordion {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  margin-top: 1.25rem;
  transition: var(--transition-smooth);
}

body.light-theme .srv-accordion {
  background: #ffffff;
  border-color: rgba(116, 140, 171, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.srv-accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: rgba(255, 255, 255, 0.02);
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  text-align: left;
  transition: var(--transition-fast);
  user-select: none;
}

body.light-theme .srv-accordion-header {
  background: #f8fafc;
}

.srv-accordion-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

body.light-theme .srv-accordion-header:hover {
  background: #f1f5f9;
}

.srv-accordion-header.active {
  border-bottom: 1px solid var(--border-color);
}

body.light-theme .srv-accordion-header.active {
  border-bottom-color: rgba(116, 140, 171, 0.2);
}

.srv-accordion-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  flex-wrap: wrap;
}

.srv-accordion-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.srv-accordion-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.srv-accordion-header.active .srv-accordion-chevron {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.srv-accordion-body {
  background: var(--bg-card);
}

body.light-theme .srv-accordion-body {
  background: #ffffff;
}

/* ============================================================
   DASHBOARD OBSERVADOR - KPI Cards compactas + tabla compacta
   ============================================================ */
.obs-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.obs-kpi-val {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}
.obs-kpi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tabla compacta del observador */
.obs-table th,
.obs-table td {
  padding: 0.45rem 0.5rem !important;
  font-size: 0.8rem !important;
}
.obs-table th {
  white-space: nowrap;
}
.obs-table td:first-child {
  min-width: 160px;
}
/* Columnas de eventos: compactas y centradas */
.obs-table td[style*="text-align:center"],
.obs-table th[style*="text-align:center"] {
  min-width: 60px;
  max-width: 90px;
}

/* Mobile: colapsar stats+chart en columna unica y adaptar tabla de reportes */
@media (max-width: 640px) {
  #view-observador .obs-layout-grid {
    grid-template-columns: 1fr !important;
  }
  #view-observador .obs-pie-col {
    width: 100% !important;
  }
  .hide-on-mobile {
    display: none !important;
  }
  /* Adaptaciones móviles para la tabla y controles de Reportes */
  .obs-period-buttons {
    width: 100% !important;
    display: flex !important;
  }
  .obs-period-buttons .btn {
    flex: 1 1 0 !important;
    text-align: center !important;
    padding: 0.4rem 0.3rem !important;
    font-size: 0.74rem !important;
    white-space: nowrap !important;
  }
  .obs-table-tools {
    width: 100% !important;
  }
  .obs-table-tools #obs-search {
    width: 100% !important;
    min-width: 100% !important;
  }
  .obs-table-tools-sub {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  .obs-table th:first-child,
  .obs-table td:first-child {
    min-width: 125px !important;
    max-width: 140px !important;
    white-space: normal !important;
    padding: 0.4rem 0.35rem !important;
  }
  .obs-table .srv-name-container {
    max-width: 95px !important;
    overflow: hidden !important;
  }
  .obs-table .srv-name-text {
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.78rem !important;
    line-height: 1.15 !important;
  }
  .obs-table td[style*="text-align:center"],
  .obs-table th[style*="text-align:center"] {
    min-width: 48px !important;
    max-width: 65px !important;
    padding: 0.35rem 0.2rem !important;
    font-size: 0.75rem !important;
  }
}

/* Sticky First Column para Observer Table */
.obs-table th:first-child,
.obs-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--bg-card);
  box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}
.obs-table thead th:first-child {
  z-index: 3;
}

/* Optimización de Espacios para Laptops y Computadores (Zoom 100%) */
@media (min-width: 769px) and (max-width: 1440px) {
  .sidebar {
    width: 240px;
    padding: 1.25rem 0.75rem;
  }
  .brand {
    margin-bottom: 1.25rem;
    gap: 0.5rem;
  }
  .brand-logo {
    width: 32px;
    height: 32px;
  }
  .brand-name {
    font-size: 1.1rem;
  }
  .nav-menu {
    gap: 0.25rem;
  }
  .nav-link {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
  }
  .sidebar-footer {
    gap: 0.4rem;
    padding-top: 1rem;
  }
  .sidebar-footer button {
    padding: 0.45rem !important;
    font-size: 0.8rem !important;
  }
  .main-content {
    margin-left: 240px;
    width: calc(100% - 240px);
    padding: 1.5rem;
  }
  .top-header {
    margin-bottom: 1.5rem;
  }
  .header-title h1 {
    font-size: 1.6rem;
  }
  .header-title p {
    font-size: 0.85rem;
  }
  .card {
    padding: 1.15rem;
  }
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  .metric-card {
    gap: 0.85rem;
  }
  .metric-icon {
    width: 44px;
    height: 44px;
  }
  .metric-icon svg {
    width: 20px;
    height: 20px;
  }
  .metric-value {
    font-size: 1.35rem;
  }
  .metric-label {
    font-size: 0.78rem;
  }
  .dashboard-grid {
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
}

@media (max-width: 1250px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .card[style*="grid-column: 1 / -1;"] {
    grid-column: span 1;
  }
}

/* ============================================================
   ESTILOS PARA PANEL DE SERVIDOR (VOLUNTARIOS)
   ============================================================ */

/* Contenedor de pestañas */
.srv-tabs-bar {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  margin-bottom: 1.25rem;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.srv-tabs-bar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Pestaña individual */
.srv-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.srv-tab:hover {
  background: rgba(116, 140, 171, 0.08);
  color: var(--text-primary);
}
.srv-tab.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Contenedor de panel */
.srv-panel {
  display: none;
  animation: srvFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.srv-panel.active {
  display: block;
}
@keyframes srvFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Credencial Digital */
.srv-credencial-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  margin: 1.5rem auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
.srv-credencial-header {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
  padding: 1.25rem;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}
.srv-credencial-header #srv-qr-nombre {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.srv-credencial-header #srv-qr-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.srv-qr-wrapper {
  padding: 2rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
}
.srv-qr-img {
  width: 240px;
  height: 240px;
  padding: 0.5rem;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}
.srv-qr-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1rem;
  font-weight: 500;
}
.srv-credencial-info {
  border-top: 1px dashed var(--border-color);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(116, 140, 171, 0.02);
}
.srv-credencial-info > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}
.srv-info-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.srv-credencial-info span:not(.srv-info-label) {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

/* Convocatorias List */
.srv-convocatoria-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.srv-convocatoria-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.srv-conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.srv-conv-area {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
}
.srv-conv-titulo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.srv-conv-fecha, .srv-conv-jornada {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Equipo de servicio */
.srv-team-block {
  background: rgba(116, 140, 171, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.srv-team-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.srv-team-role {
  font-weight: 700;
  color: var(--text-muted);
  min-width: 125px;
}
.srv-team-name {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}
.srv-wa-btn {
  background: #25d366;
  color: white !important;
  text-decoration: none !important;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(37, 211, 102, 0.25);
}
.srv-wa-btn:hover {
  transform: scale(1.15);
}


.srv-btn-gcal {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
}
.srv-btn-gcal:hover {
  background: rgba(116, 140, 171, 0.06);
  border-color: var(--text-muted);
}

/* Badges de Confirmación */
.srv-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}
.srv-badge-success { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); border: 1px solid rgba(16, 185, 129, 0.15); }
.srv-badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--accent-warning); border: 1px solid rgba(245, 158, 11, 0.15); }
.srv-badge-danger  { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); border: 1px solid rgba(239, 68, 68, 0.15); }
.srv-badge-muted   { background: rgba(116, 140, 171, 0.1); color: var(--text-muted); border: 1px solid rgba(116, 140, 171, 0.15); }

/* KPIs Historial */
.srv-historial-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.srv-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.srv-kpi span {
  font-size: 1.15rem;
  font-weight: 700;
}
.srv-kpi small {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.15rem;
}
.srv-kpi-success span { color: var(--accent-success); }
.srv-kpi-warning span { color: var(--accent-warning); }
.srv-kpi-danger span  { color: var(--accent-danger); }
.srv-kpi-muted span   { color: var(--text-muted); }

/* Items del Historial */
.srv-hist-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.srv-hist-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.srv-hist-right {
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Acreditador: Selector de modo de escaneo */
#acred-scan-mode {
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 600;
  color: var(--accent-primary);
  background-color: rgba(99, 102, 241, 0.03);
  transition: all 0.2s;
}
#acred-scan-mode:focus {
  border-color: var(--accent-primary);
  background-color: var(--bg-card);
}

/* Rediseño Sobrio de Áreas (Reportes) */
.chip-area {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  letter-spacing: 0.2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.area-row-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  width: 100%;
}
.area-row-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}
.area-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.area-row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}
.area-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.area-badge-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-card);
  padding: 0.1rem 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}
.area-progress-bg {
  width: 100%;
  height: 5px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 3px;
  overflow: hidden;
}
.area-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ============================================================ */
/* OPTIMIZACIÓN RESPONSIVE CELULAR / MÓVIL (Sub-fase 4.5 & 4.3) */
/* ============================================================ */

/* Alerta de no convocados para Coordinador en Calendario */
.cal-alerta-sin-convocar {
  margin-top: 0.45rem;
  padding: clamp(0.45rem, 0.85vw, 0.6rem) clamp(0.65rem, 1.1vw, 0.85rem);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(245, 158, 11, 0.08));
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-left: 4px solid #ef4444;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.08);
}

.cal-alerta-sin-convocar-text {
  font-size: clamp(0.76rem, 0.84vw, 0.83rem);
  color: #b91c1c;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 220px;
  line-height: 1.35;
}

.cal-alerta-sin-convocar-btn {
  font-size: clamp(0.74rem, 0.8vw, 0.78rem) !important;
  padding: 0.32rem 0.7rem !important;
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25) !important;
  border-radius: 6px !important;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background-color 0.15s;
}

.cal-alerta-sin-convocar-btn:hover {
  background: #b91c1c !important;
  transform: translateY(-1px);
}

/* Chips de Compañeros de Servicio en Portal Servidor */
.srv-companero-chip {
  display: inline-flex;
  align-items: center;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 6px;
  padding: 0.22rem 0.5rem;
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.15rem;
  max-width: 100%;
  word-break: break-word;
  transition: background-color 0.15s;
}

.srv-companero-chip:hover {
  background: rgba(99, 102, 241, 0.14);
}

.srv-team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}

/* Selector de Área en Escaneo QR de Acreditación (Móvil & Escritorio) */
.acred-scan-areas-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
  background: rgba(var(--accent-primary-rgb), 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.acred-scan-areas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.1rem;
}

.acred-scan-areas-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
}

.acred-scan-multi-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(var(--accent-primary-rgb), 0.16);
  color: var(--accent-primary);
}

.acred-scan-area-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  text-align: left;
}

.acred-scan-area-option:hover {
  background: var(--bg-card-hover);
  border-color: rgba(var(--accent-primary-rgb), 0.4);
}

.acred-scan-area-option.selected {
  border-color: var(--accent-primary);
  background: rgba(var(--accent-primary-rgb), 0.12);
  box-shadow: 0 0 0 1px rgba(var(--accent-primary-rgb), 0.25);
}

.acred-scan-area-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.acred-scan-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.acred-scan-area-option.selected .acred-scan-radio {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
}

.acred-scan-area-option.selected .acred-scan-radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
}

.acred-scan-area-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.acred-scan-area-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.acred-scan-area-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  word-break: break-word;
}

.acred-scan-area-sub {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.08rem;
}

.acred-area-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.48rem;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.acred-area-pill.pill-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.acred-area-pill.pill-accredited {
  background: rgba(99, 102, 241, 0.16);
  color: #818cf8;
}

.acred-area-pill.pill-returned {
  background: rgba(16, 185, 129, 0.16);
  color: #10b981;
}

.acred-area-pill.pill-extra {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-secondary);
}

.acred-area-pill.pill-multi {
  background: rgba(var(--accent-primary-rgb), 0.16);
  color: var(--accent-primary);
}

.acred-other-area-toggle {
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.42rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
  width: 100%;
  margin-top: 0.1rem;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.acred-other-area-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: rgba(var(--accent-primary-rgb), 0.06);
}

/* Adaptación fluida para celulares (iPhone, Android, pantallas < 640px) */
@media (max-width: 640px) {
  /* Alerta Coordinador en móvil */
  .cal-alerta-sin-convocar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.65rem 0.75rem;
    gap: 0.55rem;
  }

  .cal-alerta-sin-convocar-text {
    font-size: 0.8rem;
    flex: unset;
  }

  .cal-alerta-sin-convocar-btn {
    width: 100% !important;
    padding: 0.5rem 0.8rem !important;
    font-size: 0.82rem !important;
    text-align: center;
    border-radius: 6px;
  }

  .evento-card .card-header {
    padding: 0.85rem 0.95rem !important;
  }

  /* Portal del Servidor en móvil */
  .srv-convocatoria-card {
    padding: 1rem 0.85rem !important;
    margin-bottom: 0.85rem !important;
  }

  .srv-team-block {
    padding: 0.6rem 0.7rem !important;
    gap: 0.5rem !important;
  }

  .srv-team-row {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }

  .srv-team-row.srv-team-row-col {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .srv-team-row.srv-team-row-col .srv-team-role {
    min-width: unset !important;
    font-size: 0.75rem !important;
    margin-bottom: 0.15rem;
    color: var(--accent-primary);
  }

  .srv-team-row.srv-team-row-col .srv-team-name {
    width: 100% !important;
  }

  .srv-team-role {
    min-width: 105px;
    font-size: 0.76rem;
  }

  .srv-team-name {
    font-size: 0.78rem;
  }

  .srv-wa-btn {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.75rem !important;
  }

  .srv-companero-chip {
    font-size: 0.76rem;
    padding: 0.25rem 0.55rem;
  }

  /* Barra de herramientas de Acreditación adaptable en móvil */
  .acred-controls-toolbar {
    flex-wrap: wrap !important;
    max-width: 100% !important;
  }

  .acred-controls-toolbar #acred-search {
    flex: 1 1 calc(100% - 58px) !important;
    min-width: 160px !important;
  }

  .acred-controls-toolbar #filter-area-acreditacion {
    flex: 1 1 100% !important;
    max-width: none !important;
    min-width: 130px !important;
  }

  /* Controles superiores de Acreditación en móvil */
  .acred-top-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }

  .acred-top-select-wrap {
    width: 100% !important;
  }

  .acred-top-select-wrap #select-evento-acreditacion {
    max-width: none !important;
    width: 100% !important;
  }

  .acred-top-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem !important;
  }

  .acred-top-actions button {
    justify-content: center !important;
    text-align: center !important;
    width: 100%;
    padding: 0.5rem 0.6rem !important;
    font-size: 0.8rem !important;
  }

  .acred-top-actions #btn-export-acreditacion {
    grid-column: 1 / -1;
  }

  /* Tarjetas de Servidores en móvil: nombre completo + fila horizontal de botones */
  .servidor-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.6rem !important;
  }

  .servidor-header {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.4rem;
  }

  .servidor-name {
    white-space: normal;
    word-break: break-word;
  }

  .servidor-actions {
    flex-direction: row !important;
    width: 100%;
    gap: 0.45rem !important;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-color);
  }

  .servidor-actions .btn {
    flex: 1 1 0;
    justify-content: center;
    text-align: center;
    padding: 0.42rem 0.5rem !important;
    font-size: 0.78rem !important;
  }
}

/* Grillas de 2 columnas en formularios de modales pasan a 1 columna en pantallas pequeñas */
@media (max-width: 540px) {
  .modal-body div[style*="grid-template-columns: 1fr 1fr"],
  .modal-body div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }
}

/* Ergonomía táctil y modo App Instalada (PWA Standalone) */
.btn,
.nav-link,
.srv-tab,
.doc-tab,
.btn-toggle,
.modal-close-btn,
.mobile-menu-btn,
.mobile-close-sidebar-btn,
.theme-toggle-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (display-mode: standalone) {
  .main-content {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .modal-backdrop {
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  }

  .toast-container {
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }
}



