/* ═══════════════════════════════════════════════
   VARIABLES & RESET
═══════════════════════════════════════════════ */
:root {
  --navy:    #0F1C2E;
  --navy2:   #1A2D45;
  --navy3:   #243B55;
  --gold:    #C8A84B;
  --gold2:   #E2C068;
  --steel:   #4A7FA5;
  --steel2:  #6BA3C8;
  --light:   #E8EDF2;
  --white:   #FFFFFF;
  --success: #2ECC71;
  --danger:  #E74C3C;
  --warn:    #F39C12;
  --text:    #CBD5E1;
  --muted:   #64748B;
  --border:  rgba(200,168,75,0.2);
  --shadow:  0 4px 24px rgba(0,0,0,0.4);
  --r:       8px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ═══════════════════════════════════════════════
   PANTALLAS
═══════════════════════════════════════════════ */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════ */
#screen-login {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #060E1A 0%, #0F1C2E 50%, #1A2D45 100%);
  position: relative;
  overflow: hidden;
}

#screen-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 60px, rgba(200,168,75,0.03) 60px, rgba(200,168,75,0.03) 61px),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(200,168,75,0.03) 60px, rgba(200,168,75,0.03) 61px);
}

.login-box {
  background: rgba(26,45,69,0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

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

.login-logo .emblem {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  color: var(--gold);
  letter-spacing: 3px;
}

.login-logo p {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

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

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  background: rgba(15,28,46,0.8);
  border: 1px solid rgba(200,168,75,0.25);
  border-radius: var(--r);
  padding: 12px 16px;
  color: var(--white);
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,168,75,0.1);
}

.btn-login, .btn-primary, .btn-secondary, .option-btn, .nav-item, [onclick] {
  touch-action: manipulation;
}

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: var(--navy);
  border: none;
  border-radius: var(--r);
  padding: 14px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(200,168,75,0.3); }
.btn-login:active { transform: translateY(0); }

.login-error {
  background: rgba(231,76,60,0.15);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--r);
  padding: 10px 14px;
  color: #ff8a7a;
  font-size: 13px;
  margin-top: 16px;
  display: none;
  text-align: center;
}

.login-note {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted);
}

.login-note a { color: var(--steel2); text-decoration: none; }

/* ═══════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════ */
#screen-app {
  flex-direction: row;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  min-width: 240px;
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(180deg, #060E1A 0%, #0F1C2E 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 2px;
}

.sidebar-logo span {
  display: block;
  font-family: 'Barlow', sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  color: var(--navy);
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 10px; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.nav-item:hover { background: rgba(200,168,75,0.07); color: var(--white); }
.nav-item.active { background: rgba(200,168,75,0.1); border-left-color: var(--gold); color: var(--gold); }

.nav-item .icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--r);
  padding: 9px;
  color: #ff8a7a;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(231,76,60,0.1); border-color: var(--danger); }

/* MAIN CONTENT */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100vh;
}

