/* === RESET Y BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Permitir selección solo en inputs y textareas */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-lighter: #eff6ff;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --danger: #dc2626;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 28px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.18);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    /* Safe area helpers */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    /* Mobile nav height */
    --nav-user-h: 40px;
    --nav-tabs-h: 62px;
    --nav-total: calc(var(--nav-user-h) + var(--nav-tabs-h) + var(--safe-bottom));
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* === INPUTS — 16px mínimo en iOS para evitar zoom automático === */
input,
textarea,
select {
    font-size: 1rem;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

/* === BOTONES — targets táctiles mínimo 44px === */
button {
    touch-action: manipulation;
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

/* === LOGIN SCREEN === */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #1e40af 0%, #2563eb 45%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    padding: 1.25rem;
    padding-top: max(1.25rem, var(--safe-top));
    padding-bottom: max(1.25rem, var(--safe-bottom));
    overflow-y: auto;
}

.login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.12) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 80%, rgba(29,78,216,0.5) 0%, transparent 60%);
    pointer-events: none;
}

.login-box {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2rem 1.75rem;
    border-radius: 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0,0,0,0.28), 0 0 0 1px rgba(255,255,255,0.15);
    position: relative;
    animation: loginAppear 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes loginAppear {
    from { opacity: 0; transform: translateY(24px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-box .login-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.login-box h1 {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.login-box > p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.login-box .form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.login-box .form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.login-box .form-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    color: var(--gray-900);
    background: var(--gray-50);
}

.login-box .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

.login-box .btn-primary {
    width: 100%;
    margin-top: 0.75rem;
    min-height: 50px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(37,99,235,0.4);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.login-box .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.45);
}

.login-box .btn-primary:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.login-box .error-msg {
    color: var(--danger);
    font-size: 0.84rem;
    margin-top: 0.75rem;
    min-height: 1.2rem;
    font-weight: 500;
}

/* Logo en login */
.login-logo {
    width: 150px;
    height: auto;
    margin: 0 auto 0.75rem;
    display: block;
}

.login-icon {
    margin-bottom: 0.75rem !important;
    padding: 0 !important;
    background: none !important;
    width: auto !important;
    height: auto !important;
    font-size: inherit !important;
}

/* === SPLASH SCREEN === */
#splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splash-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

#splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    color: white;
    padding: 1rem;
    position: relative;
}

.splash-content .logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: splashBounce 1s ease infinite;
}

.splash-content h1 {
    font-size: 1.9rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.splash-content p {
    opacity: 0.85;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes splashBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50%       { transform: translateY(-10px) scale(1.05); }
}

/* === NAVEGACIÓN MOBILE — columna: user-strip arriba, tabs abajo === */
#navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-top: 1px solid rgba(0,0,0,0.07);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 100;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.07);
}

/* — Franja usuario (arriba dentro del navbar móvil) — */
.nav-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    background: rgba(248,250,252,0.8);
    min-height: var(--nav-user-h);
    flex-shrink: 0;
}

.nav-user-nombre {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: var(--primary-light);
    border: 1.5px solid rgba(37,99,235,0.2);
    border-radius: 20px;
    padding: 0.22rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 1;
    min-width: 0;
}

.nav-user-nombre::before {
    content: "👤";
    font-size: 0.8rem;
    flex-shrink: 0;
}

.btn-cambiar-pass,
.btn-logout-nav {
    background: var(--gray-100);
    border: 1.5px solid var(--gray-200);
    color: var(--gray-700);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    line-height: 1;
    min-width: 34px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.btn-cambiar-pass:active { transform: scale(0.93); background: var(--gray-200); }
.btn-logout-nav:active   { transform: scale(0.93); background: #fee2e2; border-color: #fca5a5; }

/* — Fila de tabs — */
.nav-brand {
    display: none;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 0;
    width: 100%;
    justify-content: space-around;
    padding: 0.2rem 0 0;
    padding-bottom: calc(0.2rem + var(--safe-bottom));
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.4rem 0.5rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-400);
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    flex: 1;
    min-height: var(--nav-tabs-h);
    touch-action: manipulation;
    position: relative;
    letter-spacing: 0.01em;
}

.nav-btn::before { font-size: 1.45rem; transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1); }
.nav-btn[data-section="inicio"]::before       { content: "🏠"; }
.nav-btn[data-section="modulos"]::before      { content: "📚"; }
.nav-btn[data-section="cuestionario"]::before { content: "📝"; }
.nav-btn[data-section="progreso"]::before     { content: "📊"; }
.nav-btn[data-section="examen_claves"]::before { content: "📋"; }

.nav-btn:active::before,
.nav-btn.active::before {
    transform: scale(1.18) translateY(-2px);
}

.nav-btn:active,
.nav-btn.active {
    color: var(--primary);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* nav-logo (solo desktop) */
.nav-logo {
    height: 30px;
    width: auto;
    display: block;
}

/* === CONTENIDO PRINCIPAL === */
#main-content {
    padding: 1.1rem;
    padding-bottom: calc(var(--nav-total) + 1rem);
    padding-left: max(1.1rem, var(--safe-left));
    padding-right: max(1.1rem, var(--safe-right));
    max-width: 800px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.28s cubic-bezier(0.16,1,0.3,1);
}

