/* ═══════════════════════════════════════════════════════════
   Práctica ICFES — Design System v3 (Premium)
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-deep: #070b14;
    --bg: #0c1222;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-glass: rgba(255, 255, 255, 0.92);
    --border: rgba(148, 163, 184, 0.35);
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.45);
    --accent: #22d3ee;
    --accent-2: #a78bfa;
    --success: #10b981;
    --success-soft: #ecfdf5;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --warning: #f59e0b;
    --warning-soft: #fffbeb;
    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #22d3ee 100%);
    --gradient-surface: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow: 0 12px 40px -8px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 24px 64px -16px rgba(15, 23, 42, 0.2);
    --shadow-glow: 0 0 0 1px rgba(255,255,255,0.06), 0 20px 50px -12px rgba(99, 102, 241, 0.25);
    --radius-xs: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --font: "Plus Jakarta Sans", system-ui, sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg-deep);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(99, 102, 241, 0.25);
    color: var(--text);
}

/* ── Ambient background ── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 100% 80% at 0% -20%, rgba(99, 102, 241, 0.22), transparent 55%),
        radial-gradient(ellipse 80% 60% at 100% 0%, rgba(34, 211, 238, 0.12), transparent 50%),
        radial-gradient(ellipse 70% 50% at 50% 100%, rgba(139, 92, 246, 0.1), transparent 55%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent);
    pointer-events: none;
    z-index: 0;
}

body > * { position: relative; z-index: 1; }

/* ── Layout ── */
.container {
    width: min(1140px, 92%);
    margin: 0 auto;
    padding: 28px 0 56px;
}

/* ── Typography ── */
h1, h2, h3, h4 {
    margin-top: 0;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: var(--text);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 700; }

p { margin: 0 0 1rem; }

.text-gradient {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hint, .subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 0;
    line-height: 1.5;
}

.empty {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
    font-size: 0.95rem;
}