.topbar {
  background: rgba(15,28,46,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-transform: uppercase;
}

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

.progress-pill {
  background: rgba(200,168,75,0.1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}

.page-content { flex: 1; padding: 32px; }

/* ═══════════════════════════════════════════════
   PÁGINAS INTERNAS
═══════════════════════════════════════════════ */
.page { display: none; }
.page.active { display: block; }

/* PAGE HEADER */
.page-header { margin-bottom: 32px; }
.page-header h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  color: var(--white);
  letter-spacing: 2px;
}
.page-header p { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ═══════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
}

.stat-icon { font-size: 28px; margin-bottom: 12px; }
.stat-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  color: var(--white);
  line-height: 1;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.stat-change { font-size: 12px; color: var(--success); margin-top: 8px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
}

.card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Progress bars */
.progress-item { margin-bottom: 16px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-label span:first-child { color: var(--text); }
.progress-label span:last-child { color: var(--gold); font-weight: 600; }
.progress-bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 3px; transition: width 1s ease; }
.progress-fill.steel { background: linear-gradient(90deg, var(--steel), var(--steel2)); }
.progress-fill.success { background: linear-gradient(90deg, #27ae60, var(--success)); }

/* Recent activity */
.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.activity-dot.gold { background: var(--gold); }
.activity-dot.green { background: var(--success); }
.activity-dot.blue { background: var(--steel2); }
.activity-text { font-size: 13px; color: var(--text); flex: 1; }
.activity-time { font-size: 11px; color: var(--muted); }

/* ═══════════════════════════════════════════════
   PSICOTÉCNICOS
═══════════════════════════════════════════════ */
.test-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.test-cat-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.test-cat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(200,168,75,0.05), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.test-cat-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.test-cat-card:hover::after { opacity: 1; }

.cat-icon { font-size: 36px; margin-bottom: 12px; }
.cat-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-transform: uppercase;
}
.cat-desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cat-stats { display: flex; gap: 16px; margin-top: 16px; }
.cat-stat { font-size: 12px; color: var(--muted); }
.cat-stat strong { color: var(--gold); font-size: 14px; display: block; }

.cat-mode-btns {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  position: relative;
  z-index: 10;
}
.cat-btn-ayuda, .cat-btn-examen {
  flex: 1;
  padding: 9px 10px;
  border: none;
  border-radius: 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  touch-action: manipulation;
  position: relative;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}
.cat-btn-ayuda {
  background: linear-gradient(135deg, rgba(200,168,75,0.18), rgba(200,168,75,0.08));
  border: 1px solid rgba(200,168,75,0.5);
  color: var(--gold2);
}
.cat-btn-ayuda:hover { background: linear-gradient(135deg, rgba(200,168,75,0.3), rgba(200,168,75,0.15)); border-color: var(--gold); transform: translateY(-1px); }
.cat-btn-ayuda:active { transform: translateY(0); opacity: 0.85; }
.cat-btn-examen {
  background: linear-gradient(135deg, rgba(231,76,60,0.2), rgba(231,76,60,0.08));
  border: 1px solid rgba(231,76,60,0.5);
  color: #ff8a7a;
}
.cat-btn-examen:hover { background: linear-gradient(135deg, rgba(231,76,60,0.35), rgba(231,76,60,0.18)); border-color: #E74C3C; transform: translateY(-1px); }
.cat-btn-examen:active { transform: translateY(0); opacity: 0.85; }

/* TEST ACTIVO */
#test-container { display: none; }

.test-header {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.test-info h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-transform: uppercase;
}

.test-info p { font-size: 13px; color: var(--muted); margin-top: 2px; }

.test-timer {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  color: var(--gold);
  letter-spacing: 2px;
  min-width: 80px;
  text-align: center;
}

.test-timer.warning { color: var(--warn); }
.test-timer.danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.test-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}

.test-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
  border-radius: 2px;
  transition: width 0.3s;
}

.question-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
  margin-bottom: 20px;
}

.question-num {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 16px;
}

.question-text {
  font-size: 18px;
  color: var(--white);
  line-height: 1.5;
  margin-bottom: 28px;
  font-weight: 500;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-btn {
  background: rgba(15,28,46,0.6);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--r);
  padding: 14px 18px;
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-btn:hover { border-color: var(--gold); color: var(--white); background: rgba(200,168,75,0.08); }
.option-btn.selected { border-color: var(--gold); background: rgba(200,168,75,0.12); color: var(--white); }
.option-btn.correct { border-color: var(--success); background: rgba(46,204,113,0.12); color: #7fffb8; }
.option-btn.wrong { border-color: var(--danger); background: rgba(231,76,60,0.12); color: #ff8a7a; }
.option-btn:disabled { cursor: default; }

.option-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0;
}

.test-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 24px;
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  border: none;
  border-radius: var(--r);
  padding: 10px 24px;
  color: var(--navy);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,168,75,0.3); }

