/* =========================================================
   CampusVirtual Praxis – Estilos integrados
   Versión 2.0 · Moodle moderno + Panel de Conexiones
   ========================================================= */

/* ---- Reset y base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta principal Praxis */
  --primary:       #1b3b72;
  --primary-mid:   #254d96;
  --primary-light: #3a64b8;
  --primary-pale:  #dce8f8;
  --primary-xpale: #f0f5ff;

  /* Acento */
  --accent:        #e63946;

  /* Semánticos */
  --green:         #16a34a;
  --green-pale:    #dcfce7;
  --red:           #dc2626;
  --red-pale:      #fee2e2;
  --orange:        #ea580c;
  --orange-pale:   #ffedd5;
  --purple:        #9333ea;
  --purple-pale:   #f3e8ff;
  --cyan:          #0891b2;
  --cyan-pale:     #cffafe;

  /* Neutros */
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-300:      #d1d5db;
  --gray-400:      #9ca3af;
  --gray-500:      #6b7280;
  --gray-600:      #4b5563;
  --gray-700:      #374151;
  --gray-800:      #1f2937;
  --gray-900:      #111827;
  --white:         #ffffff;

  /* Layout */
  --topbar-h:      64px;
  --sidebar-w:     260px;
  --font:          'Inter', sans-serif;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --transition:    .2s ease;
}

html, body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
ul { list-style: none; }
.hidden { display: none !important; }
.mt-20 { margin-top: 20px; }

/* =========================================================
   SCROLLBAR
   ========================================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* =========================================================
   TOPBAR
   ========================================================= */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 16px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.sidebar-toggle {
  width: 36px; height: 36px;
  background: none; border: none;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--gray-100); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 0.95rem;
}
.brand-text {
  display: flex; flex-direction: column;
  line-height: 1.2;
}
.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  letter-spacing: -.3px;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--gray-400);
}

.topbar-center { flex: 1; max-width: 480px; margin: 0 24px; }

.search-global {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 50px;
  padding: 7px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-global:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-pale);
  background: var(--white);
}
.search-global i { color: var(--gray-400); font-size: 0.8rem; }
.search-global input {
  flex: 1; border: none; outline: none;
  background: transparent;
  font-family: var(--font); font-size: 0.82rem;
  color: var(--gray-700);
}
.search-global kbd {
  font-size: 0.65rem; color: var(--gray-400);
  border: 1px solid var(--gray-200);
  border-radius: 4px; padding: 1px 5px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  width: 36px; height: 36px;
  background: none; border: none;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  position: relative;
  transition: background var(--transition);
}
.topbar-btn:hover { background: var(--gray-100); color: var(--primary); }

.badge-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 1.5px solid var(--white);
}

.topbar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-weight: 700; font-size: 0.78rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(27,59,114,.35);
  margin-left: 4px;
  transition: transform var(--transition);
}
.topbar-avatar:hover { transform: scale(1.06); }

/* =========================================================
   APP SHELL
   ========================================================= */
.app-shell {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 900;
  transition: transform .25s ease;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.profile-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-weight: 700; font-size: 0.8rem;
  flex-shrink: 0;
}
.profile-name {
  display: block;
  font-weight: 600; font-size: 0.85rem;
  color: var(--gray-800);
}
.profile-role {
  display: block;
  font-size: 0.7rem;
  color: var(--primary-light);
}
.profile-role i { margin-right: 3px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.85rem; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-item:hover { background: var(--primary-pale); color: var(--primary); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  box-shadow: 0 3px 10px rgba(27,59,114,.35);
}

.nav-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); color: var(--white); }
.nav-badge.new { background: var(--accent); color: var(--white); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--gray-100);
}
.sidebar-bbdd { }
.bbdd-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.bbdd-title i { margin-right: 4px; color: var(--primary-light); }
.bbdd-items { display: flex; flex-wrap: wrap; gap: 4px; }
.bbdd-chip {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--gray-100);
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
}
.bbdd-chip.active {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}
.bbdd-chip i { font-size: 0.45rem; margin-right: 3px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 850;
}

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 28px 60px;
  min-width: 0;
}