/* ── Cards ── */
.card {
    background: var(--gradient-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(22px, 4vw, 32px);
    box-shadow: var(--shadow), var(--shadow-xs);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
}

.card-header {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 { margin-bottom: 6px; }

/* ── Topbar ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glow);
    margin-bottom: 28px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    flex-shrink: 0;
    position: relative;
}

/* Logo institucional (imagen) */
.brand-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
}

.brand-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-logo-wrap--xs {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    padding: 3px;
}

.brand-logo-wrap--sm {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    padding: 4px;
    box-shadow: 0 6px 20px var(--primary-glow);
    position: relative;
}

.brand-logo-wrap--md {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    padding: 5px;
    position: relative;
}

.brand-logo-wrap--lg {
    width: 108px;
    height: 108px;
    border-radius: 22px;
    padding: 10px;
    margin-bottom: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.brand-logo-wrap--sm::after,
.brand-logo-wrap--md::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: var(--gradient-brand);
    opacity: 0.2;
    filter: blur(6px);
    z-index: -1;
}

.brand-logo--xs { width: 30px; height: 30px; object-fit: contain; }
.brand-logo--sm,
.brand-logo--md,
.brand-logo--lg {
    width: 100%;
    height: 100%;
}

.topbar h1 {
    font-size: 1.0625rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar .subtitle {
    font-size: 0.8125rem;
    margin: 2px 0 0;
    color: var(--text-secondary);
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-xl);
    margin-bottom: 28px;
}

.menu h1 { font-size: 1.0625rem; margin: 0; }

/* ── Forms ── */
label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

input, textarea, select {
    width: 100%;
    padding: 13px 16px;
    margin: 0 0 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input::placeholder, textarea::placeholder {
    color: #94a3b8;
}

input:hover, textarea:hover, select:hover {
    border-color: #94a3b8;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

textarea { min-height: 110px; resize: vertical; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.form-actions-center { justify-content: center; }

/* ── Buttons ── */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: 0 4px 16px var(--primary-glow);
    position: relative;
    overflow: hidden;
}

button::before, .btn:not(.btn-light):not(.btn-ghost):not(.btn-danger)::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--primary-glow);
    filter: brightness(1.05);
}

button:active, .btn:active { transform: translateY(0); }

.btn-danger {
    background: linear-gradient(135deg, #f87171, #dc2626);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-danger::before { display: none; }

.btn-light {
    background: #fff;
    color: var(--text);
    border: 1.5px solid var(--border-strong);
    box-shadow: var(--shadow-xs);
}

.btn-light::before { display: none; }

.btn-light:hover {
    background: var(--surface-2);
    box-shadow: var(--shadow-sm);
    filter: none;
}

.btn-ghost {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: none;
}

.btn-ghost::before { display: none; }

.btn-ghost:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
    filter: none;
}

.card .btn-ghost,
.score-card .btn-ghost {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1.5px solid var(--border-strong);
}

.card .btn-ghost:hover,
.score-card .btn-ghost:hover {
    background: #f1f5f9;
    color: var(--text);
    filter: none;
}

.btn-sm { padding: 8px 16px; font-size: 0.8125rem; border-radius: var(--radius-xs); }

.actions-icons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    vertical-align: middle;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--text-secondary);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform 0.2s var(--ease), background 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.btn-icon i {
    font-size: 16px;
    line-height: 1;
    color: inherit;
}

.btn-icon:hover {
    transform: translateY(-1px);
    background: var(--surface-2);
    color: var(--text);
    filter: none;
    box-shadow: var(--shadow-sm);
}

.btn-icon:active { transform: translateY(0); }

.btn-icon--primary {
    color: #fff;
    border-color: transparent;
    background: var(--gradient-brand);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-icon--primary:hover {
    color: #fff;
    background: var(--gradient-brand);
    filter: brightness(1.08);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-icon--danger {
    color: #dc2626;
    border-color: #fecaca;
    background: var(--danger-soft);
}

.btn-icon--danger:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.btn-icon--success {
    color: #059669;
    border-color: #a7f3d0;
    background: var(--success-soft);
}

.btn-icon--success:hover {
    background: #d1fae5;
    color: #047857;
}

.btn-icon--ghost {
    color: var(--text-muted);
    background: var(--surface-2);
}

.btn-icon--ghost:hover {
    color: var(--text);
    background: #f1f5f9;
}

/* ── Alerts ── */
.alerta {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alerta-error {
    background: var(--danger-soft);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alerta-success {
    background: var(--success-soft);
    color: #047857;
    border: 1px solid #a7f3d0;
}

/* ══ AUTH ══ */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-shell {
    width: min(1000px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    animation: scaleIn 0.5s var(--ease) backwards;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-brand {
    padding: clamp(36px, 6vw, 56px);
    background: linear-gradient(160deg, #1e1b4b 0%, #312e81 35%, #4f46e5 70%, #0e7490 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-brand::before {
    content: "";
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.25), transparent 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.auth-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
    pointer-events: none;
}

.auth-brand .brand-logo-wrap--lg {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.auth-brand .brand-logo-wrap--lg::after { display: none; }

.auth-form-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.auth-form-brand .brand-logo-wrap--md {
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
}

.auth-form-brand strong {
    display: block;
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.35;
}

.auth-form-brand span {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.auth-brand h1 {
    color: #fff;
    font-size: clamp(1.75rem, 3.5vw, 2.25rem);
    margin-bottom: 14px;
    position: relative;
}

.auth-brand > p {
    color: rgba(255,255,255,0.88);
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 32px;
    max-width: 340px;
    position: relative;
}

.auth-stats {
    display: flex;
    gap: 24px;
    margin-top: 8px;
    position: relative;
}

.auth-stat strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
}

.auth-stat span {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-features {
    list-style: none;
    padding: 0;
    margin: 28px 0 0;
    position: relative;
}

.auth-features li {
    padding: 10px 0 10px 32px;
    position: relative;
    color: rgba(255,255,255,0.92);
    font-size: 0.9375rem;
    font-weight: 500;
}

.auth-features li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: rgba(34, 211, 238, 0.2);
    border: 1px solid rgba(34, 211, 238, 0.5);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2367e8f9' stroke-width='3'%3E%3Cpath d='M5 12l5 5L19 7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.auth-form-wrap {
    padding: clamp(32px, 5vw, 48px);
    background: #fff;
}

.auth-form-wrap h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.auth-form-wrap .hint { margin-bottom: 28px; }

.auth-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 32px 28px; }
    .auth-stats { gap: 16px; }
}

/* ══ PAGE HERO ══ */
.page-hero {
    text-align: center;
    margin-bottom: 40px;
    padding: 0 16px;
}

.page-hero .eyebrow {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #c7d2fe;
    margin-bottom: 16px;
}

.page-hero h1 {
    color: #fff;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    margin-bottom: 12px;
    text-shadow: 0 2px 24px rgba(0,0,0,0.2);
}

.page-hero p {
    color: rgba(255,255,255,0.72);
    max-width: 480px;
    margin: 0 auto;
    font-size: 1.05rem;
}

/* ══ MATERIA CARDS ══ */
.materia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.materia-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--gradient-surface);
    padding: 26px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
    position: relative;
    overflow: hidden;
}

.materia-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity 0.3s;
}

.materia-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 3px;
    background: var(--gradient-brand);
    border-radius: 0 0 4px 4px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s var(--ease-spring);
}

.materia-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg), 0 0 40px -8px var(--primary-glow);
    border-color: rgba(99, 102, 241, 0.3);
}

.materia-card:hover::after { transform: scaleX(1); }

.materia-card > * { position: relative; z-index: 1; }

.materia-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.materia-card h3 { margin-bottom: 0; font-size: 1.2rem; }

.materia-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex: 1;
    margin: 0;
    line-height: 1.55;
}