/* Resultados test */
#test-results { display: none; }

/* Calculadora baremo */
.b-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: color 0.15s;
}
.b-check:hover { color: var(--white); }
.b-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--gold);
  flex-shrink: 0;
  cursor: pointer;
}
.b-check span { flex: 1; }
.b-check .b-pts {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(200,168,75,0.12);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.results-header {
  text-align: center;
  padding: 40px;
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 24px;
}

.results-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 80px;
  line-height: 1;
  margin-bottom: 8px;
}

.results-score.excellent { color: var(--success); }
.results-score.good { color: var(--gold); }
.results-score.poor { color: var(--danger); }

.results-label { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.results-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.result-stat {
  background: rgba(15,28,46,0.5);
  border-radius: var(--r);
  padding: 16px;
  text-align: center;
}
.result-stat-val { font-family: 'Bebas Neue', sans-serif; font-size: 32px; color: var(--white); }
.result-stat-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

/* ═══════════════════════════════════════════════
   TEMARIO
═══════════════════════════════════════════════ */
/* ── TEMARIO BIBLIOTECA ── */

.biblioteca-header {
  margin-bottom: 28px;
}
.biblioteca-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
.biblioteca-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #2ECC71);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.biblioteca-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.libro-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  pointer-events: all;
  user-select: none;
  -webkit-user-select: none;
}
.libro-card:hover {
  border-color: rgba(200,168,75,0.5);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.libro-card.leido {
  border-color: rgba(46,204,113,0.25);
}
.libro-card-spine {
  height: 6px;
  width: 100%;
}
.libro-card-body {
  padding: 20px;
}
.libro-card-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 8px;
}
.libro-card-titulo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  margin-bottom: 10px;
}
.libro-card-intro {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.libro-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.libro-card-secciones {
  font-size: 11px;
  color: var(--muted);
}
.libro-card-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}
.libro-card-badge.leido-badge {
  background: rgba(46,204,113,0.15);
  color: #2ECC71;
}
.libro-card-badge.nuevo-badge {
  background: rgba(200,168,75,0.12);
  color: var(--gold);
}

/* ── LECTOR ── */
.lector-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.lector-back {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.lector-back:hover { background: rgba(255,255,255,0.1); color: var(--white); }

.lector-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}
.lector-indice {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: sticky;
  top: 80px;
}
.lector-indice-title {
  padding: 12px 16px;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(200,168,75,0.06);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.lector-indice-item {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.lector-indice-item:hover { color: var(--white); background: rgba(255,255,255,0.03); }
.lector-indice-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(200,168,75,0.06); }

.lector-contenido {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.lector-tema-titulo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--white);
  margin-bottom: 6px;
}
.lector-tema-intro {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.lector-seccion {
  margin-bottom: 32px;
  scroll-margin-top: 90px;
}
.lector-seccion-titulo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(200,168,75,0.15);
}
.lector-seccion p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 12px;
}
.lector-seccion ul {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lector-seccion ul li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 8px 12px;
  background: rgba(255,255,255,0.025);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.04);
  line-height: 1.5;
}
.lector-seccion ul li::before {
  content: '▸';
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 1px;
}
.lector-nav-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

/* Legacy — keep for info/warn boxes */
.temario-grid { display: none; }

.temario-nav {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  height: fit-content;
  position: sticky;
  top: 80px;
}