/* Views */
.view { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.view-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.4px;
}
.view-title i { color: var(--primary); margin-right: 8px; }
.view-subtitle {
  font-size: 0.84rem;
  color: var(--gray-500);
  margin-top: 3px;
}
.view-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* =========================================================
   HERO BANNER
   ========================================================= */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 55%, #3a64b8 100%);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}
.hero-banner::before {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.hero-banner::after {
  content: '';
  position: absolute;
  right: 80px; bottom: -100px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.hero-text { position: relative; z-index: 1; }
.hero-greeting { font-size: 0.9rem; opacity: .8; margin-bottom: 6px; }
.hero-title { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; margin-bottom: 8px; }
.hero-sub { font-size: 0.85rem; opacity: .75; margin-bottom: 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.hero-stats {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.hero-stat {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  padding: 14px 20px;
  min-width: 80px;
  backdrop-filter: blur(4px);
}
.hero-stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.hero-stat-label {
  font-size: 0.68rem;
  opacity: .75;
  text-align: center;
  line-height: 1.3;
}

/* =========================================================
   BOTONES
   ========================================================= */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border: none;
  padding: 9px 18px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(27,59,114,.3);
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(27,59,114,.4); }
.btn-primary:active { transform: none; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.3);
  padding: 9px 18px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-ghost:hover { background: rgba(255,255,255,.25); }

.btn-ghost.dark {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-ghost.dark:hover { background: var(--gray-200); }

.btn-link {
  background: none; border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 5px;
  padding: 4px 0;
  transition: color var(--transition);
}
.btn-link:hover { color: var(--primary-light); }

/* =========================================================
   STAT CARDS
   ========================================================= */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.stat-card.orange .stat-icon { background: var(--orange-pale); color: var(--orange); }
.stat-card.blue   .stat-icon { background: var(--primary-pale); color: var(--primary); }
.stat-card.green  .stat-icon { background: var(--green-pale); color: var(--green); }
.stat-card.purple .stat-icon { background: var(--purple-pale); color: var(--purple); }
.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}
.stat-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; }

/* =========================================================
   DASHBOARD GRID
   ========================================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* =========================================================
   CARD SECTION
   ========================================================= */
.card-section {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-section.compact { padding: 16px 18px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gray-800);
  display: flex; align-items: center; gap: 7px;
}
.section-title i { color: var(--primary); }

/* =========================================================
   CURSOS GRID
   ========================================================= */
.cursos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.cursos-grid.full {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.curso-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  background: var(--white);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.curso-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.curso-card-top {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: rgba(255,255,255,.9);
  position: relative;
}
.curso-card-shortname {
  position: absolute;
  top: 8px; right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0,0,0,.2);
  color: var(--white);
  padding: 2px 7px;
  border-radius: 10px;
}
.curso-card-body { padding: 12px; }
.curso-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
  line-height: 1.3;
}
.curso-card-cat {
  font-size: 0.7rem;
  color: var(--gray-400);
  margin-bottom: 10px;
}
.progress-bar-wrap {
  background: var(--gray-100);
  border-radius: 50px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar {
  height: 100%;
  border-radius: 50px;
  width: 0%;
  transition: width 1s ease;
}
.progress-label {
  font-size: 0.68rem;
  color: var(--gray-400);
  display: flex;
  justify-content: space-between;
}
.curso-card-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-continuar {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--white);
  border: none;
  padding: 5px 12px;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  transition: opacity var(--transition);
}
.btn-continuar:hover { opacity: .85; }

/* Skeleton */
.skeleton-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-100);
  height: 160px;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; }
  50% { opacity:.5; }
}

/* =========================================================
   WIDGET CONEXIONES
   ========================================================= */