.materia-card .card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.materia-card .arrow {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 50%;
    font-weight: 700;
    transition: transform 0.25s var(--ease-spring), background 0.2s;
}

.materia-card:hover .arrow {
    transform: translateX(4px);
    background: var(--primary);
    color: #fff;
}

/* ══ ADMIN ══ */
.grid-2 {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(380px, 1.55fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

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

@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }

.materia-list { margin-top: 8px; }

.materia-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    background: #fff;
    transition: all 0.2s var(--ease);
}

.materia-item:hover {
    border-color: #a5b4fc;
    box-shadow: var(--shadow-sm);
}

.materia-item.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.materia-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.breadcrumb {
    font-size: 0.875rem;
    margin-bottom: 18px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb a:hover { text-decoration: underline; }

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 12px;
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    margin: 0;
}

/* ══ TABLE ══ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-top: 16px;
    background: #fff;
}

.table-wrap td.actions-icons {
    white-space: nowrap;
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th {
    background: var(--surface-2);
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.15s; }

tbody tr:hover td { background: #fafbfc; }

/* ══ BADGES ══ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: #eef2ff;
    color: #4338ca;
}

.badge-time {
    background: #fff7ed;
    color: #c2410c;
}

/* ══ QUIZ ══ */
.quiz-progress-wrap {
    margin-bottom: 20px;
}

.quiz-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
}

.quiz-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--gradient-brand);
    border-radius: 999px;
    transition: width 0.4s var(--ease);
    box-shadow: 0 0 12px var(--primary-glow);
}