.temario-nav-title {
  padding: 16px 20px;
  background: rgba(200,168,75,0.08);
  border-bottom: 1px solid var(--border);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

.temario-nav-item {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.temario-nav-item:hover { background: rgba(200,168,75,0.05); color: var(--white); }
.temario-nav-item.active { background: rgba(200,168,75,0.1); color: var(--gold); border-left: 3px solid var(--gold); }

.temario-nav-item .check { font-size: 14px; margin-left: auto; }

.temario-content {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 32px;
}

.temario-content h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--white);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.temario-content .tema-intro {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.temario-section { margin-bottom: 28px; }

.temario-section h4 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.temario-section p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.temario-section ul {
  list-style: none;
  margin-top: 12px;
}

.temario-section ul li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.temario-section ul li::before {
  content: '▸';
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 1px;
}

.info-box {
  background: rgba(74,127,165,0.1);
  border: 1px solid rgba(74,127,165,0.3);
  border-radius: var(--r);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: var(--steel2);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.warn-box {
  background: rgba(243,156,18,0.1);
  border: 1px solid rgba(243,156,18,0.3);
  border-radius: var(--r);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: #f5c842;
}

.temario-nav-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

/* ═══════════════════════════════════════════════
   SIMULACROS
═══════════════════════════════════════════════ */
.simulacro-list { display: flex; flex-direction: column; gap: 16px; }

.simulacro-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  transition: all 0.2s;
}

.simulacro-card:hover { border-color: rgba(200,168,75,0.4); }

.simulacro-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  color: rgba(200,168,75,0.2);
  line-height: 1;
  min-width: 60px;
  text-align: center;
}

.simulacro-info { flex: 1; }
.simulacro-info h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--white);
  text-transform: uppercase;
}
.simulacro-info p { font-size: 13px; color: var(--muted); margin-top: 4px; }

.simulacro-meta {
  display: flex;
  gap: 20px;
  margin-top: 12px;
}

.sim-meta-item { font-size: 12px; color: var(--muted); }
.sim-meta-item strong { color: var(--text); display: block; font-size: 14px; }

.simulacro-action { text-align: right; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.badge-new { background: rgba(46,204,113,0.15); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }
.badge-done { background: rgba(200,168,75,0.1); color: var(--gold); border: 1px solid var(--border); }
.badge-locked { background: rgba(100,116,139,0.15); color: var(--muted); border: 1px solid rgba(100,116,139,0.2); }

/* ═══════════════════════════════════════════════
   PROGRESO
═══════════════════════════════════════════════ */
.progress-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.rank-card {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.rank-icon {
  font-size: 48px;
  line-height: 1;
}

.rank-info h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--gold);
  letter-spacing: 1px;
}
.rank-info p { font-size: 13px; color: var(--muted); }
.rank-info .rank-next { font-size: 12px; color: var(--steel2); margin-top: 6px; }