.section.active { display: block; }

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

/* === HERO / INICIO === */
.hero {
    text-align: center;
    padding: 2rem 1.25rem 1.75rem;
    background: linear-gradient(160deg, #1e40af 0%, var(--primary) 50%, #3b82f6 100%);
    border-radius: var(--radius);
    color: white;
    margin-bottom: 1.1rem;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
}

.hero h1 {
    font-size: 1.45rem;
    margin-bottom: 0.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    position: relative;
}

.hero p {
    opacity: 0.88;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    position: relative;
}

/* === BOTONES === */
.btn-primary {
    background: white;
    color: var(--primary);
    border: none;
    padding: 0.8rem 1.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.97rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: inline-block;
    min-height: 48px;
    touch-action: manipulation;
    letter-spacing: 0.01em;
    position: relative;
}

.btn-primary:active  { transform: scale(0.97); }
.btn-primary:hover   { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.97rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-block;
    min-height: 48px;
    touch-action: manipulation;
    margin-left: 0.5rem;
}

.btn-secondary:hover  { background: var(--gray-200); }
.btn-secondary:active { background: var(--gray-300); transform: scale(0.97); }

/* === STATS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.1rem;
}

.stat-card {
    background: white;
    padding: 1rem 0.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--gray-500);
    margin-top: 0.2rem;
    font-weight: 500;
}

/* === INFO CARDS === */
.info-cards {
    display: grid;
    gap: 0.8rem;
}

.info-card {
    background: white;
    padding: 1.1rem 1.1rem 1.1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.info-card:active { transform: scale(0.99); }

.info-icon {
    font-size: 1.7rem;
    margin-bottom: 0.4rem;
}

.info-card h3 {
    font-size: 0.93rem;
    margin-bottom: 0.2rem;
    color: var(--gray-900);
    font-weight: 700;
}

.info-card p {
    font-size: 0.84rem;
    color: var(--gray-500);
    line-height: 1.5;
}

/* === MÓDULOS === */
.section > h2 {
    font-size: 1.25rem;
    margin-bottom: 0.2rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.section-desc {
    color: var(--gray-500);
    margin-bottom: 1.1rem;
    font-size: 0.875rem;
}

.modulos-list {
    display: grid;
    gap: 0.8rem;
}

.modulo-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.18s;
    border: 1.5px solid transparent;
    touch-action: manipulation;
}

.modulo-card:active  { transform: scale(0.98); }
.modulo-card:hover   { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary-light); }

.modulo-card.completado { border-color: var(--success); }

.modulo-card.completado .modulo-status {
    background: var(--success);
    color: white;
}

.modulo-header {
    padding: 1rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.modulo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    border: 1.5px solid rgba(37,99,235,0.12);
}

.modulo-info { flex: 1; min-width: 0; }

.modulo-info h3 {
    font-size: 0.93rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modulo-info p {
    font-size: 0.76rem;
    color: var(--gray-500);
    line-height: 1.4;
}

.modulo-status {
    padding: 0.28rem 0.65rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--gray-100);
    color: var(--gray-500);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.modulo-progress {
    height: 4px;
    background: var(--gray-100);
}

.modulo-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 0 2px 2px 0;
    transition: width 0.5s ease;
}

/* === DETALLE MÓDULO === */
.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 1rem;
    padding: 0.6rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 44px;
    touch-action: manipulation;
}