.quiz-mode .timer-panel {
    background: var(--gradient-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 22px 26px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

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

.timer-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

#timer-display {
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.timer-bar {
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: var(--gradient-brand);
    border-radius: 999px;
    transition: width 1s linear;
    box-shadow: 0 0 16px var(--primary-glow);
}

.timer-fill.urgente {
    background: linear-gradient(90deg, #fbbf24, #ef4444);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
}

.timer-text { display: none; }

.pregunta-step {
    animation: fadeUp 0.35s var(--ease) backwards;
}

.pregunta-step h3 {
    font-size: 1.2rem;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.pregunta-num {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    background: #eef2ff;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.opcion { margin-bottom: 12px; }

.opcion label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
    margin: 0;
    transition: all 0.2s var(--ease);
}

.opcion label:hover {
    border-color: #a5b4fc;
    background: #fafbff;
    transform: translateX(4px);
}

.opcion input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.opcion label::before {
    content: "";
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s var(--ease);
}

.opcion label:has(input:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, #faf5ff 0%, #eef2ff 100%);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
    transform: translateX(0);
}

.opcion label:has(input:checked)::before {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: inset 0 0 0 4px #fff;
}

.opcion input:disabled + span,
.opcion label:has(input:disabled) {
    opacity: 0.65;
    cursor: not-allowed;
}

.quiz-nav {
    margin-top: 28px;
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

#quiz-fin .materia-card-icon {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: var(--success);
    font-size: 1.5rem;
}

/* ══ RESULTS ══ */
.section-title-light {
    color: rgba(255,255,255,0.9);
    font-size: 1rem;
    font-weight: 700;
    margin: 36px 0 18px;
    letter-spacing: -0.02em;
}

.score-card {
    text-align: center;
    padding: 40px 32px;
}

.score-ring {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin: 0 auto 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: conic-gradient(from 0deg, var(--primary) 0%, var(--accent) calc(var(--pct) * 1%), #e2e8f0 calc(var(--pct) * 1%));
    position: relative;
    box-shadow: 0 0 40px var(--primary-glow);
}

.score-ring::before {
    content: "";
    position: absolute;
    inset: 10px;
    background: #fff;
    border-radius: 50%;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.04);
}

.score-ring span {
    position: relative;
    z-index: 1;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.score-ring small {
    position: relative;
    z-index: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.score-tier {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 20px;
}

.score-tier.excellent { background: #ecfdf5; color: #047857; }
.score-tier.good { background: #eff6ff; color: #1d4ed8; }
.score-tier.improve { background: #fff7ed; color: #c2410c; }

.score-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 28px 0;
}

@media (max-width: 720px) {
    .score-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
    .score-stats { grid-template-columns: 1fr; }
}

.stat-box {
    padding: 20px 16px;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: transform 0.2s var(--ease);
}

.stat-box:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.stat-box strong {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.stat-box span {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.result-message {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.correcta { color: var(--success); font-weight: 700; }
.incorrecta { color: var(--danger); font-weight: 700; }

.result-item {
    border-left: 4px solid var(--border);
    transition: box-shadow 0.2s;
}

.result-item:hover { box-shadow: var(--shadow); }

.result-item.correct { border-left-color: var(--success); }
.result-item.incorrect { border-left-color: var(--danger); }

.result-item.skipped {
    border-left-color: var(--warning);
}

.badge-skip {
    background: #fff7ed;
    color: #c2410c;
}

.result-skip {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.feedback-box {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 0.9375rem;
}

.pregunta-bloqueada .opcion label {
    cursor: not-allowed;
}

.lock-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 16px 0 0;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-xs);
    border-left: 3px solid var(--border-strong);
}

.lock-hint.locked {
    color: #4338ca;
    background: #eef2ff;
    border-left-color: var(--primary);
    font-weight: 600;
}

/* ══ Admin resultados ══ */
.admin-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-nav a {
    padding: 10px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    transition: background 0.2s, color 0.2s;
}

.admin-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.admin-nav a.active {
    background: var(--surface);
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.admin-filters select {
    width: auto;
    min-width: 160px;
    margin: 0;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card canvas {
    max-height: 280px;
    margin-top: 12px;
}

.chart-card h2 {
    font-size: 1.1rem;
    margin-bottom: 0;
}

.grado-selector-bar {
    margin-bottom: 22px;
}

.grado-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.grado-chip {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    transition: all 0.2s var(--ease);
}

.grado-chip:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.grado-chip.active {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.grado-chip-add {
    border-style: dashed;
    color: var(--primary);
}

.pregunta-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.materia-tag {
    display: inline-block;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary-dark);
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8125rem;
    margin-bottom: 16px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

/* ══ IMÁGENES ══ */
.label-hint {
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.upload-box input[type="file"] {
    padding: 16px;
    background: var(--surface-2);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}

.upload-hint { margin-top: -10px; margin-bottom: 22px; font-size: 0.8125rem; }

.upload-preview {
    margin-top: 12px;
    padding: 14px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.upload-preview img {
    display: block;
    max-width: 100%;
    max-height: 160px;
    border-radius: var(--radius-xs);
    margin-bottom: 10px;
    object-fit: contain;
}

.check-remove {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    color: var(--danger);
    cursor: pointer;
    margin: 0;
}

.check-remove input { width: auto; margin: 0; }

.pregunta-imagenes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.img-pregunta {
    margin: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.img-pregunta figcaption {
    padding: 12px 16px;
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.img-pregunta-guia figcaption {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4338ca;
}

.img-pregunta-ayuda figcaption {
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    color: #c2410c;
}

.img-pregunta a { display: block; padding: 14px; }

.img-pregunta img {
    display: block;
    width: 100%;
    max-height: 340px;
    object-fit: contain;
    border-radius: var(--radius-xs);
    transition: transform 0.3s var(--ease);
}

.img-pregunta a:hover img { transform: scale(1.015); }

/* ══ FOOTER ══ */
.site-footer {
    text-align: center;
    padding: 28px 16px 12px;
    margin-top: 20px;
}

.footer-brand {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.footer-brand .brand-logo-wrap--xs {
    width: 44px;
    height: 44px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.95);
}

.footer-brand p {
    margin: 0;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.5;
}

.footer-brand strong {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
}

/* ══ UTILITIES ══ */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

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

.topbar, .card, .materia-card, .timer-panel, .auth-shell {
    animation: fadeUp 0.45s var(--ease) backwards;
}

.materia-grid .materia-card:nth-child(1) { animation-delay: 0.05s; }
.materia-grid .materia-card:nth-child(2) { animation-delay: 0.1s; }
.materia-grid .materia-card:nth-child(3) { animation-delay: 0.15s; }
.materia-grid .materia-card:nth-child(4) { animation-delay: 0.2s; }
.materia-grid .materia-card:nth-child(5) { animation-delay: 0.25s; }
.materia-grid .materia-card:nth-child(6) { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