.history-table {
  background: var(--navy2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.table-header {
  padding: 16px 24px;
  background: rgba(200,168,75,0.05);
  border-bottom: 1px solid var(--border);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

table { width: 100%; border-collapse: collapse; }
.ranking-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.15s; }
tbody tr:hover { background: rgba(200,168,75,0.04); }
tbody tr:last-child { border-bottom: none; }
td { padding: 14px 20px; font-size: 14px; color: var(--text); }
td strong { color: var(--white); }

.score-cell {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.score-cell.high { color: var(--success); }
.score-cell.mid { color: var(--gold); }
.score-cell.low { color: var(--danger); }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

/* ═══════════════════════════════════════════════
   MOBILE — BASE (≤768px)
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Layout */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .page-content { padding: 12px; }

  /* Grids → single column */
  .dashboard-grid,
  .temario-grid,
  .options-grid,
  .results-breakdown,
  .sim-grid { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 14px 12px; }

  /* Temario layout stacks */
  .lector-body { grid-template-columns: 1fr; }
  .lector-indice { position: static; display: none; }
  .lector-contenido { padding: 20px 16px; }
  .biblioteca-grid { grid-template-columns: 1fr; }

  /* Question box */
  .question-box { padding: 16px 12px; }
  .options-grid { gap: 8px; }
  .option-btn { padding: 12px 10px; font-size: 14px; min-height: 44px; }

  /* Simulacros */
  .sim-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .sim-meta { flex-wrap: wrap; gap: 8px; }

  /* Ranking table scrollable */
  .ranking-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead th, tbody td { padding: 10px 8px; font-size: 13px; white-space: nowrap; }

  /* Stats */
  .stat-number { font-size: 28px; }

  /* Buttons touch targets */
  .btn-primary, .btn-secondary { padding: 12px 20px; font-size: 15px; min-height: 44px; }

  /* Login box */
  .login-box { padding: 32px 20px; margin: 16px; }

  /* Fitness panel - contained */
  #panel-fitness > div { padding: 12px 0 !important; }

  /* IMC calculator inputs */
  #imc-peso, #imc-talla { font-size: 16px !important; }

  /* Day cards in fitness */
  .dia-detail a {
    min-height: 40px;
    padding: 8px 14px !important;
    font-size: 13px !important;
  }

  /* Nav items touch targets */
  .nav-item { padding: 14px 20px; min-height: 44px; }

  /* Profile / user area */
  .user-info { padding: 12px 16px; }

  /* Badges */
  .badge { font-size: 10px; padding: 2px 8px; }

  /* Hamburger larger touch area */
  .hamburger { padding: 10px; min-width: 44px; min-height: 44px; }
}

/* ═══════════════════════════════════════════════
   MOBILE — SMALL (≤480px)
═══════════════════════════════════════════════ */
/* Pruebas físicas: tabla desktop, cards móvil */
@media (max-width: 560px) {
  .pruebas-tabla { display: none !important; }
  .pruebas-cards { display: flex !important; flex-direction: column; }

  /* Simulacro físico — ajustes móvil */
  #panel-fisico .fis-cron-num  { font-size: 38px !important; }
  #panel-fisico .fis-imgs      { flex-direction: column !important; }
  #panel-fisico .fis-img-box   { height: 180px !important; }
  #panel-fisico .fis-nav-btns  { flex-direction: column !important; }
  #panel-fisico .fis-nav-btns button { width: 100% !important; }
  #panel-fisico .fis-header    { flex-direction: column !important; align-items: flex-start !important; }
  #panel-fisico .fis-time-inputs { flex-wrap: wrap !important; gap: 6px !important; }
}
@media (min-width: 561px) {
  .pruebas-tabla { display: block; }
  .pruebas-cards { display: none !important; }
}

@media (max-width: 480px) {
  .page-content { padding: 8px; }
  .card { padding: 12px 10px; border-radius: 8px; }

  /* Fitness plan day cards grid → single column always */
  #panel-fitness [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Popover móvil: flechita decorativa oculta (es fixed centrado) */
  .dia-popover > div:first-child { display: none !important; }

  /* Botones dentro del popover en móvil se apilan */
  .dia-popover [style*="display:flex"][style*="flex-wrap:wrap"] {
    flex-direction: column;
  }
  .dia-popover a, .dia-popover button[onclick*="speakEjercicio"] {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  /* IMC calculator flex → column */
  #panel-fitness [style*="display:flex"][style*="gap:12px"] {
    flex-direction: column;
  }

  /* Login tighter */
  .login-box { padding: 24px 16px; }
  .login-logo h1 { font-size: 26px; }

  /* Sim cards */
  .sim-card { padding: 14px 12px; }

  /* Font adjustments — minimum readable */
  .card-title { font-size: 13px; }
  .stat-number { font-size: 24px; }
}

/* ═══════════════════════════════════════════════
   TOUCH IMPROVEMENTS — ALL MOBILE
═══════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover states that don't work on touch */
  .nav-item:hover { background: transparent; color: var(--text); }
  .nav-item.active:hover { background: rgba(200,168,75,0.1); color: var(--gold); }

  /* Larger tap areas for interactive elements */
  .nav-item { min-height: 48px; }
  .option-btn { min-height: 52px; }
  .btn-primary, .btn-secondary, .btn-login { min-height: 48px; }

  /* Prevent text selection on tap */
  .nav-item, .option-btn, .sim-card, [onclick] { -webkit-user-select: none; user-select: none; }

  /* Remove tap highlight flash */
  * { -webkit-tap-highlight-color: transparent; }

  /* Smooth scrolling on iOS */
  .temario-nav, .sidebar-nav, .main-content { -webkit-overflow-scrolling: touch; }
}

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(200,168,75,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200,168,75,0.4); }

