/* Design system tomado de codificardev.com.ar (redesign.css) */
:root {
  --accent: #6366F1;
  --accent-hover: #818CF8;
  --accent-gradient: linear-gradient(135deg, #6366F1, #8B5CF6);
  --accent-glow: rgba(99, 102, 241, 0.15);
  --cyan: #22D3EE;
  --bg-primary: #09090B;
  --bg-elevated: #18181B;
  --bg-input: #1E1E22;
  --bg-subtle: #27272A;
  --border: #3F3F46;
  --border-light: #27272A;
  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #EF4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Barra superior */
.topbar {
  background: rgba(9, 9, 11, 0.9);
  border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 0.8rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: var(--text-primary); }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-txt { font-size: 0.9rem; color: var(--text-secondary); border-left: 1px solid var(--border); padding-left: 0.75rem; }
.brand-txt strong { color: var(--text-primary); font-weight: 600; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a {
  color: var(--text-secondary); text-decoration: none; padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm); font-size: 0.92rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav a:hover { background: var(--bg-subtle); color: var(--text-primary); }
.user-box { display: flex; align-items: center; gap: 0.75rem; }
.user-name { color: var(--text-secondary); font-size: 0.88rem; }

.container { max-width: 1100px; margin: 2rem auto 3rem; padding: 0 1.25rem; }
.footer {
  text-align: center; color: var(--text-muted); font-size: 0.8rem;
  padding: 2rem 1rem 2.5rem; border-top: 1px solid var(--border-light);
}
.footer a { color: var(--text-secondary); text-decoration: none; }
.footer a:hover { color: var(--accent-hover); }

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.2rem 0 0.4rem; }
h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.9rem; }
.muted { color: var(--text-secondary); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }

/* Tarjetas y grillas */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 1.4rem 1.6rem; margin: 1rem 0;
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Tabla de respaldo de cada gráfico: los valores nunca quedan sólo en el tooltip. */
.datos-tabla { margin-top: 1rem; border-top: 1px solid var(--border-light); padding-top: 0.6rem; }
.datos-tabla > summary {
  cursor: pointer; color: var(--text-muted); font-size: 0.84rem;
  list-style: none; user-select: none;
}
.datos-tabla > summary::before { content: '▸ '; }
.datos-tabla[open] > summary::before { content: '▾ '; }
.datos-tabla > summary:hover { color: var(--text-secondary); }
.datos-tabla .tabla { margin-top: 0.6rem; }

.stat { text-align: center; }
.stat-num {
  font-size: 2.6rem; font-weight: 700; font-family: var(--font-mono);
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-den { font-size: 1.2rem; color: var(--text-muted); font-weight: 500; font-family: var(--font-mono); }
.stat-label { color: var(--text-secondary); font-size: 0.88rem; margin-top: 0.2rem; }

/* Login */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(ellipse 60% 40% at 50% -10%, var(--accent-glow), transparent),
    var(--bg-primary);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.25rem; }
.auth-logo { height: 30px; width: auto; display: block; margin-bottom: 1.2rem; }

/* Formularios */
label { display: block; margin: 0.9rem 0 0; font-size: 0.88rem; font-weight: 500; color: var(--text-secondary); }
input, select {
  width: 100%; padding: 0.6rem 0.8rem; margin-top: 0.35rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem;
  background: var(--bg-input); color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
}
select { width: auto; }
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.92rem;
  font-weight: 600; font-family: var(--font-sans);
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
}
.btn-primary { background: var(--accent-gradient); color: #fff; margin-top: 1.1rem; }
.btn-primary:hover { opacity: 0.88; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.84rem; }
.inline { display: inline; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin: 0.9rem 0; font-size: 0.9rem; }
.alert-error { background: var(--error-bg); color: #FCA5A5; border: 1px solid rgba(239, 68, 68, 0.35); }
.alert-ok { background: var(--success-bg); color: #6EE7B7; border: 1px solid rgba(16, 185, 129, 0.35); }
.clave {
  font-family: var(--font-mono); font-size: 1rem; background: var(--bg-input);
  padding: 0.15rem 0.55rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--cyan);
}

/* Tablas */
.tabla { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tabla th, .tabla td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.tabla tbody tr { transition: background var(--transition); }
.tabla tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.tabla thead th {
  color: var(--text-muted); font-size: 0.74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.tabla a { color: var(--accent-hover); text-decoration: none; }
.tabla a:hover { text-decoration: underline; }
.tabla-perfil th { width: 45%; color: var(--text-secondary); font-weight: 500; }

/* Lista de aciertos */
.check-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.check-list li { display: flex; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border-light); font-size: 0.9rem; }
.check-icon { font-weight: 700; }
.check-list .ok .check-icon { color: var(--success); }
.check-list .fail .check-icon { color: var(--error); }

/* Respuestas del alumno */
.respuesta-item { padding: 1rem 0; border-bottom: 1px solid var(--border-light); }
.respuesta-item:last-child { border-bottom: none; }
.respuesta-enunciado { font-weight: 600; margin-bottom: 0.4rem; }
.valor-texto { margin: 0.3rem 0; white-space: pre-wrap; color: var(--text-secondary); }
.resp-ok .respuesta-enunciado { color: #6EE7B7; }
.resp-fail .respuesta-enunciado { color: #FCA5A5; }
.referencia {
  background: var(--success-bg); border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; margin-top: 0.5rem; font-size: 0.88rem;
}
.referencia-det { margin-top: 0.5rem; font-size: 0.88rem; }
.referencia-det summary { cursor: pointer; color: var(--accent-hover); }
.referencia-det p { background: var(--bg-input); border-radius: var(--radius-sm); padding: 0.65rem 0.9rem; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.12rem 0.55rem;
  border-radius: var(--radius-full); margin-right: 0.4rem; vertical-align: middle;
  letter-spacing: 0.3px;
}
.badge-ok { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-fail { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warn { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0.3rem 0; }
.chip {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-full);
  padding: 0.18rem 0.75rem; font-size: 0.84rem; text-decoration: none; color: var(--text-secondary);
  transition: border-color var(--transition), color var(--transition);
}
a.chip:hover { border-color: var(--accent); color: var(--text-primary); }
.chips-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-activo { background: var(--accent-gradient); color: #fff; border-color: transparent; }

.lista-simple { padding-left: 1.2rem; font-size: 0.88rem; color: var(--text-secondary); }
.lista-simple li { margin: 0.35rem 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Preguntas expandibles (panel admin) */
.q { border-bottom: 1px solid var(--border-light); }
.q:last-child { border-bottom: none; }
.q > summary {
  list-style: none; display: flex; align-items: center; gap: 0.9rem;
  padding: 0.65rem 0.5rem; cursor: pointer; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.q > summary::-webkit-details-marker { display: none; }
.q > summary:hover { background: rgba(255, 255, 255, 0.03); }
.q[open] > summary { background: rgba(255, 255, 255, 0.03); }
.q-cod {
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500;
  color: var(--accent-hover); background: var(--accent-glow);
  border-radius: var(--radius-sm); padding: 0.18rem 0.5rem;
  min-width: 3.4rem; text-align: center; flex-shrink: 0;
}
.q-enun { flex: 1; font-size: 0.9rem; line-height: 1.45; }
.q-meta { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.q-pct { font-family: var(--font-mono); font-size: 0.86rem; }
.minibar {
  width: 110px; height: 8px; background: var(--bg-subtle);
  border-radius: var(--radius-full); overflow: hidden;
}
.minibar i { display: block; height: 100%; background: var(--accent-gradient); border-radius: var(--radius-full); }
.q-body { padding: 0.5rem 0.5rem 1.3rem; }
.q-linea { margin: 0.4rem 0 0.8rem; font-size: 0.9rem; }

/* Barras de distribución en HTML (sin canvas) */
.dist { display: grid; gap: 0.4rem; margin: 0.9rem 0; }
.dist-row {
  display: grid; grid-template-columns: minmax(150px, 38%) 1fr 2.4rem;
  gap: 0.8rem; align-items: center; font-size: 0.86rem;
}
.dist-label { color: var(--text-secondary); text-align: right; overflow-wrap: anywhere; line-height: 1.35; }
.dist-track { height: 14px; background: var(--bg-subtle); border-radius: 4px; overflow: hidden; }
.dist-track i {
  display: block; height: 100%; min-width: 3px;
  background: rgba(99, 102, 241, 0.55); border-right: 2px solid var(--accent-hover);
  border-radius: 0 4px 4px 0;
}
.dist-correcta .dist-track i { background: rgba(16, 185, 129, 0.4); border-right-color: #34D399; }
.dist-correcta .dist-label { color: #6EE7B7; font-weight: 600; }
.dist-val { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-secondary); text-align: right; }

.q-indiv { margin-top: 0.8rem; font-size: 0.9rem; }
.q-indiv > summary { cursor: pointer; color: var(--accent-hover); }
.q-indiv .tabla { margin-top: 0.6rem; }

@media (max-width: 640px) {
  .q > summary { flex-wrap: wrap; }
  .q-enun { flex-basis: 100%; order: 3; }
  .dist-row { grid-template-columns: 1fr 3rem; }
  .dist-label { grid-column: 1 / -1; text-align: left; }
}

@media (max-width: 640px) {
  .topbar-inner { gap: 0.6rem; }
  .card { padding: 1.1rem; }
  .brand-txt { display: none; }
}
