/* ==========================================================================
   Design System Oficial Freiría Lorenzo · App aula D: Gestor Docente
   Tema Dark Slate / Engineering Blue & Plantilla Técnica de Impresión A4
   ========================================================================== */

:root {
  /* Fondos y Paneles */
  --bg: #0f172a;           /* Slate 900 - Fondo general de la app */
  --panel: #1e293b;        /* Slate 800 - Paneles, tarjetas y barras */
  --panel-hover: #273548;  /* Resalte al pasar el cursor */
  --panel-active: #1e3a5f; /* Elemento activo o seleccionado */
  --border: #334155;       /* Slate 700 - Bordes estructurales */
  --border-light: #475569; /* Slate 600 */

  /* Colores de Acento Corporativo */
  --accent: #2563eb;       /* Blue 600 - Botones primarios, acciones */
  --accent-hover: #1d4ed8; /* Blue 700 */
  --accent-light: #38bdf8; /* Sky 400 - Títulos, badges activos */
  --accent-bg: #1e3a5f;    /* Fondo acento translúcido */

  /* Jerarquía de Texto */
  --text: #e2e8f0;         /* Slate 200 - Texto principal */
  --text-dim: #94a3b8;     /* Slate 400 - Leyendas y etiquetas */
  --text-muted: #64748b;   /* Slate 500 - Metadatos e iconos */
  --white: #ffffff;

  /* Estados Semánticos de Calidad y Control */
  --success: #22c55e;      /* Verde - Presente / Aprobado / Conforme */
  --success-bg: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;      /* Ámbar - Justificada (J) / Retraso / Revisión */
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;       /* Rojo - Falta injustificada / Suspenso / Alerta */
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #0ea5e9;         /* Azul claro */
  --info-bg: rgba(14, 165, 233, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
}

/* ==================== HEADER FIJO ==================== */
.header {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 100;
  gap: 15px;
}

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

.header-logo {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.header-title h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.1;
  letter-spacing: 0.3px;
}

.header-title h1 span {
  font-size: 13px;
  font-weight: 400;
  color: var(--accent-light);
  margin-left: 6px;
}

.header-subtitle {
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.nav-tab.active {
  background: var(--accent);
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.tab-icon {
  font-size: 13px;
}

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

.academic-badge {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-light);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

/* ==================== BOTONES ESTÁNDAR ==================== */
.btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--panel-hover); border-color: var(--text-dim); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #16a34a; }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: #d97706; }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-xs { padding: 2px 6px; font-size: 10.5px; border-radius: 4px; }
.btn-full { width: 100%; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.btn-icon:hover { background: var(--panel-hover); border-color: var(--text-dim); }

.btn-group-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ==================== CONTENEDOR PRINCIPAL & VISTAS ==================== */
.app-container {
  height: calc(100vh - 56px);
  position: relative;
  overflow: hidden;
}

.app-view {
  display: none;
  height: 100%;
  width: 100%;
}

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

/* ==================== VISTA 1: ASISTENCIA ==================== */
.asistencia-layout {
  display: flex;
  height: 100%;
}

.asistencia-sidebar {
  width: 330px;
  min-width: 330px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px;
  gap: 12px;
}

.asistencia-main {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
}

/* Calendario */
.panel-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.calendar-card {
  user-select: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.calendar-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  color: var(--text-dim);
  transition: all 0.1s ease;
}

.cal-day:hover {
  background: var(--panel-hover);
  color: var(--white);
}

.cal-day.empty {
  cursor: default;
  background: transparent;
  border: none;
}

.cal-day.today {
  border-color: var(--accent);
  font-weight: 700;
  color: var(--accent-light);
}

.cal-day.has-session {
  background: rgba(37, 99, 235, 0.12);
  color: var(--white);
  font-weight: 600;
}

.cal-day.has-session::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-light);
}

.cal-day.selected {
  background: var(--accent) !important;
  color: var(--white) !important;
  font-weight: 700;
}

.cal-day.selected::after {
  background: var(--white);
}

.calendar-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.dot-class { background: var(--accent-light); }
.dot-selected { background: var(--accent); }

/* Formulario Sesión */
.session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.session-card-header h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--white);
}

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 3px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 6px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.session-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0;
  background: var(--panel);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  text-align: center;
}