.modulo-detalle-header {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.modulo-detalle-header h2 {
    font-size: 1.2rem;
    margin-bottom: 0.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.modulo-detalle-header p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.contenido-modulo {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.contenido-modulo h3 {
    font-size: 1.05rem;
    margin: 1.2rem 0 0.5rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.contenido-modulo h3:first-child { margin-top: 0; }

.contenido-modulo p {
    color: var(--gray-700);
    font-size: 0.93rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.contenido-modulo p:empty {
    display: none;
}

.contenido-modulo br + br {
    display: none;
}

.contenido-modulo ul {
    margin-left: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

.contenido-modulo li {
    margin-bottom: 0.25rem;
    font-size: 0.93rem;
    line-height: 1.55;
}

.contenido-modulo .highlight-box {
    background: var(--primary-lighter);
    border-left: 4px solid var(--primary);
    padding: 0.9rem 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 0 0 0.75rem 0;
}

.contenido-modulo .highlight-box p {
    margin-bottom: 0.25rem;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.93rem;
    line-height: 1.45;
}

.contenido-modulo .highlight-box p:last-child {
    margin-bottom: 0;
}

/* === IMÁGENES Y VÍDEOS EN CONTENIDO === */
.content-image-wrapper {
    margin: 1rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.content-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
}

/* Desktop: imagen más pequeña para mejor calidad visual */
@media (min-width: 768px) {
    .content-image-wrapper {
        max-width: 520px;
        margin: 1rem auto;
    }
}

/* === BLOQUE IMAGEN + TEXTO (image-text) === */
/* Móvil: imagen arriba, texto abajo */
.content-image-text {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 1rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.content-image-text-img {
    width: 100%;
    flex-shrink: 0;
}

.content-image-text-img img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    object-fit: cover;
}

/* Desktop: limitar tamaño de imagen en layout image-text */
@media (min-width: 768px) {
    .content-image-text-img {
        max-width: 360px;
    }
}

.content-image-caption {
    font-size: 0.78rem !important;
    color: var(--gray-400) !important;
    text-align: center;
    margin: 0.35rem 0 0 !important;
    font-style: italic;
    line-height: 1.4;
}

.content-image-text-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.content-image-text-body p {
    margin-bottom: 0 !important;
}

.content-image-text-titulo {
    font-size: 0.97rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.4rem 0;
}

/* Desktop (≥ 768px): imagen al lado del texto */
@media (min-width: 768px) {
    .content-image-text {
        flex-direction: row;
        align-items: flex-start;
        gap: 1.25rem;
    }

    .content-image-text-img {
        width: 42%;
        max-width: 340px;
    }

    /* Imagen a la derecha */
    .content-image-text.image-text-right {
        flex-direction: row-reverse;
    }
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    margin: 1rem 0;
    border-radius: var(--radius-sm);
    background: var(--gray-900);
}

.video-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
    border-radius: var(--radius-sm);
}

.video-wrapper-direct {
    margin: 1rem 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-900);
}

.video-wrapper-direct video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-sm);
}

.btn-completar {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    min-height: 52px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-completar:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(37,99,235,0.25); }

.btn-completar.completado {
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
    box-shadow: 0 4px 14px rgba(22,163,74,0.35);
    color: white;
}

/* === IMÁGENES EN PREGUNTAS DE TEST === */
.pregunta-imagen {
    display: block;
    width: 100%;
    max-width: 400px;
    max-height: 220px;
    object-fit: contain;
    margin: 0 auto 1.1rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--gray-200);
    background: var(--gray-50);
}

/* Desktop: pregunta con imagen más grande pero con mejor calidad */
@media (min-width: 768px) {
    .pregunta-imagen {
        max-width: 480px;
        max-height: 280px;
    }
}

/* === CUESTIONARIO === */
.test-selector {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1.25rem;
}

.test-option {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    touch-action: manipulation;
    min-height: 60px;
}

.test-option:hover  { border-color: var(--primary); background: var(--primary-lighter); transform: translateY(-1px); }
.test-option:active { background: var(--primary-light); transform: scale(0.99); }

/* Test bloqueado - módulo no completado o unidades pendientes */
.test-option.test-option-bloqueado {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.85);
    border-color: var(--gray-300);
    background: var(--gray-50);
    pointer-events: none;
    transition: none;
}
.test-option.test-option-bloqueado:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
    transform: none;
}
.test-option.test-option-bloqueado .test-icon {
    filter: grayscale(1);
    opacity: 0.7;
}
.test-option.test-option-bloqueado h4 {
    color: var(--gray-500);
}
.test-option.test-option-bloqueado p {
    color: var(--gray-400);
    font-weight: 600;
}

.test-option .test-icon { font-size: 1.5rem; flex-shrink: 0; }
.test-option h4 { font-size: 0.92rem; font-weight: 700; }

.test-option p {
    font-size: 0.78rem;
    color: var(--gray-500);
}

.test-progress {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.16,1,0.3,1);
    width: 0%;
}

#test-progress-text {
    font-size: 0.76rem;
    color: var(--gray-500);
    white-space: nowrap;
    font-weight: 600;
}

