:root {
  --bg: #f7f9fc;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #0c6ddf;
  --primary-700: #0a5cc0;
  --secondary: #0ea5e9;
  --ok: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #e2f3d6;
  border-bottom: 1px solid #d6e8c8;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #56b4d3;
  color: #fff; display: grid; place-items: center;
  font-weight: 700;
}
.title { font-size: 18px; font-weight: 600; }

.nav { display: flex; gap: 8px; }
.nav-btn {
  padding: 8px 12px; border: none; background: var(--card-bg);
  border: 1px solid #d1d5db; border-radius: 8px; cursor: pointer; color: var(--text);
}
.nav-btn:hover { background: #f3f4f6; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }

h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 24px; margin: 0 0 16px; }
h3 { margin: 8px 0 12px; }

.primary, .secondary {
  padding: 10px 14px; border: none; border-radius: 8px; cursor: pointer;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-700); }
.secondary { background: var(--card-bg); border: 1px solid #d1d5db; }
.secondary:hover { background: #f3f4f6; }

.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 920px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .cards-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card-bg);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; cursor: pointer; user-select: none;
}
.card-title .chev { color: var(--muted); }
.card-title:hover { color: var(--primary); }

.card-desc { margin-top: 10px; color: var(--muted); display: none; }
.card.open .card-desc { display: block; }

.section-actions { margin-top: 16px; display: flex; gap: 8px; }

.quiz { margin-top: 12px; display: grid; gap: 16px; }
.quiz .q-card { padding: 16px; border-radius: 12px; background: var(--card-bg); border: 1px solid #e5e7eb; }
.quiz .q-title { font-weight: 600; margin-bottom: 12px; white-space: pre-line;}
.quiz label { display: flex; gap: 10px; padding: 6px 0; cursor: pointer; }

.quiz-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.progreso { color: var(--muted); }

.resultado { margin-top: 12px; font-weight: 600; }
.resultado.ok { color: var(--ok); }
.resultado.fail { color: var(--danger); }

.certificado.hidden { display: none; }

/* Certificado profesional */
.cert {
  margin-top: 18px; 
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: 3px solid #0066a4;
  border-radius: 20px; 
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 102, 164, 0.15);
  position: relative;
  max-width: 800px;
  margin: 20px auto;
  font-family: 'Georgia', serif;
}

/* Encabezado del certificado */
.cert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #0066a4;
}

.cert-logo {
  flex: 0 0 auto;
}

.cert-logo-img {
  width: 120px;
  height: auto;
  background: white;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.cert-title-section {
  flex: 1;
  text-align: center;
  margin-left: 20px;
}

.cert-main-title {
  font-size: 28px;
  font-weight: bold;
  color: #0066a4;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.cert-subtitle {
  font-size: 16px;
  color: #666;
  margin-top: 5px;
  font-style: italic;
}

/* Decoraciones */
.cert-decoration-top, .cert-decoration-bottom {
  text-align: center;
  margin: 20px 0;
}

.cert-ornament {
  width: 200px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #0066a4, transparent);
  margin: 0 auto;
  position: relative;
}

.cert-ornament::before,
.cert-ornament::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 9px;
  height: 9px;
  background: #0066a4;
  border-radius: 50%;
}

.cert-ornament::before {
  left: -5px;
}

.cert-ornament::after {
  right: -5px;
}

/* Cuerpo del certificado */
.cert-body {
  text-align: center;
  margin: 30px 0;
  line-height: 1.8;
}

.cert-text-main {
  font-size: 18px;
  color: #333;
  margin-bottom: 15px;
}