.widget-card {
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.widget-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.widget-conexiones {
  background: linear-gradient(135deg, var(--primary) 0%, #2c57a8 100%);
  color: var(--white);
}
.widget-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.widget-body { flex: 1; }
.widget-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 2px; }
.widget-sub { font-size: 0.73rem; opacity: .8; }
.widget-arrow { font-size: 0.8rem; opacity: .7; }

/* =========================================================
   SIDE PANEL
   ========================================================= */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Actividad */
.activity-list { display: flex; flex-direction: column; gap: 12px; }
.activity-item { display: flex; gap: 10px; align-items: flex-start; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.activity-dot.blue { background: var(--primary); }
.activity-dot.green { background: var(--green); }
.activity-dot.orange { background: var(--orange); }
.activity-dot.purple { background: var(--purple); }
.activity-dot.red { background: var(--red); }
.activity-body { flex: 1; }
.activity-text { font-size: 0.78rem; color: var(--gray-700); display: block; line-height: 1.4; }
.activity-time { font-size: 0.68rem; color: var(--gray-400); display: block; margin-top: 2px; }

/* Mini calendario */
.cal-nav {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
}
.cal-nav button {
  width: 22px; height: 22px;
  background: none; border: 1px solid var(--gray-200);
  border-radius: 4px;
  color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem;
  transition: background var(--transition);
}
.cal-nav button:hover { background: var(--gray-100); }

.mini-cal {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 2px;
  text-align: center;
}
.cal-day-name {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--gray-400);
  padding: 2px 0 4px;
}
.cal-day {
  font-size: 0.72rem;
  color: var(--gray-600);
  padding: 4px 2px;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-day:hover { background: var(--gray-100); }
.cal-day.today {
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}
.cal-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
}
.cal-day.other-month { color: var(--gray-300); }

/* =========================================================
   FOROS GRID
   ========================================================= */
.foros-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.foro-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  transition: box-shadow var(--transition);
}
.foro-card:hover { box-shadow: var(--shadow-sm); }
.foro-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-weight: 700; font-size: 0.75rem;
  flex-shrink: 0;
}
.foro-body { flex: 1; min-width: 0; }
.foro-course { font-size: 0.65rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .3px; }
.foro-title {
  font-size: 0.78rem; font-weight: 500; color: var(--gray-700);
  margin: 4px 0 6px;
  line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.foro-meta { font-size: 0.65rem; color: var(--gray-400); }
.foro-meta i { margin-right: 3px; }
.foro-meta i:nth-child(2) { margin-left: 8px; }

/* =========================================================
   PLACEHOLDER VIEW
   ========================================================= */
.placeholder-view {
  text-align: center;
  padding: 80px 20px;
  color: var(--gray-400);
}
.placeholder-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: block;
}
.placeholder-view h2 { font-size: 1.2rem; color: var(--gray-600); margin-bottom: 8px; }
.placeholder-view p { font-size: 0.85rem; }

/* =========================================================
   PANEL DE CONEXIONES
   ========================================================= */
.conexiones-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 20px;
  align-items: start;
}

/* Sidebar de cursos del panel de conexiones */
.conn-sidebar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
}
.conn-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.conn-sidebar-title { font-weight: 700; font-size: 0.88rem; }
.conn-badge-num {
  background: var(--primary);
  color: var(--white);
  font-size: 0.65rem; font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.conn-search {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.conn-search i { color: var(--gray-400); font-size: 0.75rem; }
.conn-search input {
  border: none; outline: none;
  font-family: var(--font); font-size: 0.79rem;
  color: var(--gray-700); width: 100%;
  background: transparent;
}
.conn-curso-list { padding: 6px 0; }
.conn-curso-list li {
  cursor: pointer;
  padding: 9px 14px;
  transition: background var(--transition);
}
.conn-curso-list li:hover { background: var(--primary-pale); }
.conn-curso-list li.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-mid));
  color: var(--white);
}
.cc-nombre { display: block; font-weight: 500; font-size: 0.8rem; }
.cc-short { display: block; font-size: 0.68rem; color: var(--gray-400); margin-top: 1px; }
.conn-curso-list li.active .cc-short { color: rgba(255,255,255,.65); }
.cc-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-api-info {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--gray-100);
}
.api-title { font-size: 0.68rem; font-weight: 600; color: var(--gray-500); margin-bottom: 6px; }
.api-title i { margin-right: 4px; color: var(--primary-light); }
.api-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.api-chip {
  font-size: 0.62rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--green-pale);
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* Panel principal conexiones */
.conn-main { display: flex; flex-direction: column; gap: 16px; }