.kpi-mini {
  display: flex;
  flex-direction: column;
}

.kpi-val {
  font-size: 15px;
  font-weight: 700;
}

.kpi-lbl {
  font-size: 9.5px;
  color: var(--text-muted);
}

.session-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==================== HISTORIAL DE CLASES EN BARRA LATERAL ==================== */
.history-classes-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-classes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-classes-header h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--white);
  margin: 0;
}

.history-search-wrap {
  width: 100%;
}

.history-search-input {
  width: 100%;
  font-size: 11px;
  padding: 5px 8px;
}

.classes-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 2px;
}

.class-item-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.class-item-card:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
  transform: translateX(2px);
}

.class-item-card.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.25);
}

.class-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.class-item-date {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--white);
}

.class-item-card.active .class-item-date {
  color: var(--accent-light);
}

.class-item-time {
  font-size: 10px;
  color: var(--text-dim);
}

.class-item-tema {
  font-size: 11px;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 10px;
}

.class-item-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.class-badge-mini {
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
}
.class-badge-pres { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.class-badge-falt { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.class-badge-just { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.class-badge-retr { background: rgba(56, 189, 248, 0.15); color: var(--info); }

.class-btn-load {
  font-size: 10px;
  color: var(--accent-light);
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.class-btn-load:hover {
  text-decoration: underline;
}

/* ==================== TABLAS DE DATOS ==================== */
.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 15px;
}

.table-header-bar h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
}

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

.search-input {
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  width: 220px;
}
.search-input:focus { border-color: var(--accent); }

.table-container {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
}

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

.data-table th {
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

/* Fila de Asistencia con Controles */
.student-row-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}

.student-name-cell {
  display: flex;
  flex-direction: column;
}

.student-name-cell strong {
  color: var(--white);
  font-size: 12.5px;
}

.student-name-cell span {
  font-size: 10.5px;
  color: var(--text-dim);
}

/* Controles de Asistencia (3 Cuadros de Idéntico Tamaño: Presente, Justificado, Falta) */
.attendance-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  width: 100%;
}

.btn-status-toggle {
  height: 32px;
  width: 100%;
  padding: 0 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-status-toggle:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-status-toggle.active-presente {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.35);
}

.btn-status-toggle.active-justificada {
  background: var(--warning);
  color: #000;
  border-color: var(--warning);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.35);
}

.btn-status-toggle.active-falta {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.35);
}

/* Apartado de Resta de Tiempo (-15min, -30min, -1h, -2h) */
.time-deduction-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
}

.btn-time-deduct {
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.btn-time-deduct:hover {
  background: var(--panel-hover);
  border-color: var(--text-dim);
  color: var(--text);
}

.btn-time-deduct.active {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning);
  font-weight: 700;
}

.inline-obs-input {
  width: 100%;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 11.5px;
  outline: none;
}
.inline-obs-input:focus { border-color: var(--accent); }

/* ==================== VISTA 2: FICHA DE ALUMNO ==================== */
.ficha-layout {
  display: flex;
  height: 100%;
}

.ficha-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}

.ficha-main {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
}

.student-select-header {
  margin-bottom: 14px;
}

.student-select-header label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 500;
}

.form-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}
.form-select:focus { border-color: var(--accent); }

.student-profile-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.student-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 10px;
}

.student-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  background: var(--bg);
}