.pregunta-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.pregunta-numero {
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pregunta-texto {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.1rem;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.opciones-list {
    display: grid;
    gap: 0.65rem;
}

.opcion-btn {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.9rem 0.875rem;
    text-align: left;
    font-size: 0.93rem;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s, transform 0.12s;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 54px;
    touch-action: manipulation;
    line-height: 1.4;
    font-weight: 500;
}

.opcion-btn:hover  { border-color: var(--primary); background: var(--primary-lighter); }
.opcion-btn:active { background: var(--primary-light); transform: scale(0.99); }

.opcion-btn.correcta   { border-color: var(--success); background: var(--success-light); }
.opcion-btn.incorrecta { border-color: var(--danger); background: #fee2e2; }
.opcion-btn.opcion-elegida { border-color: #7c3aed; background: #ede9fe; }
.opcion-btn.opcion-elegida .letra { background: #7c3aed; color: white; }

.opcion-btn .letra {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 800;
    flex-shrink: 0;
    transition: background 0.18s;
}

.opcion-btn.correcta  .letra { background: var(--success); color: white; }
.opcion-btn.incorrecta .letra { background: var(--danger); color: white; }

/* === RESULTADO TEST === */
.resultado-card {
    background: white;
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.04);
}

.resultado-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: resultadoAppear 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes resultadoAppear {
    from { transform: scale(0.4) rotate(-20deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.resultado-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.resultado-card p {
    color: var(--gray-500);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.resultado-puntuacion {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 1.5rem;
    letter-spacing: -0.03em;
}

.resultado-card .btn-primary,
.resultado-card .btn-secondary {
    display: block;
    width: 100%;
    margin: 0 0 0.65rem;
}

/* === PROGRESO === */
.progreso-global {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
}

.progreso-circular {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}

.progreso-circular svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.progreso-bg  { fill: none; stroke: var(--gray-200); stroke-width: 8; }
.progreso-fill {
    fill: none;
    stroke: url(#progresoGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1s cubic-bezier(0.16,1,0.3,1);
}

.progreso-texto {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.progreso-info h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.progreso-info p {
    font-size: 0.82rem;
    color: var(--gray-500);
}

.progreso-modulos { display: grid; gap: 0.65rem; }

.progreso-item {
    background: white;
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.15s;
}

.progreso-item:active { transform: scale(0.99); }

.progreso-item-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
    border: 1.5px solid rgba(37,99,235,0.1);
}

.progreso-item-info { flex: 1; min-width: 0; }

.progreso-item-info h4 {
    font-size: 0.84rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
}

.progreso-item-bar {
    height: 5px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progreso-item-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}

.progreso-item-pct {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 35px;
    text-align: right;
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: calc(var(--nav-total) + 12px);
    left: 1rem;
    right: 1rem;
    transform: translateY(60px);
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
    text-align: center;
    max-width: 420px;
    margin: 0 auto;
    border: 1px solid rgba(255,255,255,0.08);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* === BOTÓN INSTALAR === */
.install-btn {
    position: fixed;
    top: calc(1rem + var(--safe-top));
    right: max(1rem, var(--safe-right));
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 150;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s cubic-bezier(0.16,1,0.3,1);
    min-height: 44px;
    touch-action: manipulation;
}

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

/* === MODAL CONTRASEÑA ALUMNO — bottom-sheet en móvil === */
#modal-password-alumno {
    align-items: flex-end !important;
    padding: 0 !important;
}

#modal-password-alumno > div {
    border-radius: 24px 24px 0 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    padding-bottom: calc(1.75rem + var(--safe-bottom)) !important;
    animation: sheetUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15) !important;
}

@keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* Inputs del modal inline: asegurar 16px */
#modal-password-alumno input {
    font-size: 1rem !important;
}

/* === MODAL GENERAL === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    align-items: flex-end;
    justify-content: center;
    z-index: 500;
    padding: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

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

.modal-box {
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 1.5rem 1.5rem calc(1.5rem + var(--safe-bottom));
    width: 100%;
    max-width: 100%;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
    animation: sheetUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-box h3 {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.modal-sub {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1.1rem;
}

.modal-box .form-group {
    margin-bottom: 0.875rem;
    text-align: left;
}

.modal-box .form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-box .form-group input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--gray-900);
    background: var(--gray-50);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.modal-box .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

.error-msg {
    color: var(--danger);
    font-size: 0.83rem;
    margin-top: 0.2rem;
    min-height: 1.2em;
    font-weight: 500;
}

.modal-btns {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.1rem;
}

.modal-btns .btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    min-height: 48px;
    margin-left: 0;
    text-align: center;
    touch-action: manipulation;
}

.modal-btns .btn-secondary:hover  { background: var(--gray-200); }
.modal-btns .btn-secondary:active { background: var(--gray-300); }

.modal-btns .btn-primary {
    width: 100%;
    padding: 0.75rem 1.4rem;
    min-height: 48px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(37,99,235,0.3);
}

/* === RESPONSIVE TABLET / DESKTOP (≥ 768px) === */
@media (min-width: 768px) {

    #navbar {
        position: sticky;
        top: 0;
        bottom: auto;
        border-top: none;
        border-bottom: 1px solid rgba(0,0,0,0.07);
        box-shadow: 0 2px 16px rgba(0,0,0,0.06);
        padding: 0 2rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        height: 64px;
        background: rgba(255,255,255,0.97);
    }

    .nav-brand { display: flex; }

    .nav-links {
        width: auto;
        gap: 0.25rem;
        padding: 0;
    }

    .nav-btn {
        flex-direction: row;
        font-size: 0.875rem;
        padding: 0.5rem 0.875rem;
        min-height: auto;
        flex: none;
        gap: 0.4rem;
        border-radius: var(--radius-sm);
        font-weight: 600;
    }

    .nav-btn::before   { font-size: 1rem; }
    .nav-btn.active    { background: var(--primary-lighter); color: var(--primary); }
    .nav-btn.active::after { display: none; }

    .nav-user {
        justify-content: flex-end;
        border-bottom: none;
        background: transparent;
        padding: 0;
        width: auto;
        min-height: auto;
    }

    .nav-user-nombre { font-size: 0.8rem; max-width: 150px; }

    #main-content {
        padding: 2rem;
        padding-bottom: 2rem;
    }

    .toast {
        bottom: 2rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(60px);
        white-space: nowrap;
        max-width: none;
    }

    .toast.show { transform: translateX(-50%) translateY(0); }

    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .info-cards { grid-template-columns: repeat(3, 1fr); }
    .hero h1    { font-size: 2rem; }
    .hero       { padding: 2.75rem 2rem; }
    .login-logo { width: 190px; }
    .progreso-global { padding: 2rem; }

    .modal-overlay {
        align-items: center;
        padding: 1rem;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .modal-box {
        border-radius: var(--radius);
        max-width: 440px;
        padding: 1.75rem 2rem;
        animation: none;
        box-shadow: var(--shadow-xl);
    }

    .modal-btns {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-btns .btn-secondary,
    .modal-btns .btn-primary {
        width: auto;
    }

    #modal-password-alumno {
        align-items: center !important;
        padding: 1rem !important;
        backdrop-filter: blur(6px) !important;
        -webkit-backdrop-filter: blur(6px) !important;
    }

    #modal-password-alumno > div {
        border-radius: 16px !important;
        max-width: 420px !important;
        padding-bottom: 1.75rem !important;
        animation: none !important;
    }

    .resultado-card .btn-primary,
    .resultado-card .btn-secondary {
        display: inline-block;
        width: auto;
        margin: 0;
    }
    .resultado-card .btn-secondary { margin-left: 0.5rem; }
}

/* === STANDALONE (PWA instalada) === */
@media (display-mode: standalone) {
    body { padding-top: var(--safe-top); }
    .login-screen { padding-top: max(1.25rem, var(--safe-top)); }
    #navbar { padding-bottom: var(--safe-bottom); }
    .nav-links { padding-bottom: calc(0.2rem + var(--safe-bottom)); }
    .install-btn { display: none !important; }
}

/* === EXTRA SMALL — teléfonos muy pequeños (≤ 360px) === */
@media (max-width: 360px) {
    .login-logo  { width: 120px; }
    .login-box   { padding: 1.5rem 1rem; }
    .nav-btn     { font-size: 0.6rem; }
    .nav-btn::before { font-size: 1.25rem; }
    .stats-grid  { gap: 0.4rem; }
    .stat-number { font-size: 1.3rem; }
    .stat-label  { font-size: 0.63rem; }
    .hero h1     { font-size: 1.2rem; }
    .pregunta-texto { font-size: 1rem; }
}

/* === BLOQUE ARTÍCULO === */
.articulo-chip-wrapper {
    margin: 0.75rem 0;
}

.articulo-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1.5px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    font-family: inherit;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(37,99,235,0.12);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.articulo-chip:hover {
    background: #dbeafe;
    border-color: #93c5fd;
    box-shadow: 0 3px 8px rgba(37,99,235,0.2);
}

.articulo-chip:active {
    transform: scale(0.96);
    background: #bfdbfe;
}

/* Badge de reglamento dentro del chip de artículo */
.articulo-chip-reglamento {
    display: inline-block;
    background: #1e40af;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-left: 0.25rem;
    vertical-align: middle;
    line-height: 1.4;
}

/* ══════════════════════════════════════════════
   DESCARGAS
   ══════════════════════════════════════════════ */

.descarga-bloque {
    margin: 0.6rem 0;
}

.descarga-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 10px;
    text-decoration: none;
    color: #15803d;
    font-weight: 600;
    font-size: 0.93rem;
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
    cursor: pointer;
}

.descarga-btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
    box-shadow: 0 3px 10px rgba(22,163,74,0.18);
    transform: translateY(-1px);
}

.descarga-btn:active {
    transform: scale(0.98);
    background: #bbf7d0;
}

.descarga-icono {
    font-size: 1.35rem;
    flex-shrink: 0;
    line-height: 1;
}

.descarga-nombre {
    flex: 1;
    word-break: break-word;
    line-height: 1.35;
}

.descarga-tamano {
    font-size: 0.78rem;
    font-weight: 500;
    color: #6b7280;
    background: #e5e7eb;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    flex-shrink: 0;
    white-space: nowrap;
}

.descarga-arrow {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.75;
}

/* Sección de descargas agrupadas en módulo/unidad */
.descargas-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1.5px solid #e5e7eb;
}

.descargas-section-titulo {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6b7280;
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

@media (max-width: 480px) {
    .descarga-btn {
        padding: 0.75rem 0.85rem;
        font-size: 0.88rem;
        gap: 0.6rem;
    }
    .descarga-icono { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════════════
   EXAMEN DE CLAVES — estilos (sección #examen_claves)
   ═══════════════════════════════════════════════════ */
#examen_claves { padding: 0; }
#examen_claves .screen { display: none; min-height: 100dvh; }
#examen_claves .screen.active { display: flex; flex-direction: column; }

/* LOGIN */
#ec-login-screen {
  background: linear-gradient(160deg,#1e40af 0%,#2563eb 50%,#3b82f6 100%);
  align-items: center; justify-content: center;
  padding: max(2rem,env(safe-area-inset-top)) 1.25rem max(2rem,env(safe-area-inset-bottom));
}
.ec-login-box {
  background: rgba(255,255,255,.97); backdrop-filter: blur(20px);
  padding: 2.25rem 2rem; border-radius: 24px; width: 100%; max-width: 400px;
  text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,.28);
  animation: ecAppear .45s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes ecAppear { from{opacity:0;transform:translateY(24px) scale(.95)} to{opacity:1;transform:none} }
.ec-login-box h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .35rem; }
.ec-login-box p { color: var(--gray-500,#64748b); font-size: .875rem; margin-bottom: 1.5rem; }
.ec-form-group { margin-bottom: 1rem; text-align: left; }
.ec-form-group label { display: block; font-size: .72rem; font-weight: 700; color: var(--gray-700,#334155); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .04em; }
.ec-form-group input { width: 100%; padding: .85rem 1rem; border: 2px solid var(--gray-200,#e2e8f0); border-radius: 10px; background: var(--gray-50,#f8fafc); color: var(--gray-900,#0f172a); transition: border-color .2s,box-shadow .2s; font-size: 1rem !important; font-family: inherit; -webkit-appearance: none; }
.ec-form-group input:focus { outline: none; border-color: var(--primary,#2563eb); background: #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.ec-btn-primary { width: 100%; background: linear-gradient(135deg,#2563eb 0%,#1d4ed8 100%); color: #fff; border: none; padding: .85rem 1.5rem; border-radius: 10px; font-size: .97rem; font-weight: 700; min-height: 50px; box-shadow: 0 4px 14px rgba(37,99,235,.35); transition: transform .15s,box-shadow .15s; cursor: pointer; font-family: inherit; touch-action: manipulation; }
.ec-btn-primary:active { transform: scale(.97); }
.ec-btn-secondary { background: var(--gray-100,#f1f5f9); color: var(--gray-700,#334155); border: 1.5px solid var(--gray-200,#e2e8f0); padding: .65rem 1.2rem; border-radius: 10px; font-size: .9rem; font-weight: 600; min-height: 42px; transition: all .15s; cursor: pointer; font-family: inherit; }
.ec-error-msg { color: #dc2626; font-size: .85rem; margin-top: .75rem; min-height: 1.2em; }

/* SALA DE ESPERA */
#ec-sala-screen { align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.ec-sala-box { background: #fff; border-radius: 20px; padding: 2rem 1.5rem; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.1); }
.ec-sala-box .ec-icon-big { font-size: 3rem; margin-bottom: 1rem; }
.ec-sala-box h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .5rem; }
.ec-sala-box p { color: var(--gray-500,#64748b); font-size: .9rem; margin-bottom: 1.5rem; }
.ec-sala-alumno-info { background: #dbeafe; border-radius: 12px; padding: 1rem; margin-bottom: 1rem; text-align: left; }
.ec-sala-alumno-info span { font-size: .75rem; color: #1d4ed8; font-weight: 600; display: block; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .04em; }
.ec-sala-alumno-info strong { font-size: 1.1rem; color: #1d4ed8; font-weight: 800; }
.ec-pulse-dot { width: 12px; height: 12px; border-radius: 50%; background: #ef4444; display: inline-block; animation: ecPulseDot 1.6s infinite; margin-right: .5rem; vertical-align: middle; }
@keyframes ecPulseDot { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.5);opacity:.5} }
.ec-waiting-spinner { width: 40px; height: 40px; border: 3px solid #e2e8f0; border-top-color: #2563eb; border-radius: 50%; animation: ecSpin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes ecSpin { to{transform:rotate(360deg)} }

/* HEADER EXAMEN */
.ec-exam-header { background: #2563eb; color: #fff; padding: calc(.85rem + env(safe-area-inset-top)) 1rem .85rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 100; }
.ec-exam-header-info { flex: 1; }
.ec-exam-header h2 { font-size: 1rem; font-weight: 800; color: #fff; }
.ec-exam-header-sub { font-size: .72rem; opacity: .75; margin-top: 2px; }
.ec-badge-session { background: rgba(255,255,255,.2); border-radius: 20px; padding: .25rem .75rem; font-size: .75rem; font-weight: 700; white-space: nowrap; }

/* EXAMEN BODY */
#ec-examen-screen { flex-direction: column; }
.ec-exam-body { flex: 1; padding: 1rem; overflow-y: auto; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.ec-examinador-bar { background: #fff; border: 2px solid #e2e8f0; border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.ec-examinador-bar .ec-label { font-size: .7rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.ec-examinador-bar .ec-value { font-size: .9rem; font-weight: 700; color: #0f172a; flex: 1; }
.ec-no-apto { background: #dc2626; color: #fff; font-size: .7rem; font-weight: 800; padding: .25rem .6rem; border-radius: 6px; text-transform: uppercase; }
.ec-tiempo { background: #f1f5f9; border: 1.5px solid #e2e8f0; padding: .25rem .6rem; border-radius: 6px; font-size: .75rem; font-weight: 700; color: #334155; }
.ec-faltas-box { background: #fff; border: 2px solid #e2e8f0; border-radius: 12px; padding: 1rem; margin-bottom: 1rem; min-height: 80px; }
.ec-faltas-box .ec-faltas-label { font-size: .7rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem; }
.ec-faltas-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.ec-falta-tag { background: #fee2e2; color: #dc2626; border: 1.5px solid #dc2626; padding: .35rem .6rem; border-radius: 8px; font-size: .8rem; font-weight: 700; display: flex; align-items: center; gap: .35rem; animation: ecTagIn .3s ease; }
@keyframes ecTagIn { from{opacity:0;transform:scale(.8)} to{opacity:1;transform:scale(1)} }
.ec-falta-tag .ec-remove-btn { background: none; border: none; color: #dc2626; font-size: 1rem; font-weight: 800; cursor: pointer; padding: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.ec-grupos-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: .5rem; margin-bottom: 1rem; }
.ec-grupo-btn { background: linear-gradient(135deg,#3b82f6 0%,#2563eb 100%); color: #fff; border: none; border-radius: 10px; padding: .6rem .2rem; font-size: .95rem; font-weight: 800; min-height: 52px; display: flex; align-items: center; justify-content: center; transition: all .15s; box-shadow: 0 2px 8px rgba(37,99,235,.25); flex-direction: column; gap: 2px; cursor: pointer; touch-action: manipulation; font-family: inherit; }
.ec-grupo-btn:active { transform: scale(.93); }
.ec-grupo-btn .ec-g-num { font-size: 1.05rem; font-weight: 900; line-height: 1; }
.ec-grupo-btn .ec-g-badge { background: rgba(255,255,255,.35); border-radius: 10px; font-size: .62rem; font-weight: 800; padding: 1px 5px; display: none; }
.ec-acciones-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.ec-btn-accion { padding: .85rem; border-radius: 12px; font-size: .9rem; font-weight: 700; min-height: 52px; transition: all .15s; display: flex; align-items: center; justify-content: center; gap: .4rem; border: none; cursor: pointer; font-family: inherit; touch-action: manipulation; }
.ec-btn-accion:active { transform: scale(.97); }
.ec-btn-corregir { background: #f59e0b; color: #fff; box-shadow: 0 4px 12px rgba(245,158,11,.3); }
.ec-btn-finalizar { background: #16a34a; color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.3); }

/* ENTREGADO */
#ec-entregado-screen { align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.ec-entregado-box { background: #fff; border-radius: 20px; padding: 2rem 1.5rem; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.1); }
.ec-nota-badge { display: inline-block; padding: .5rem 1.5rem; border-radius: 50px; font-size: 1.6rem; font-weight: 900; margin: 1rem 0; }
.ec-nota-badge.aprobado { background: #dcfce7; color: #16a34a; }
.ec-nota-badge.suspenso { background: #fee2e2; color: #dc2626; }
.ec-nota-badge.pendiente { background: #dbeafe; color: #1d4ed8; }
.ec-nota-badge.apto    { background: #dcfce7; color: #16a34a; border: 2px solid #86efac; }
.ec-nota-badge.no-apto { background: #fee2e2; color: #dc2626; border: 2px solid #fca5a5; }

/* TOAST */
.ec-toast { position: fixed; bottom: calc(1.25rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(60px); background: #0f172a; color: #fff; padding: .75rem 1.25rem; border-radius: 12px; font-size: .875rem; font-weight: 500; white-space: nowrap; opacity: 0; transition: all .3s; z-index: 9999; pointer-events: none; }
.ec-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* MODALES */
.ec-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); align-items: flex-end; justify-content: center; z-index: 9999; padding: 0; }
.ec-modal-overlay.open { display: flex; }
.ec-modal-sheet { background: #fff; border-radius: 20px 20px 0 0; width: 100%; max-width: 520px; padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); animation: ecSlideUp .3s ease both; max-height: 85vh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@keyframes ecSlideUp { from{transform:translateY(60px);opacity:0} to{transform:none;opacity:1} }
.ec-modal-sheet h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: .3rem; }
.ec-modal-sheet .ec-modal-sub { color: #64748b; font-size: .875rem; margin-bottom: 1.25rem; }
.ec-modal-actions { display: flex; gap: .75rem; flex-direction: column; }
.ec-tipos-falta-grid { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ec-tipo-falta-btn { flex: 1; min-width: 100px; background: #f1f5f9; color: #334155; border: 2px solid #e2e8f0; border-radius: 10px; padding: .6rem .4rem; font-size: .85rem; font-weight: 700; text-align: center; cursor: pointer; transition: all .15s; touch-action: manipulation; font-family: inherit; }
.ec-tipo-falta-btn:active { transform: scale(.97); }
.ec-tipo-falta-btn.seleccionada { color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.ec-tipo-falta-btn.leve.seleccionada { background: #16a34a; }
.ec-tipo-falta-btn.deficiente.seleccionada { background: #d97706; }
.ec-tipo-falta-btn.eliminitoria.seleccionada { background: #dc2626; }
.ec-falta-tag .ec-tipo-indicador { font-size: .65rem; text-transform: uppercase; padding: .15rem .35rem; border-radius: 4px; font-weight: 800; margin-left: .3rem; letter-spacing: .02em; }
.ec-falta-tag .ec-tipo-indicador.leve { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.ec-falta-tag .ec-tipo-indicador.deficiente { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.ec-falta-tag .ec-tipo-indicador.eliminitoria { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.ec-subclaves-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; max-height: 50vh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: .5rem; }
.ec-subclave-btn { background: linear-gradient(135deg,#3b82f6 0%,#2563eb 100%); color: #fff; border: none; border-radius: 12px; padding: .85rem 1rem; font-size: .97rem; font-weight: 700; text-align: left; min-height: 52px; transition: all .15s; box-shadow: 0 2px 8px rgba(37,99,235,.2); display: flex; align-items: center; gap: .5rem; cursor: pointer; touch-action: manipulation; font-family: inherit; }
.ec-subclave-btn:active { transform: scale(.97); }
.ec-subclave-btn.seleccionada { background: linear-gradient(135deg,#dc2626 0%,#b91c1c 100%); box-shadow: 0 2px 8px rgba(220,38,38,.25); }
.ec-subclave-btn .ec-check-icon { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .7rem; transition: all .2s; }
.ec-subclave-btn.seleccionada .ec-check-icon { background: #fff; border-color: #fff; color: #dc2626; }
.ec-obs-section { margin-bottom: 1.25rem; }
.ec-obs-section label { display: block; font-size: .72rem; font-weight: 700; color: #334155; margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .04em; }
.ec-obs-section textarea { width: 100%; padding: .85rem 1rem; border: 2px solid #e2e8f0; border-radius: 10px; background: #f8fafc; color: #0f172a; resize: none; min-height: 90px; font-size: .9rem; line-height: 1.5; transition: border-color .2s,box-shadow .2s; font-family: inherit; }
.ec-obs-section textarea:focus { outline: none; border-color: #2563eb; background: #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.ec-corregir-lista { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
@media (max-width: 360px) { .ec-grupos-grid { grid-template-columns: repeat(4,1fr); } .ec-grupo-btn { font-size: .85rem; min-height: 46px; } }

/* ════════════════════════════════════════════════════
   FIX RESPONSIVE PROGRESO — solo lo necesario
   Previene desbordamiento horizontal en móvil sin
   alterar el diseño original
   ════════════════════════════════════════════════════ */

/* Contenedor principal sin overflow */
#main-content {
    overflow-x: hidden;
    box-sizing: border-box;
}

/* La sección progreso y todo lo que renderiza app.js */
#progreso,
#progreso-modulos-list {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Cada tarjeta de módulo generada dinámicamente */
#progreso-modulos-list > div,
.progreso-item {
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 0;
}

/* Títulos de módulo que se cortaban a la derecha */
#progreso-modulos-list h3,
#progreso-modulos-list h4,
#progreso-modulos-list strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

/* Sub-items (1.1 De realización diaria, etc.) */
#progreso-modulos-list span,
#progreso-modulos-list p,
#progreso-modulos-list small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* Filas flex internas — que no empujen hacia afuera */
#progreso-modulos-list [style*="display: flex"],
#progreso-modulos-list [style*="display:flex"] {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Cualquier hijo directo con flex que tenga texto */
#progreso-modulos-list [style*="flex: 1"],
#progreso-modulos-list [style*="flex:1"] {
    min-width: 0;
    overflow: hidden;
}

/* Barras de progreso internas */
#progreso-modulos-list [style*="background"][style*="border-radius"] {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Botones "Ver historial completo" */
#progreso-modulos-list button,
.progreso-item button {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* progreso-info necesita min-width:0 para que el flex no se desborde */
.progreso-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* ════════════════════════════════════════════════════
   FIX RESPONSIVE PROGRESO — previene desbordamiento
   horizontal en móvil sin alterar el diseño original
   ════════════════════════════════════════════════════ */
#main-content {
    overflow-x: hidden;
    box-sizing: border-box;
}
#progreso,
#progreso-modulos-list {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
#progreso-modulos-list > div,
.progreso-item {
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 0;
}
#progreso-modulos-list h3,
#progreso-modulos-list h4,
#progreso-modulos-list strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}
#progreso-modulos-list span,
#progreso-modulos-list p,
#progreso-modulos-list small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
#progreso-modulos-list [style*="display: flex"],
#progreso-modulos-list [style*="display:flex"] {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
#progreso-modulos-list [style*="flex: 1"],
#progreso-modulos-list [style*="flex:1"] {
    min-width: 0;
    overflow: hidden;
}
#progreso-modulos-list button,
.progreso-item button {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.progreso-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