.conn-controls {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.conn-ctrl-group { display: flex; flex-direction: column; gap: 4px; }
.ctrl-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-600);
  display: flex; align-items: center; gap: 5px;
}
.ctrl-input {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--gray-700);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 140px;
}
.ctrl-input[type="time"] { min-width: 110px; }
.ctrl-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

/* KPIs conexiones */
.conn-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.conn-kpi {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.conn-kpi:hover { transform: translateY(-2px); }
.conn-kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.conn-kpi-body { flex: 1; min-width: 0; }
.conn-kpi-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conn-kpi-value.kpi-green { color: var(--green); }
.conn-kpi-value.kpi-red   { color: var(--red); }
.conn-kpi-label { font-size: 0.68rem; color: var(--gray-400); margin-top: 2px; }

/* Tabla conexiones */
.conn-table-wrapper {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
  min-height: 180px;
}

.conn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.79rem;
}
.conn-table thead tr {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-mid) 100%);
}
.conn-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  font-size: 0.75rem;
  letter-spacing: .2px;
}
.conn-table thead th:first-child { border-radius: 0; }
.th-green { color: #86efac; }
.th-red   { color: #fca5a5; }

.conn-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
.conn-table tbody tr:last-child { border-bottom: none; }
.conn-table tbody tr:hover { background: var(--primary-xpale); }
.conn-table tbody td { padding: 10px 14px; vertical-align: middle; }

.alumno-cell { display: flex; align-items: center; gap: 8px; }
.alumno-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alumno-name { font-weight: 500; color: var(--gray-800); }

.email-cell { color: var(--gray-500); font-size: 0.74rem; }
.total-cell { font-weight: 700; color: var(--gray-700); }
.connected-cell { color: var(--green); font-weight: 600; }
.absent-cell    { color: var(--red); font-weight: 600; }

.tramo-pill {
  display: inline-block;
  background: var(--primary-pale);
  color: var(--primary);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-weight: 600;
  margin: 1px 2px;
  white-space: nowrap;
}
.tramo-pill.ausente {
  background: var(--red-pale);
  color: var(--red);
}
.tramo-pill.no-data {
  background: var(--gray-100);
  color: var(--gray-400);
}

.conn-table tfoot tr {
  background: var(--gray-50);
  border-top: 2px solid var(--gray-200);
}
.conn-table tfoot td {
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.79rem;
  color: var(--gray-700);
}

.conn-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--gray-400);
  gap: 12px;
}
.conn-empty-icon { font-size: 2.5rem; }
.conn-empty p { font-size: 0.84rem; text-align: center; }

.conn-loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--gray-600);
}

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.conn-footnote {
  background: var(--primary-pale);
  border: 1px solid #bcd1f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.conn-footnote.hidden { display: none; }
.conn-footnote i { font-size: 0.9rem; }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--orange); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .conn-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: none;
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; padding: 20px 16px 60px; }
  .topbar-center { display: none; }
  .hero-stats { display: none; }
  .cursos-grid { grid-template-columns: repeat(2, 1fr); }
  .foros-grid { grid-template-columns: 1fr; }
  .conexiones-layout { grid-template-columns: 1fr; }
  .conn-sidebar { position: static; }
  .conn-controls { gap: 10px; }
}

@media (max-width: 600px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .cursos-grid { grid-template-columns: 1fr; }
  .conn-kpis { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 1.3rem; }
  .hero-banner { padding: 24px 20px; }
  .side-panel { grid-template-columns: 1fr; }
  .conn-table-wrapper { overflow-x: auto; }
  .conn-table { min-width: 700px; }
}