.btn-avatar-upload {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  border: 2px solid var(--panel);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.student-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.student-meta-item {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.link-email {
  color: var(--accent-light);
  text-decoration: none;
}
.link-email:hover { text-decoration: underline; }

.student-status-badge {
  margin: 8px 0;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.student-status-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

.student-status-badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Gauge */
.attendance-gauge-box {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin: 10px 0;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.gauge-header strong {
  color: var(--white);
}

.gauge-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.gauge-fill {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.gauge-fill.warning { background: var(--warning); }
.gauge-fill.danger { background: var(--danger); }

.gauge-details {
  font-size: 10px;
  color: var(--text-muted);
}

/* Card Resumen de Notas en Lateral */
.grades-summary-card {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.grades-summary-card h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: left;
}

.grades-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.grade-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
}

.grade-label {
  font-size: 9.5px;
  color: var(--text-muted);
}

.grade-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
}

.grade-box-final {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.badge-status-grade {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.student-actions-row {
  display: flex;
  gap: 6px;
  width: 100%;
}

/* Pestañas de la Ficha */
.ficha-nav-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.ficha-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ficha-tab:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.ficha-tab.active {
  background: var(--panel);
  color: var(--accent-light);
  border: 1px solid var(--border);
}

.ficha-subtab-content {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.ficha-subtab-content.active {
  display: flex;
}

.subtab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.subtab-toolbar h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
}

.badge {
  background: var(--accent-bg);
  color: var(--accent-light);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
}

.badge-accent {
  background: var(--accent);
  color: var(--white);
}

.legend-pills {
  display: flex;
  gap: 6px;
}

.pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-info { background: var(--info-bg); color: var(--info); }

/* Tarjetas de Evaluación Trimestral y Final */
.grades-eval-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 14px;
  overflow-y: auto;
  padding-bottom: 20px;
}

.eval-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.eval-card-header {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eval-card-header h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.eval-card-body {
  padding: 14px;
  flex: 1;
}

.eval-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.eval-stat-row strong {
  font-size: 14px;
  color: var(--white);
}

.eval-card-highlight {
  border-color: var(--accent);
  background: #142338;
}

.highlight-input-box {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 10px;
  border-radius: 6px;
}

.form-input-lg {
  font-size: 16px !important;
  font-weight: 700 !important;
  text-align: center;
  color: var(--accent-light) !important;
}

.form-input-xl {
  font-size: 24px !important;
  font-weight: 800 !important;
  text-align: center;
  color: #38bdf8 !important;
  background: #0b1728 !important;
}

.text-light-blue { color: #7dd3fc; }

/* ==================== VISTA 3: SÁBANA GENERAL ==================== */
.sabana-layout {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.stats-overview-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border-right: 1px solid var(--border);
  padding-right: 14px;
}

.stat-pill:last-child {
  border-right: none;
}

.stat-lbl { color: var(--text-dim); }

.sabana-table th.col-highlight,
.sabana-table td.col-highlight {
  background: rgba(37, 99, 235, 0.15);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}

.input-nota-manual-inline {
  width: 60px;
  padding: 4px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--white);
  font-weight: 700;
  font-size: 13px;
  outline: none;
}
.input-nota-manual-inline:focus {
  background: var(--panel-hover);
  border-color: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

/* ==================== VISTA 4: TRABAJOS & ENTREGAS ==================== */
.trabajos-layout {
  display: flex;
  height: 100%;
}

.trabajos-sidebar {
  width: 330px;
  min-width: 330px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
}

.trabajos-main {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 20px;
}

.sidebar-header-with-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sidebar-header-with-btn h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--white);
}

.trabajos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trabajo-item-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.trabajo-item-card:hover {
  background: var(--panel-hover);
  border-color: var(--text-dim);
}

.trabajo-item-card.active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.12);
}

.trabajo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.trabajo-eval-tag {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent-light);
  text-transform: uppercase;
}

.trabajo-peso-tag {
  font-size: 10px;
  color: var(--text-muted);
}

.trabajo-item-card h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.25;
  margin-bottom: 4px;
}

.trabajo-deadline {
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.active-trabajo-info-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==================== VISTA 5: INFORMES OFICIALES (A4) ==================== */
.informes-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.informes-controls-bar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}

.print-sheet-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #0b111e;
  display: flex;
  justify-content: center;
}

