:root { --accent: #0d6efd; --nav-bg: #0d3b66; --radius: .6rem; }
html[data-size="small"] { font-size: 14px; }
html[data-size="large"] { font-size: 18px; }
html[data-size="xlarge"] { font-size: 21px; }
body { background: #f4f6fb; }
.app-nav { background: var(--nav-bg); }
.card { border-radius: var(--radius); border: 0; }
.card.border-success, .card.border-primary { border: 1px solid !important; }
.btn { border-radius: var(--radius); }
.course-card { transition: transform .15s, box-shadow .15s; }
.course-card:hover { transform: translateY(-3px); box-shadow: 0 .5rem 1.2rem rgba(0,0,0,.12) !important; }
.stat { text-align: center; }
.stat .bi { font-size: 1.8rem; }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.login-card { margin-top: 2rem; }
.quiz-choice { padding: .5rem .75rem .5rem 2.2rem; border: 1px solid #dee2e6; border-radius: var(--radius); }
.quiz-choice:hover { background: #eef4ff; }
.quiz-choice label { display: block; cursor: pointer; }
.form-control, .form-select { padding: .6rem .8rem; }

/* Públicos: niños (colorido y redondeado), adultos mayores (letra grande y contraste) */
body[data-audience="CHILD"] { --accent: #ff7a00; --nav-bg: #7b2ff7; --radius: 1.1rem; background: #fff8e8; }
body[data-audience="CHILD"] .btn-primary { background: #ff7a00; border-color: #ff7a00; }
body[data-audience="CHILD"] .btn-outline-primary { color: #ff7a00; border-color: #ff7a00; }
body[data-audience="CHILD"] .btn-outline-primary:hover { background: #ff7a00; color: #fff; }
body[data-audience="CHILD"] h1, body[data-audience="CHILD"] h2 { color: #7b2ff7; }
body[data-audience="YOUTH"] { --nav-bg: #14213d; }
html[data-contrast="high"] body { background: #000; color: #fff; }
html[data-contrast="high"] .card, html[data-contrast="high"] .list-group-item, html[data-contrast="high"] .table,
html[data-contrast="high"] .card-header { background: #000 !important; color: #fff !important; border: 1px solid #fff !important; }
html[data-contrast="high"] a:not(.btn) { color: #ffe600 !important; }
html[data-contrast="high"] .text-muted { color: #ddd !important; }
html[data-contrast="high"] .form-control, html[data-contrast="high"] .form-select { background: #000; color: #fff; border: 2px solid #fff; }
html[data-contrast="high"] .nav-tabs .nav-link.active { background: #ffe600; color: #000 !important; }
@media print { .app-nav, footer, .btn { display: none !important; } }

/* ===== Panel de administración personalizado ===== */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 250px; flex: 0 0 250px; background: linear-gradient(180deg, #0b2545, #13315c); color: #cfe0f5; padding: 1rem .75rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; text-decoration: none; padding: .5rem .75rem 1rem; font-size: 1.05rem; }
.admin-brand img { border-radius: .7rem; background: #fff; }
.admin-section { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; color: #8da9c4; padding: .9rem .75rem .3rem; }
.admin-menu a { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; margin-bottom: .15rem; color: #cfe0f5; text-decoration: none; border-radius: .55rem; }
.admin-menu a:hover { background: rgba(255,255,255,.1); color: #fff; }
.admin-menu a.active { background: #8ecae6; color: #0b2545; font-weight: 600; }
.admin-user { margin-top: auto; padding: .9rem .75rem 0; border-top: 1px solid rgba(255,255,255,.15); }
.admin-main { flex: 1; min-width: 0; }
.admin-topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: #fff; border-bottom: 1px solid #dee2e6; }
.admin-main > main { max-width: 1200px; }
.kpi { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; border-radius: 1rem; color: #fff; box-shadow: 0 .25rem .75rem rgba(0,0,0,.1); }
.kpi .bi { font-size: 2.2rem; opacity: .85; }
.kpi .num { font-size: 2rem; font-weight: 700; line-height: 1; }
.kpi-blue { background: linear-gradient(135deg, #2563eb, #1e40af); }
.kpi-green { background: linear-gradient(135deg, #16a34a, #166534); }
.kpi-orange { background: linear-gradient(135deg, #f59e0b, #b45309); }
.kpi-purple { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
@media (max-width: 991.98px) {
  .admin-shell { display: block; }
  .admin-sidebar { position: fixed; z-index: 1040; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .admin-sidebar.open { transform: none; }
}

/* ===== Logo ===== */
.brand-logo { border-radius: .55rem; background: #fff; object-fit: cover; }

/* ===== Pantalla de ingreso ===== */
body.login-page { background: #e7e2f3; min-height: 100vh; }
body.login-page main { max-width: 1180px; padding-top: 2.5rem !important; }
body.login-page footer { display: none; }
.login-stage { display: flex; align-items: center; justify-content: center; gap: 1rem; min-height: 78vh; position: relative; }
.login-panel { position: relative; z-index: 2; width: 100%; max-width: 440px; background: #f6f3fa; border-radius: 2rem; padding: 2.2rem 2.2rem 2.4rem; box-shadow: 0 1.5rem 3rem rgba(80, 60, 140, .18); }
.login-top { display: flex; justify-content: space-between; align-items: flex-start; }
.login-brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; color: #1d1b2e; line-height: 1.1; }
.login-brand img { border-radius: .7rem; }
.login-link { color: #2f6fd0; font-weight: 700; font-size: .8rem; text-align: right; text-decoration: underline; white-space: nowrap; }
.login-title { font-size: 2.7rem; font-weight: 800; color: #1d1b2e; margin: 1.6rem 0 .2rem; letter-spacing: -.02em; }
.login-sub { color: #6d6a80; margin-bottom: 1.4rem; }
.login-label { font-weight: 600; color: #6d6a80; font-size: .9rem; margin: .8rem 0 .35rem; }
.login-field { position: relative; }
.login-field > .bi:first-child { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: #8b88a0; font-size: 1.1rem; pointer-events: none; }
.login-field input { width: 100%; padding: .85rem 2.8rem .85rem 2.7rem; border: 2px solid #d8d3e6; border-radius: .85rem; background: #fff; font-size: 1rem; outline: none; transition: border-color .15s, box-shadow .15s; }
.login-field input:focus { border-color: #2e9e2e; box-shadow: 0 0 0 .2rem rgba(46, 158, 46, .15); }
.login-field .eye { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: #6d6a80; font-size: 1.2rem; padding: .3rem .5rem; }
.login-hint { font-size: .82rem; color: #6d6a80; margin-top: .45rem; }
.login-error { background: #fde8e8; color: #a12020; border-radius: .8rem; padding: .7rem .9rem; font-size: .92rem; }
.login-error ul { margin: 0; padding: 0; list-style: none; }
.login-btn { margin-top: 1.6rem; width: 100%; border: 0; border-radius: .9rem; padding: .95rem 1.2rem; background: #343a40; color: #fff; font-weight: 700; font-size: 1.05rem; transition: background .15s, transform .15s; }
.login-btn:hover { background: #1d2125; transform: translateY(-1px); }
.login-a11y { position: absolute; top: .8rem; right: 1rem; display: flex; gap: .3rem; z-index: 3; }
.login-a11y button { border: 1px solid #b9b1d3; background: rgba(255,255,255,.7); border-radius: .5rem; padding: .15rem .6rem; font-weight: 700; color: #3b3560; }

.login-art { position: relative; flex: 1; max-width: 560px; height: 520px; display: none; margin-left: -10px; }
@media (min-width: 992px) { .login-art { display: block; } }
.login-art .blob { position: absolute; border-radius: 50%; }
.login-art .b1 { width: 400px; height: 340px; left: 90px; top: 150px; background: radial-gradient(circle at 30% 30%, #d9cdfb, #a99af0); border-radius: 55% 45% 50% 50% / 55% 50% 50% 45%; }
.login-art .b2 { width: 130px; height: 80px; right: 0; top: 190px; background: linear-gradient(135deg, #cfc3f7, #b8a8f2); border-radius: 60% 40% 55% 45%; transform: rotate(-12deg); }
.login-art .b3 { width: 110px; height: 70px; left: 60px; top: 380px; background: linear-gradient(135deg, #c9e3ff, #8cc4ff); border-radius: 50%; }
.art-core { position: absolute; left: 170px; top: 40px; width: 230px; height: 230px; border-radius: 3rem; background: linear-gradient(145deg, #1f4cff, #00c6ee); display: grid; place-items: center; color: #fff; font-size: 8rem; box-shadow: 0 1.5rem 2.5rem rgba(31, 76, 255, .3); transform: rotate(-4deg); }
.art-chip { position: absolute; display: flex; align-items: center; gap: .55rem; background: #fff; border-radius: 1rem; padding: .7rem 1rem; font-weight: 700; color: #3b3560; box-shadow: 0 .8rem 1.6rem rgba(80, 60, 140, .2); animation: float 5s ease-in-out infinite; }
.art-chip .bi { font-size: 1.4rem; color: #6a5acd; }
.art-chip.c1 { left: 20px; top: 110px; }
.art-chip.c2 { right: 10px; top: 80px; animation-delay: -1.2s; }
.art-chip.c3 { left: 40px; top: 300px; animation-delay: -2.4s; }
.art-chip.c4 { right: 20px; top: 320px; animation-delay: -3.5s; }
.art-chip.c4 .bi { color: #e0a100; }
.art-text { position: absolute; left: 90px; right: 0; bottom: 10px; text-align: center; color: #3b3560; font-size: 1.05rem; }
.art-text strong { font-size: 1.5rem; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .art-chip { animation: none; } }
html[data-contrast="high"] body.login-page { background: #000; }
html[data-contrast="high"] .login-panel { background: #000; border: 2px solid #fff; }
html[data-contrast="high"] .login-title, html[data-contrast="high"] .login-brand { color: #fff; }
html[data-contrast="high"] .login-sub, html[data-contrast="high"] .login-label, html[data-contrast="high"] .login-hint { color: #ddd; }
html[data-contrast="high"] .login-btn { background: #ffe600; color: #000; }

/* =====================================================================
   Tema "lila suave" (mismo lenguaje visual del ingreso) para toda la app
   ===================================================================== */
:root { --ink: #1d1b2e; --ink-soft: #6d6a80; --lilac-bg: #ece8f6; --card-bg: #f6f3fa; --line: #d8d3e6; --violet: #6a5acd; --dark: #343a40; }
body { background: var(--lilac-bg); color: var(--ink); }
h1, h2, h3, h4, h5 { letter-spacing: -.01em; }
h1.h3 { font-weight: 800; letter-spacing: -.02em; }
.card { --bs-card-bg: var(--card-bg); border-radius: 1.4rem; box-shadow: 0 .8rem 1.8rem rgba(80, 60, 140, .1) !important; }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 700; padding: 1rem 1.25rem; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(106, 90, 205, .06); }
.table > :not(caption) > * > * { padding: .75rem 1.25rem; }
.table thead th { color: var(--ink-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
.list-group-item { background: transparent; border-color: var(--line); }
.text-muted { color: var(--ink-soft) !important; }

.btn { border-radius: .9rem; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--dark); --bs-btn-border-color: var(--dark); --bs-btn-hover-bg: #1d2125; --bs-btn-hover-border-color: #1d2125; --bs-btn-active-bg: #1d2125; --bs-btn-active-border-color: #1d2125; --bs-btn-disabled-bg: var(--dark); --bs-btn-disabled-border-color: var(--dark); }
.btn-outline-primary { --bs-btn-color: var(--dark); --bs-btn-border-color: #9d98b3; --bs-btn-hover-bg: var(--dark); --bs-btn-hover-border-color: var(--dark); --bs-btn-active-bg: var(--dark); }
.form-control, .form-select { border: 2px solid var(--line); border-radius: .85rem; background-color: #fff; }
.form-control:focus, .form-select:focus { border-color: #2e9e2e; box-shadow: 0 0 0 .2rem rgba(46, 158, 46, .15); }
.form-check-input:checked { background-color: var(--violet); border-color: var(--violet); }
.progress { background: #ddd6f1; border-radius: 1rem; }
.progress-bar { background: linear-gradient(90deg, #6a5acd, #8f7bf0); border-radius: 1rem; }
.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { color: var(--ink-soft); font-weight: 600; border: 0; border-bottom: 3px solid transparent; border-radius: 0; }
.nav-tabs .nav-link.active { background: transparent; color: var(--ink); border-bottom-color: var(--violet); }
.badge.text-bg-info { background: #d9cdfb !important; color: #3b3560 !important; }
.page-link { color: var(--ink); border-radius: .6rem; margin: 0 .1rem; }

/* Barra superior (docente / participante) */
.app-nav { background: rgba(246, 243, 250, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
  --bs-navbar-color: #4a4570; --bs-navbar-hover-color: var(--ink); --bs-navbar-active-color: var(--ink); --bs-navbar-brand-color: var(--ink); --bs-navbar-brand-hover-color: var(--ink); }
.app-nav .nav-link { font-weight: 600; border-radius: .7rem; padding: .45rem .8rem !important; }
.app-nav .nav-link:hover { background: rgba(106, 90, 205, .1); }
.app-nav .navbar-toggler { border-color: var(--line); }
.app-nav .navbar-toggler-icon { filter: invert(1) opacity(.7); }
.app-nav .btn-outline-light { color: #3b3560; border-color: #b9b1d3; }
.app-nav .btn-outline-light:hover { background: #3b3560; color: #fff; }
.app-nav .btn-light { background: var(--dark); color: #fff; border-color: var(--dark); }

/* Barra lateral del administrador: tarjeta flotante clara */
.admin-sidebar { background: var(--card-bg); color: var(--ink); margin: .75rem; height: calc(100vh - 1.5rem); border-radius: 1.6rem; box-shadow: 0 1rem 2.4rem rgba(80, 60, 140, .16); flex-basis: 250px; top: .75rem; }
.admin-brand { color: var(--ink); }
.admin-section { color: #9a96b0; }
.admin-menu a { color: #4a4570; font-weight: 600; border-radius: .9rem; }
.admin-menu a:hover { background: rgba(106, 90, 205, .1); color: var(--ink); }
.admin-menu a.active { background: var(--dark); color: #fff; }
.admin-user { border-top-color: var(--line); }
.admin-user .text-white-50 { color: var(--ink-soft) !important; }
.admin-user .text-white { color: var(--ink) !important; }
.admin-sidebar .btn-outline-light { color: #3b3560; border-color: #b9b1d3; }
.admin-sidebar .btn-outline-light:hover { background: #3b3560; color: #fff; }
.admin-sidebar .btn-light { background: var(--dark); color: #fff; border-color: var(--dark); }
.admin-topbar { background: var(--card-bg); border-color: var(--line); }
@media (max-width: 991.98px) { .admin-sidebar { margin: 0; height: 100vh; border-radius: 0 1.6rem 1.6rem 0; top: 0; } }

/* Saludo / hero de los paneles */
.hero { position: relative; overflow: hidden; border-radius: 1.8rem; padding: 1.8rem 2rem; margin-bottom: 1.5rem; background: linear-gradient(120deg, #f6f3fa 40%, #e1d8fb); box-shadow: 0 1rem 2.2rem rgba(80, 60, 140, .14); }
.hero h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .25rem; }
.hero p { color: var(--ink-soft); margin: 0 0 1rem; max-width: 34rem; }
.hero-art { position: absolute; right: 2rem; top: 50%; transform: translateY(-50%); width: 190px; height: 150px; display: none; }
@media (min-width: 768px) { .hero-art { display: block; } .hero { padding-right: 15rem; } }
.hero-art .tile { position: absolute; right: 30px; top: 5px; width: 110px; height: 110px; border-radius: 2rem; display: grid; place-items: center; font-size: 3.8rem; color: #fff; background: linear-gradient(145deg, #1f4cff, #00c6ee); box-shadow: 0 1rem 1.6rem rgba(31, 76, 255, .28); transform: rotate(-5deg); }
.hero-art .dot { position: absolute; border-radius: 50%; background: #c9bdf5; }
.hero-art .dot.d1 { width: 70px; height: 70px; left: 20px; bottom: 5px; }
.hero-art .dot.d2 { width: 34px; height: 34px; right: 0; bottom: 20px; background: #8cc4ff; }
.hero-art .mini { position: absolute; left: 0; top: 18px; background: #fff; border-radius: .9rem; padding: .35rem .6rem; font-weight: 700; font-size: .8rem; color: #3b3560; box-shadow: 0 .5rem 1rem rgba(80, 60, 140, .2); animation: float 5s ease-in-out infinite; }

/* Indicadores (KPI) en pastel con ícono en burbuja */
.kpi { background: var(--card-bg) !important; color: var(--ink) !important; box-shadow: 0 .8rem 1.8rem rgba(80, 60, 140, .1); border-radius: 1.4rem; }
.kpi .bi { width: 3.2rem; height: 3.2rem; display: grid; place-items: center; border-radius: 1rem; font-size: 1.6rem; opacity: 1; flex: none; }
.kpi-blue .bi { background: #d6e4ff; color: #1f4cff; }
.kpi-green .bi { background: #d3f2df; color: #15803d; }
.kpi-orange .bi { background: #ffe6c2; color: #c2680a; }
.kpi-purple .bi { background: #e1d8fb; color: #6a5acd; }
.kpi .num { color: var(--ink); }
.stat .bi { display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: #e1d8fb; font-size: 1.5rem; color: var(--violet) !important; }

/* Tarjetas de curso */
.course-card .card-body { position: relative; padding-top: 1.6rem; }
.course-card::before { content: ""; display: block; height: .5rem; border-radius: 1.4rem 1.4rem 0 0; background: linear-gradient(90deg, #6a5acd, #00c6ee); }
.col-md-6:nth-child(3n+2) > .course-card::before { background: linear-gradient(90deg, #f59e0b, #f472b6); }
.col-md-6:nth-child(3n) > .course-card::before { background: linear-gradient(90deg, #16a34a, #2dd4bf); }
.col-xl-4:nth-child(3n+2) > .course-card::before { background: linear-gradient(90deg, #f59e0b, #f472b6); }
.col-xl-4:nth-child(3n) > .course-card::before { background: linear-gradient(90deg, #16a34a, #2dd4bf); }
.course-card { overflow: hidden; }
.pending-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 2rem; background: #fde8e8; color: #a12020; font-weight: 600; font-size: .85rem; }

html[data-contrast="high"] .hero, html[data-contrast="high"] .kpi, html[data-contrast="high"] .admin-sidebar, html[data-contrast="high"] .app-nav { background: #000 !important; border: 1px solid #fff; color: #fff !important; }
html[data-contrast="high"] .hero p, html[data-contrast="high"] .kpi .num, html[data-contrast="high"] .admin-menu a, html[data-contrast="high"] .admin-brand, html[data-contrast="high"] .app-nav .nav-link, html[data-contrast="high"] .navbar-brand { color: #fff !important; }
html[data-contrast="high"] .admin-menu a.active, html[data-contrast="high"] .btn-primary { background: #ffe600 !important; color: #000 !important; border-color: #ffe600 !important; }
.app-nav .nav-link, .app-nav .navbar-brand { white-space: nowrap; }

/* ===== Firmas ===== */
#sig-canvas { width: 100%; height: auto; aspect-ratio: 700 / 240; background: #fff; border: 2px dashed #b9b1d3; border-radius: 1rem; touch-action: none; cursor: crosshair; display: block; }
.sig-preview { min-height: 110px; display: grid; place-items: center; background: #fff; border: 2px solid var(--line); border-radius: 1rem; padding: .5rem; }
.sig-preview img { max-width: 100%; max-height: 100px; object-fit: contain; }
.sig-preview-sm { min-height: 64px; width: 150px; padding: .25rem; }
.sig-preview-sm img { max-height: 54px; }