.cert-name-container {
  margin: 20px 0;
  padding: 15px;
  background: linear-gradient(90deg, #f8f9fa, #e9ecef, #f8f9fa);
  border-radius: 10px;
  border: 2px dashed #0066a4;
}

.cert-name {
  font-size: 32px;
  font-weight: bold;
  color: #0066a4;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cert-text-secondary {
  font-size: 16px;
  color: #555;
  margin: 15px 0;
}

.cert-course-name {
  font-size: 24px;
  color: #0066a4;
  margin: 20px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cert-description {
  font-size: 14px;
  color: #666;
  font-style: italic;
  max-width: 600px;
  margin: 20px auto;
  line-height: 1.6;
}

/* Información de organización y fecha */
.cert-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0;
  padding: 20px;
  background: rgba(0, 102, 164, 0.05);
  border-radius: 10px;
}

.cert-organization {
  text-align: left;
}

.cert-org-name {
  font-size: 20px;
  font-weight: bold;
  color: #0066a4;
}

.cert-org-subtitle {
  font-size: 14px;
  color: #666;
  font-style: italic;
}

.cert-date-section {
  text-align: right;
}

.cert-date-label {
  font-size: 14px;
  color: #666;
}

.cert-date {
  font-size: 16px;
  font-weight: bold;
  color: #0066a4;
}

/* Pie del certificado */
.cert-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px solid #0066a4;
}

.cert-signature-section {
  text-align: center;
}

.cert-signature-line {
  width: 200px;
  height: 2px;
  background: #0066a4;
  margin-bottom: 10px;
}

.cert-signature-text {
  font-size: 14px;
  color: #666;
  font-weight: bold;
}

.cert-seal {
  position: relative;
}

.cert-seal-circle {
  width: 80px;
  height: 80px;
  border: 3px solid #0066a4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  box-shadow: 0 4px 15px rgba(0, 102, 164, 0.2);
}

.cert-seal-text {
  font-size: 12px;
  font-weight: bold;
  color: #0066a4;
  text-align: center;
  line-height: 1.2;
}

/* Mensaje final */
.cert-message {
  text-align: center;
  font-size: 14px;
  color: #666;
  font-style: italic;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

/* Acciones del certificado */
.cert-actions { 
  margin-top: 20px; 
  display: flex; 
  justify-content: center;
  gap: 15px;
}

.cert-actions button {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.cert-actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
  .cert {
    padding: 20px;
    margin: 10px;
  }
  
  .cert-header {
    flex-direction: column;
    text-align: center;
  }
  
  .cert-title-section {
    margin-left: 0;
    margin-top: 15px;
  }
  
  .cert-main-title {
    font-size: 22px;
  }
  
  .cert-name {
    font-size: 24px;
  }
  
  .cert-course-name {
    font-size: 18px;
  }
  
  .cert-info {
    flex-direction: column;
    text-align: center;
    gap: 15px;
  }
  
  .cert-footer {
    flex-direction: column;
    gap: 20px;
  }
  
  .cert-actions {
    flex-direction: column;
  }
}

.site-footer { padding: 16px 24px; text-align: center; color: var(--muted); }

.form-row { display: grid; gap: 6px; margin-bottom: 8px; }
.form-row label { color: var(--muted); }
.form-row input, .form-row select {
  padding: 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
}
.muted { color: var(--muted); }

/* Material del PDF */
.pdf-content { margin-top: 16px; display: grid; gap: 16px; }
.pdf-page { background: var(--card-bg); border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px; }
.pdf-page h3 { margin: 0 0 8px; font-size: 18px; }
.pdf-canvas { width: 100%; height: auto; display: block; border: 1px dashed #e5e7eb; border-radius: 8px; }
.pdf-text { color: var(--muted); white-space: pre-wrap; margin-top: 8px; }

/* Presentación del material: visor centrado + lista en columna */
.img-material { margin-top: 16px; display: grid; gap: 16px; }
.img-viewer { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#main-img { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 12px; background: #fff; }
.viewer-controls { display: flex; gap: 8px; }
.viewer-controls .btn { padding: 8px 12px; border-radius: 8px; border: 1px solid #d1d5db; background: var(--card-bg); cursor: pointer; }
.viewer-controls .btn:hover { background: #f3f4f6; }

.thumb-list { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.thumb-item { width: 100%; max-width: 340px; background: var(--card-bg); border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); cursor: pointer; }
.thumb-item img { display: block; width: 100%; height: auto; }
.thumb-caption { padding: 10px 12px; color: var(--muted); font-size: 14px; border-top: 1px solid #e5e7eb; }
.thumb-item:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.08); }
.thumb-item.active { outline: 2px solid var(--primary); }

/* (Lightbox removido: usamos visor en página) */