.report-preview-sheet {
  background: #ffffff;
  color: #1a1a1a;
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 18mm 20mm 18mm;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  font-family: 'Arial Narrow', Arial, -apple-system, sans-serif;
  font-size: 10.5pt;
  line-height: 1.4;
}

/* Plantilla Oficial de Informe A4 (Freiría Lorenzo) */
.rep-header {
  border-bottom: 2px solid #1e3a5f;
  padding-bottom: 10px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rep-logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rep-logo-img {
  height: 42px;
  width: auto;
}

.rep-title-group h2 {
  font-size: 14pt;
  font-weight: 700;
  color: #1e3a5f;
  margin: 0;
  letter-spacing: 0.3px;
}

.rep-title-group p {
  font-size: 9.5pt;
  color: #475569;
  margin: 2px 0 0 0;
}

.rep-cajetin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 9.5pt;
}

.rep-cajetin-table td {
  border: 1px solid #94a3b8;
  padding: 4px 8px;
}

.rep-cajetin-label {
  background: #f1f5f9;
  font-weight: 700;
  color: #1e3a5f;
}

.rep-section-title {
  font-size: 11pt;
  font-weight: 700;
  color: #1e3a5f;
  border-bottom: 1.5px solid #2563eb;
  padding-bottom: 3px;
  margin: 14px 0 8px 0;
  text-transform: uppercase;
}

.rep-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  font-size: 9pt;
}

.rep-table th {
  background: #e8f0fe;
  color: #1e3a5f;
  border: 1px solid #94a3b8;
  padding: 5px 6px;
  text-align: left;
  font-weight: 700;
}

.rep-table td {
  border: 1px solid #cbd5e1;
  padding: 4px 6px;
  color: #1a1a1a;
}

.rep-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* Tabla compactada para que los 23 alumnos encajen en una sola hoja A4 */
.rep-table-compact {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
  font-size: 7.8pt;
}

.rep-table-compact th {
  background: #e8f0fe;
  color: #1e3a5f;
  border: 1px solid #94a3b8;
  padding: 2.5px 5px;
  text-align: left;
  font-weight: 700;
  font-size: 7.5pt;
  line-height: 1.1;
}

.rep-table-compact td {
  border: 1px solid #cbd5e1;
  padding: 2px 4px;
  color: #1a1a1a;
  line-height: 1.15;
  font-size: 7.6pt;
}

.rep-table-compact tr:nth-child(even) td {
  background: #f8fafc;
}

