:root {
  --navy: #14213D; --navy-2: #1E2C4D; --red: #B8262E; --red-soft: #FDF1F1; --red-line: #E03838;
  --blue: #163F78; --ink: #2A3140; --ink-2: #3D4555; --muted: #5A6272; --line: #E4E8EF;
  --bg: #F3F5F9; --white: #FFFFFF; --green: #1E7A46; --green-bg: #E6F4EC; --amber: #7A4A00; --amber-bg: #FFF1D6;
  --display: Montserrat, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 'Nunito Sans', system-ui, sans-serif; }
a { color: var(--blue); }
a:hover { color: var(--red); }
h1, h2, h3 { font-family: var(--display); color: var(--navy); line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0 0 12px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: #fff; padding: 8px 12px; z-index: 10; }
:focus-visible { outline: 3px solid #FF6B66; outline-offset: 2px; }

.bar { background: var(--navy); color: #fff; }
.bar-in { max-width: 1200px; margin: 0 auto; padding: 10px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 17px; }
.brand img { border-radius: 50%; background: #fff; }
.topnav { display: flex; flex-wrap: wrap; gap: 4px 22px; font-weight: 700; font-size: 15px; flex: 1; }
.topnav a { color: #C9D2E3; text-decoration: none; padding: 10px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: #fff; }
.topnav a[aria-current="page"] { color: #fff; border-color: #FF6B66; }
.logout { display: flex; align-items: center; gap: 14px; margin: 0; }
.who { display: flex; align-items: center; gap: 10px; color: #C9D2E3; font-size: 15px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.linkbtn { background: none; border: 0; color: #fff; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0 4px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 36px 24px 72px; }
.wrap.wide { max-width: 1200px; }
.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .12em; color: var(--red); text-transform: uppercase; margin: 0 0 8px; }

.card { background: var(--white); border-radius: 0; padding: 28px; margin-bottom: 20px; }
.card.dark { background: var(--navy); color: #fff; }
.card.dark h2, .card.dark h3 { color: #fff; }
.card.dark .muted { color: #C9D2E3; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.stack > * + * { margin-top: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 24px; border-radius: 999px; border: 0; background: var(--red); color: #fff; font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; }
.btn:hover { background: #9E1F27; color: #fff; }
.btn.secondary { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.secondary:hover { background: #EEF2F8; color: var(--blue); }
.btn.light { background: #fff; color: var(--navy); }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 15px; }
.btn.danger { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn[disabled] { background: var(--line); color: #6B7383; cursor: not-allowed; border: 0; }

.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.now { background: var(--red); color: #fff; }
.badge.lock { background: #EEF1F5; color: #4A5468; }
.level { width: 60px; height: 60px; flex: none; border-radius: 50%; border: 3px solid #FF6B66; display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 22px; }

progress.progress { width: 100%; height: 10px; border: 0; border-radius: 999px; overflow: hidden; background: #E4E8EF; appearance: none; }
progress.progress::-webkit-progress-bar { background: #E4E8EF; border-radius: 999px; }
progress.progress::-webkit-progress-value { background: var(--red); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: var(--red); border-radius: 999px; }
.card.dark progress.progress, .card.dark progress.progress::-webkit-progress-bar { background: #2E3B58; }
.card.dark progress.progress::-webkit-progress-value { background: #FF6B66; }
.card.dark progress.progress::-moz-progress-bar { background: #FF6B66; }

.flash { border-radius: 0; padding: 14px 18px; margin-bottom: 20px; font-weight: 700; }
.flash-ok { background: var(--green-bg); color: #145C33; }
.flash-warn { background: var(--amber-bg); color: #5C3A00; }
.flash-error { background: var(--red-soft); color: #8A1C22; }

.units { display: grid; gap: 14px; }
.unit { background: #fff; border-radius: 0; padding: 22px; border: 2px solid transparent; }
.unit.current { border-color: var(--red); }
.unit.locked { background: #EEF1F5; }
.unit ol { list-style: none; margin: 14px 0 0; padding: 0; }
.unit ol li a, .unit ol li span.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 0; text-decoration: none; color: var(--ink-2); min-height: 44px; }
.unit ol li a:hover { background: var(--bg); color: var(--navy); }
.dot { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid #9AA3B2; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 800; }
.dot.done { background: var(--green); border-color: var(--green); }

.video { aspect-ratio: 16 / 9; background: #0E1730; border-radius: 0; overflow: hidden; position: relative; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #C9D2E3; padding: 24px; text-align: center; }

.question { background: #fff; border-radius: 0; padding: 24px; margin-bottom: 16px; }
.question fieldset { border: 0; margin: 0; padding: 0; }
.question legend { font-family: var(--display); font-weight: 700; color: var(--navy); font-size: 19px; margin-bottom: 14px; padding: 0; }
.option { display: flex; align-items: center; gap: 14px; border: 1.5px solid #D3D9E3; border-radius: 0; padding: 12px 16px; margin-bottom: 10px; cursor: pointer; min-height: 52px; }
.option:hover { border-color: var(--blue); }
.option input { width: 20px; height: 20px; accent-color: var(--red); }
.option.right { border-color: var(--green); background: var(--green-bg); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }

form.stack label, .field label { display: block; font-weight: 700; color: var(--navy); margin-bottom: 6px; font-size: 15px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid #C7CFDB; border-radius: 0; padding: 11px 14px; min-height: 46px;
}
textarea { min-height: 96px; }
.field { margin-bottom: 16px; }
.hint { font-size: 14px; color: var(--muted); margin-top: 4px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: 0; overflow: hidden; font-size: 15px; }
table.data th { text-align: left; background: var(--navy); color: #fff; padding: 12px 14px; font-weight: 700; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; border-radius: 0; }
.inline-form { display: inline; }

.login { max-width: 440px; margin: 40px auto; }
.cert { background: #fff; border: 10px double var(--red-line); outline: 4px solid var(--blue); outline-offset: -22px; border-radius: 0; padding: 72px 56px; text-align: center; max-width: 900px; margin: 0 auto; }
.cert img { width: 120px; height: 120px; }
.cert .name { font-family: var(--display); font-size: 40px; font-weight: 800; color: var(--navy); margin: 18px 0; }
.cert .course { font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--red); }

@media print {
  .bar, .foot, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .cert { border-width: 8px; }
}
@media (max-width: 640px) {
  h1 { font-size: 26px; }
  .card { padding: 22px; }
  .cert { padding: 48px 22px; }
  .cert .name { font-size: 30px; }
}

.on-dark { color: #fff; }
.on-dark:hover { color: #FF8A86; }
.center { text-align: center; }
.justify-center { justify-content: center; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; } .mt-36 { margin-top: 36px; } .mb-20 { margin-bottom: 20px; }
.bigscore { font-family: var(--display); font-size: 48px; font-weight: 800; margin: 8px 0; }
.bigscore.pass { color: var(--green); }
.bigscore.fail { color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
a.card { display: block; text-decoration: none; color: inherit; }
a.card:hover { outline: 2px solid var(--red); }
.row input[type=text] { flex: 1 1 260px; width: auto; }

/* ---------- Fases ---------- */
.phases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.phase-step a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 0; text-decoration: none; color: inherit; background: var(--bg); min-height: 64px; }
.phase-num { width: 34px; height: 34px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; border: 2px solid #9AA3B2; color: #6B7383; }
.phase-name { display: block; font-family: var(--display); font-weight: 700; color: var(--navy); line-height: 1.2; }
.phase-state { display: block; font-size: 13px; color: var(--muted); }
.phase-step.done .phase-num { background: var(--green); border-color: var(--green); color: #fff; }
.phase-step.now a { background: var(--red-soft); }
.phase-step.now .phase-num { border-color: var(--red); color: var(--red); }
.phase-step.locked a { opacity: .7; }
.card.dark .phase-step a { background: var(--navy-2); }
.card.dark .phase-name { color: #fff; }
.card.dark .phase-state { color: #C9D2E3; }
.card.dark .phase-step.now a { background: #3A2533; }
.card.dark .phase-step.now .phase-num { border-color: #FF6B66; color: #FF8A86; }
@media (max-width: 640px) { .phases { grid-template-columns: 1fr; } }

.phase { padding: 28px; scroll-margin-top: 16px; }
.phase h2 { margin-bottom: 4px; }
.phase h3 { font-size: 16px; margin: 22px 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
h4 { font-family: var(--display); color: var(--navy); font-size: 19px; margin: 0 0 4px; }
.phase-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px 36px; }
@media (max-width: 860px) { .phase-grid { grid-template-columns: 1fr; } }
.gate { margin-top: 24px; padding: 20px; border-radius: 0; border: 2px dashed #C7CFDB; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.phase.current .gate { border-color: var(--red); border-style: solid; }
.gate p { margin: 0; }

.list, .sessions { list-style: none; margin: 0; padding: 0; }
.unit .list li a, .unit .list li span.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 0; text-decoration: none; color: var(--ink-2); min-height: 44px; }
.unit .list li a:hover { background: var(--bg); color: var(--navy); }
.card .list li { padding: 6px 0; }
.session { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.session:first-child { border-top: 0; }
.session.mine { background: var(--green-bg); border-radius: 0; padding: 14px; border-top: 0; margin: 6px 0; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

/* Reloj del examen con tiempo */
.timer { position: sticky; top: 12px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--navy); color: #fff; border-radius: 0; padding: 12px 18px; margin-bottom: 16px; }
.timer strong { font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red); }
input[type=datetime-local], input[type=url] { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid #C7CFDB; border-radius: 0; padding: 11px 14px; min-height: 46px; }

/* Marca de agua del vídeo: nombre y email del alumno, se mueve cada pocos segundos */
.watermark { position: absolute; z-index: 2; left: 6%; top: 8%; max-width: 80%; pointer-events: none; user-select: none;
  color: rgba(255, 255, 255, .42); font-size: clamp(11px, 1.6vw, 15px); font-weight: 700; letter-spacing: .02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55); transition: left 1.2s ease, top 1.2s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video:fullscreen { aspect-ratio: auto; border-radius: 0; width: 100vw; height: 100vh; }
.video:fullscreen .watermark { font-size: 18px; }
.video-bar { margin-top: 10px; }
.video-bar p { margin: 0; }

/* Compra */
.buy { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .buy { grid-template-columns: 1fr; } }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { position: relative; padding: 6px 0 6px 28px; }
.checklist li::before { content: '✓'; position: absolute; left: 4px; color: var(--green); font-weight: 800; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--red); }
form.stack label.check { display: flex; font-weight: 400; color: var(--ink); font-size: 15px; }

/* Libro digital */
.book { border-left: 6px solid var(--red); }
.book-code { display: inline-block; font-size: 22px; font-weight: 700; letter-spacing: .08em; background: var(--bg); border: 1.5px dashed #9AA3B2; padding: 10px 16px; margin: 4px 0 12px; user-select: all; }
.linkbtn.dark { color: var(--red); min-height: 0; }