/* Fade in */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page.active { animation: fadeIn 0.25s ease; }

/* ─── SIM MODO SELECTOR ─── */
.sim-modo-wrap {
  max-width: 540px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
}
.sim-modo-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  color: var(--white);
  letter-spacing: 3px;
  margin-bottom: 6px;
}
.sim-modo-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 36px;
  letter-spacing: 0.5px;
}
.sim-modo-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
.sim-modo-card {
  background: var(--navy2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 28px 20px;
  cursor: pointer;
  transition: all 0.22s;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.sim-modo-card:hover { transform: translateY(-3px); }
.sim-modo-card.ayuda { border-color: rgba(200,168,75,0.35); }
.sim-modo-card.ayuda:hover { border-color: var(--gold); background: rgba(200,168,75,0.07); box-shadow: 0 8px 32px rgba(200,168,75,0.15); }
.sim-modo-card.examen { border-color: rgba(231,76,60,0.35); }
.sim-modo-card.examen:hover { border-color: #E74C3C; background: rgba(231,76,60,0.07); box-shadow: 0 8px 32px rgba(231,76,60,0.15); }
.sim-modo-card .smc-icon { font-size: 44px; margin-bottom: 14px; display: block; }
.sim-modo-card .smc-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.sim-modo-card.ayuda .smc-name { color: var(--gold2); }
.sim-modo-card.examen .smc-name { color: #ff8a7a; }
.sim-modo-card .smc-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 14px;
}
.sim-modo-card .smc-pills {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sim-modo-card .smc-pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 5px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.sim-modo-card.ayuda .smc-pill { background: rgba(200,168,75,0.12); color: var(--gold); }
.sim-modo-card.examen .smc-pill { background: rgba(231,76,60,0.12); color: #ff8a7a; }
.sim-modo-back {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-family: 'Barlow', sans-serif;
  transition: color 0.2s;
}
.sim-modo-back:hover { color: var(--text); }
@media (max-width: 480px) {
  .sim-modo-cards { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   PAGE TRANSITIONS & POLISH
═══════════════════════════════════════════════ */
body {
  animation: pageFadeIn 0.25s ease;
}

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

/* Nav transition overlay */
#nav-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--navy);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.18s ease;
}
#nav-transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ═══════════════════════════════════════════════
   FITNESS — MEJORAS VISUALES v2
══════════════════════════════════════════════ */
/* Cards del plan fitness con bordes más visibles */
#panel-fitness .card {
  border-color: rgba(200,168,75,0.22);
  border-width: 1px;
}
#panel-fitness .card:hover {
  border-color: rgba(200,168,75,0.35);
}
/* Días del plan semanal — borde más visible */
[data-semana] > div > div[style*="display:grid"] > div {
  border-color: rgba(255,255,255,0.12) !important;
}
/* Dias hover */
[data-semana] > div > div[style*="display:grid"] > div:hover {
  border-color: rgba(200,168,75,0.4) !important;
}
/* Día abierto */
[data-semana] > div > div[style*="display:grid"] > div.dia-open {
  border-color: rgba(200,168,75,0.5) !important;
  background: rgba(200,168,75,0.06) !important;
}
/* Botones dentro del popover en móvil */
.dia-popover {
  max-width: min(300px, 85vw);
}
.dia-popover a, .dia-popover button {
  font-size: 11px !important;
}
/* Fix CTA flex en móvil */
@media (max-width: 480px) {
  #panel-fitness [style*="flex-wrap:wrap"] {
    flex-wrap: wrap !important;
  }
  #panel-fitness [style*="justify-content:space-between"] {
    flex-direction: column;
    align-items: flex-start;
  }
  .imc-form-btn {
    width: 100% !important;
  }
}