.rep-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 8pt;
  font-weight: 700;
}
.rep-tag-presente { background: #dcfce7; color: #166534; }
.rep-tag-falta { background: #fee2e2; color: #991b1b; }
.rep-tag-just { background: #fef3c7; color: #92400e; }

.rep-firmas-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 25px;
  font-size: 9pt;
  page-break-inside: avoid;
}

.rep-firmas-table td {
  border: 1px solid #94a3b8;
  padding: 8px;
  vertical-align: top;
}

.rep-footer {
  display: flex;
  justify-content: space-between;
  font-size: 8pt;
  color: #64748b;
  border-top: 1px solid #cbd5e1;
  padding-top: 6px;
  margin-top: 25px;
}

/* ==================== MODALES ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-card-lg {
  width: 650px;
}

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

.modal-header h3 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--white);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
.modal-close:hover { color: var(--white); }

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(0, 0, 0, 0.15);
}

/* Switch & Checkbox */
.switch-lbl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.switch-lbl input { display: none; }

.switch-slider {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s ease;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  top: 3px;
  left: 3px;
  transition: all 0.2s ease;
}

.switch-lbl input:checked + .switch-slider {
  background: var(--accent);
}

.switch-lbl input:checked + .switch-slider::before {
  transform: translateX(16px);
}

.switch-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.input-readonly {
  background: var(--bg) !important;
  color: var(--accent-light) !important;
  font-weight: 700;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.2s ease-out;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==================== UTILIDADES ==================== */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-accent { color: var(--accent-light) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-xs { font-size: 11px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mb-3 { margin-bottom: 12px !important; }
/* ==================== PORTADA DE ACCESO / BLOQUEO PIN ==================== */
.auth-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 70%, #080d1a 100%);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-gate-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(37, 99, 235, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: authScaleIn 0.25s ease-out;
}

@keyframes authScaleIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.auth-header {
  padding: 24px 20px 14px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.auth-logo {
  height: 44px;
  width: auto;
  margin-bottom: 10px;
}

.auth-header h2 {
  font-size: 18px;
  color: var(--white);
  font-weight: 700;
}

.auth-header h2 span {
  color: var(--accent-light);
  font-size: 14px;
  font-weight: 400;
}

.auth-subtitle {
  font-size: 12px;
  color: var(--text);
  margin-top: 2px;
}

.auth-course-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-light);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.auth-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-lock-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.auth-notice {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 16px;
}

.pin-input-wrap {
  display: flex;
  position: relative;
  width: 100%;
  margin-bottom: 8px;
}

.pin-input {
  width: 100%;
  padding: 10px 42px 10px 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 6px;
  color: var(--accent-light);
  outline: none;
  transition: all 0.2s;
}

.pin-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.35);
}

.btn-toggle-pin {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.btn-toggle-pin:hover { color: var(--text); }

.auth-error-msg {
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.auth-remember-row {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 14px;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 6px auto;
}

.keypad-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--white);
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
}

.keypad-btn:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
}

.keypad-btn:active {
  transform: scale(0.96);
  background: var(--accent);
}

.keypad-btn-clear {
  color: var(--danger);
}

.keypad-btn-enter {
  color: var(--success);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
}
.keypad-btn-enter:hover {
  background: var(--success);
  color: #fff;
}

.auth-footer {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

/* ==================== SISTEMA DE RÚBRICA Y VALORACIÓN DE ENTREGAS ==================== */
.trabajos-table-rubrica th {
  padding: 8px 6px;
  font-size: 11px;
  vertical-align: middle;
}
.trabajos-table-rubrica td {
  padding: 6px 5px;
  font-size: 11.5px;
  vertical-align: middle;
}

.rubrica-chk {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--accent);
}

.rubrica-chk-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.rubrica-pts-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.rubrica-pts-tag.zero {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-dim);
}

.rubrica-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.rubrica-stepper-input {
  width: 42px;
  padding: 3px 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
}
.rubrica-stepper-input:focus {
  border-color: var(--accent);
  outline: none;
}

.rubrica-badge-score {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-block;
  min-width: 32px;
  text-align: center;
  line-height: 1;
}
.rubrica-badge-score.score-full {
  background: rgba(16, 185, 129, 0.18);
  color: #10b981;
}
.rubrica-badge-score.score-mid {
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
}
.rubrica-badge-score.score-zero {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
}

.rubrica-tabs-group {
  display: inline-flex;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.rubrica-tab-btn {
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  line-height: 1.1;
}
.rubrica-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.rubrica-tab-btn.active-bien {
  background: #15803d;
  color: #ffffff;
  font-weight: 700;
}
.rubrica-tab-btn.active-reg {
  background: #475569;
  color: #ffffff;
  font-weight: 700;
}
.rubrica-tab-btn.active-mal {
  background: #b91c1c;
  color: #ffffff;
  font-weight: 700;
}
.rubrica-tab-btn.active-casi {
  background: #d97706;
  color: #ffffff;
  font-weight: 700;
}

.rubrica-nota-bruta {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.rubrica-nota-final {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--accent-light);
}

.rubrica-select-plazo {
  font-size: 11px;
  padding: 3px 4px;
  width: 95px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}

/* ==================== MEDIA PRINT ==================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 15mm 12mm;
  }

  body {
    background: #ffffff !important;
    color: #1a1a1a !important;
    height: auto !important;
    overflow: visible !important;
    font-size: 10pt !important;
  }

  .header,
  .no-print,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .app-container {
    height: auto !important;
    overflow: visible !important;
  }

  .app-view {
    display: none !important;
  }

  #view-informes {
    display: block !important;
  }

  .print-sheet-wrapper {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .report-preview-sheet {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
  }
}
