/* =========================================================================
   ISFES · Academia de Policía Local
   Diseño web alineado con la identidad de academia.isfes.es.
   Marca: triángulo azul/rojo/verde. Azul institucional para la estructura,
   rojo y verde reservados para corregir (fallo / acierto).
   ========================================================================= */

:root {
    /* Marca (tomada del logotipo ISFES) */
    --brand: #004898;
    --brand-strong: #003B7E;
    --brand-deep: #002E5E;
    --brand-tint: #E8F0FA;

    /* Corrección */
    --red: #F80000;
    --red-text: #C40000;
    --red-soft: #FDE9E8;
    --green: #58A010;
    --green-text: #3F7A0C;
    --green-soft: #EDF5DF;

    /* Neutros */
    --paper: #F1F5FA;
    --card: #FFFFFF;
    --ink: #232A33;
    --ink-2: #525C68;
    --ink-3: #8A929E;
    --line: #E0E6EF;
    --line-strong: #C5CFDD;
    --highlight: #F2B308;

    --radius: 4px;
    --sidebar: 260px;
    --sans: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; font-size: 16px; }
html[data-font="sm"] { font-size: 14px; }
html[data-font="lg"] { font-size: 18px; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ Tema oscuro */
html[data-theme="dark"] {
    --paper: #10161F;
    --card: #1A2230;
    --ink: #E7ECF3;
    --ink-2: #B3BECC;
    --ink-3: #8996A6;
    --line: #2A3446;
    --line-strong: #3A465A;
    --brand: #6FA8E6;
    --brand-strong: #8FBEF0;
    --brand-deep: #16202E;
    --brand-tint: #1E2A3C;
    --red-soft: #3A2424;
    --green-soft: #26331C;
}
html[data-theme="dark"] { background: var(--paper); }
html[data-theme="dark"] .sidebar { background: #0C121B; }
html[data-theme="dark"] a { color: var(--brand); }
html[data-theme="dark"] .topbar { background: rgba(16,22,31,.92); }

h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.25rem); font-weight: 800; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }
small { font-size: .7em; font-weight: 600; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
:focus-visible { outline: 3px solid rgba(0,72,152,.4); outline-offset: 2px; }

/* ---------------------------------------------------------------- Layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
    background: var(--brand-deep);
    color: #D3DEEC;
    padding: 28px 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.content { display: flex; flex-direction: column; min-width: 0; }
.main { padding: 40px clamp(20px, 5vw, 60px) 72px; max-width: 1400px; width: 100%; }

/* Marca de la barra lateral */
.brand { text-decoration: none; display: block; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand__logo { display: block; width: 100%; max-width: 180px; height: auto; }
.brand__sub {
    display: block;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #8FB0D8;
    margin-top: 14px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
    display: block;
    padding: 9px 14px;
    color: #C3D2E6;
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 0 4px 4px 0;
    font-size: .93rem;
    font-weight: 500;
    transition: background-color .15s, color .15s;
}
.nav__item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav__item.is-active {
    color: #fff;
    font-weight: 600;
    border-left-color: #fff;
    background: rgba(255,255,255,.11);
}

/* Opción deshabilitada (solo acceso completo) */
.nav__item--disabled {
    color: #6E86A6;
    cursor: not-allowed;
    opacity: .75;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.nav__item--disabled:hover { color: #6E86A6; background: transparent; }
.nav__lock { font-size: .78rem; opacity: .9; }

.sidebar__foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.14); font-size: .85rem; }
.nav__name { display: block; color: #fff; font-weight: 600; margin-bottom: 6px; }
.nav__logout { color: #8FB0D8; }
.nav__logout:hover { color: #fff; }
/* Capa del menú móvil: fuera de pantallas pequeñas no existe. */
.nav-scrim { display: none; }
/* Botón de cerrar del menú: solo en móvil. */
.nav__close { display: none; }

/* Controles de lectura (tema y tamaño de letra) */
.reading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.reading__btn {
    background: rgba(255,255,255,.08);
    color: #D3DEEC;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 4px;
    padding: 5px 9px;
    font: inherit;
    font-size: .78rem;
    cursor: pointer;
}
.reading__btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.reading__icon { margin-right: 3px; }
.reading__font { display: inline-flex; gap: 4px; }
.reading__btn--font { min-width: 30px; text-align: center; }

.topbar { display: none; }

/* ------------------------------------------------------------- Tipografía */
.page-head { margin-bottom: 26px; }
.page-head h1 { margin-bottom: .25em; }
.lede { color: var(--ink-2); max-width: 62ch; margin: 0; }
.crumb { font-size: .85rem; color: var(--ink-3); margin: 0 0 6px; }
.muted { color: var(--ink-3); }
.subhead { margin-top: 1.6em; }
.formula { font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; margin: 6px 0 0; }

/* ----------------------------------------------------------------- Hero */
.hero {
    position: relative;
    overflow: hidden;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius);
    padding: 30px clamp(22px, 4vw, 40px);
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.hero::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -70px;
    width: 260px;
    height: 260px;
    background: rgba(255,255,255,.07);
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
}
.hero__intro, .hero__nota { position: relative; z-index: 1; }
.hero__kicker {
    margin: 0 0 6px;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #A9C6EA;
}
.hero h1 { color: #fff; margin: 0 0 6px; }
.hero__sub { margin: 0; color: #D3E0F2; max-width: 46ch; font-size: .96rem; }
.hero__nota { text-align: right; }
.hero__nota-label { display: block; font-size: .76rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #A9C6EA; }
.hero__nota-value {
    display: block;
    font-size: clamp(2.6rem, 6vw, 3.6rem);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}
.hero__nota-value small { color: #A9C6EA; font-size: .34em; font-weight: 600; }

/* ---------------------------------------------------------------- Bloques */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 22px;
}
.panel--center { text-align: center; padding: 44px 24px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.columns--charts { grid-template-columns: 1fr 1fr; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.bignum { font-size: 3.4rem; font-weight: 800; margin: 0; line-height: 1; font-variant-numeric: tabular-nums; }
.bignum--ok { color: var(--green-text); }

/* ------------------------------------------------------------ Estadísticas */
.scoreline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 22px;
    overflow: hidden;
}
.stat {
    background: var(--card);
    padding: 16px 18px;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    margin: -1px 0 0 -1px;
}
.stat__label { display: block; font-size: .76rem; font-weight: 600; color: var(--ink-3); margin-bottom: 5px; }
.stat__value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* --------------------------------------------------------------- Controles */
.btn {
    display: inline-block;
    padding: 9px 17px;
    border: 1px solid var(--line-strong);
    background: var(--card);
    color: var(--ink);
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { background: #CC0000; border-color: #CC0000; color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn--ghost:hover { color: var(--brand-strong); background: var(--brand-tint); }
.btn--small { padding: 6px 12px; font-size: .82rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.actions form { margin: 0; }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.inline-form { margin-bottom: 18px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form--inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; }
.field > span { color: var(--ink-2); font-weight: 600; }
.field em { color: var(--ink-3); font-style: normal; font-size: .82em; }
.field input, .field select, input[type="text"], input[type="password"], select {
    font: inherit;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    width: 100%;
}
.field input:focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(0,72,152,.14); }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.fieldset legend { font-weight: 600; color: var(--ink-2); padding: 0 6px; font-size: .9rem; }
.radio, .check { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: .92rem; cursor: pointer; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radio--inline { padding: 4px 6px; }

/* --------------------------------------------------------- Elección (áreas) */
.choice-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.choice-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}
.choice-card:hover { border-left-color: var(--brand); color: var(--ink); }
.choice-card__title { font-size: 1.03rem; font-weight: 700; }
.choice-card__meta { font-size: .82rem; color: var(--ink-3); }
.choice-card--full { border-left-color: var(--brand); }

/* Colores por área (práctica) */
.choice-card--ord {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF3D1 100%);
    color: #8B7000;
    border-color: #E8D4A0;
    border-left-color: #E8D4A0;
}
.choice-card--ord:hover { border-left-color: #D4B880; }

.choice-card--pen {
    background: linear-gradient(135deg, #F3EDFB 0%, #E8DDF7 100%);
    color: #5A3D8A;
    border-color: #D0C4E8;
    border-left-color: #D0C4E8;
}
.choice-card--pen:hover { border-left-color: #B8A8D8; }

.choice-card--adm {
    background: linear-gradient(135deg, #FDECEC 0%, #FADDDD 100%);
    color: #9B2C2C;
    border-color: #F0C0C0;
    border-left-color: #F0C0C0;
}
.choice-card--adm:hover { border-left-color: #E0A0A0; }

.choice-card--tra {
    background: linear-gradient(135deg, #E8F7EE 0%, #D1F0DB 100%);
    color: #2E7D32;
    border-color: #A8E6B8;
    border-left-color: #A8E6B8;
}
.choice-card--tra:hover { border-left-color: #88D098; }

.stack { display: flex; flex-direction: column; gap: 12px; }

/* --------------------------------------------------------- Tarjetas de área (bloque) - Mismo estilo que .choice-card */
.area-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 8px;
}
.area-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}
.area-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.area-card__name {
    font-size: 1.03rem;
    font-weight: 700;
    line-height: 1.2;
}
.area-card:hover {
    border-left-color: var(--brand);
    color: var(--ink);
}
.area-card:focus-within {
    border-left-color: var(--brand);
    outline: none;
}
.area-card:has(input:checked) {
    border-left-color: currentColor;
}

/* Colores por área (igual que .choice-card) */
.area-card--ord {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF3D1 100%);
    color: #8B7000;
    border-color: #E8D4A0;
    border-left-color: #E8D4A0;
}
.area-card--ord:hover { border-left-color: #D4B880; }
.area-card--ord:has(input:checked) { color: #8B7000; }

.area-card--pen {
    background: linear-gradient(135deg, #F3EDFB 0%, #E8DDF7 100%);
    color: #5A3D8A;
    border-color: #D0C4E8;
    border-left-color: #D0C4E8;
}
.area-card--pen:hover { border-left-color: #B8A8D8; }
.area-card--pen:has(input:checked) { color: #5A3D8A; }

.area-card--adm {
    background: linear-gradient(135deg, #FDECEC 0%, #FADDDD 100%);
    color: #9B2C2C;
    border-color: #F0C0C0;
    border-left-color: #F0C0C0;
}
.area-card--adm:hover { border-left-color: #E0A0A0; }
.area-card--adm:has(input:checked) { color: #9B2C2C; }

.area-card--tra {
    background: linear-gradient(135deg, #E8F7EE 0%, #D1F0DB 100%);
    color: #2E7D32;
    border-color: #A8E6B8;
    border-left-color: #A8E6B8;
}
.area-card--tra:hover { border-left-color: #88D098; }
.area-card--tra:has(input:checked) { color: #2E7D32; }

/* Móvil */
@media (max-width: 600px) {
    .area-cards { grid-template-columns: 1fr; }
}

/* Móvil */
@media (max-width: 600px) {
    .area-cards { grid-template-columns: 1fr; }
    .area-card { min-height: 70px; padding: 14px 12px; }
}

.sheet {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: var(--radius);
    padding: 22px;
    max-width: 1200px;
    box-shadow: 0 1px 2px rgba(0,46,94,.05);
}
.sheet__tab {
    margin: -22px -22px 16px;
    padding: 8px 22px;
    background: var(--brand);
    color: #EAF1FA;
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: .02em;
    border-radius: 3px 3px 0 0;
}
.sheet__tab--exam { background: var(--red); color: #fff; }
.qnum { font-size: .75rem; color: var(--ink-3); margin: 0 0 6px; }
.qtext { font-size: 1.05rem; line-height: 1.45; font-weight: 600; margin: 0 0 14px; }

.options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    text-align: left;
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.option:hover { border-color: var(--brand); }
.bubble {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--ink-3);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: .85rem;
}
.option:hover .bubble { border-color: var(--brand); }
.bubble--blank { border-style: dashed; color: var(--ink-3); }
.option--blank { background: #FCFCFB; }

.options--result .option { cursor: default; }
.options--result .option:hover { border-color: var(--line); }
.option.is-correct { border-color: var(--green); background: var(--green-soft); }
.option.is-correct .bubble { background: var(--green); border-color: var(--green); color: #fff; }
.option.is-wrong { border-color: var(--red); background: var(--red-soft); }
.option.is-wrong .bubble { background: var(--red); border-color: var(--red); color: #fff; }

.feedback { border-left: 4px solid var(--line-strong); padding: 8px 12px; margin: 14px 0 0; font-weight: 600; font-size: .9rem; }
.feedback--ok { border-color: var(--green); background: var(--green-soft); color: var(--green-text); }
.feedback--ko { border-color: var(--red); background: var(--red-soft); color: var(--red-text); }
.feedback--blank { border-color: var(--ink-3); background: #EFF1F5; }
.feedback__note { border: 0; font-weight: 400; color: var(--ink-2); margin: 8px 0 0; font-size: .85rem; }

/* --- Feedback principal tras responder (solo la explicación) --- */
.feedback--main {
    margin: 16px 0 0;
    border-radius: var(--radius);
    overflow: hidden;
    border-left: 5px solid var(--line-strong);
    background: var(--paper);
}
.feedback--main--ok { border-left-color: var(--green); }
.feedback--main--ko { border-left-color: var(--red); }
.feedback--main--blank { border-left-color: var(--ink-3); }
.feedback__explanation {
    padding: 12px 16px;
    font-size: .92rem;
    line-height: 1.55;
    color: var(--ink);
}

.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress__bar { display: block; height: 100%; background: var(--brand); }

.report { max-width: 1200px; margin-top: 18px; font-size: .9rem; color: var(--ink-2); }
.report summary { cursor: pointer; color: var(--ink-3); }

/* --------------------------------------------------------------- Resultado */
.result { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 26px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 22px; }
.result__value { font-size: 4.2rem; font-weight: 800; line-height: 1; color: var(--red-text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result__out { display: block; color: var(--ink-3); font-size: .9rem; margin-top: 4px; font-weight: 600; }
.result__counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; margin: 0; }
.result__counts dt { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.result__counts dd { margin: 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ok { color: var(--green-text); }
.ko { color: var(--red-text); }

/* ----------------------------------------------------------------- Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list--tight li { padding: 7px 0; }
.list__meta { color: var(--ink-3); font-size: .85rem; display: inline-flex; gap: 12px; align-items: center; }
.list__lead { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; margin-right: 2px; }
.dot--ok { background: var(--green); }
.dot--ko { background: var(--red); }
.recent-item { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.recent-item__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.recent-item__q { margin: 0; color: var(--ink-2); font-size: .9rem; line-height: 1.35; }
.recent-item__form { display: inline-flex; margin: 0; }

/* ----------------------------------------------------------------- Tablas */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-weight: 700; color: var(--brand); border-bottom: 2px solid var(--brand); }
.table tbody tr:hover { background: #F7FAFE; }
.table--wide { display: block; overflow-x: auto; }

/* Tablas ordenables (informe de la clase) */
.table--sortable thead th { cursor: pointer; user-select: none; white-space: nowrap; }
.table--sortable thead th.th-sort::after {
    content: "\2195";
    margin-left: 6px;
    font-size: .85em;
    font-weight: 400;
    color: var(--ink-3);
}
.table--sortable thead th.th-sort:hover { color: var(--brand-strong); }
.table--sortable thead th.th-sort:hover::after { color: var(--brand-strong); }
.table--sortable thead th.is-asc::after { content: "\25B2"; color: var(--brand); }
.table--sortable thead th.is-desc::after { content: "\25BC"; color: var(--brand); }

/* ------------------------------------------------------------------- Avisos */
.note { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 20px; border-left: 4px solid var(--line-strong); background: #EEF2F7; }
.note--info { border-color: var(--brand); background: var(--brand-tint); }
.note--warn { border-color: var(--highlight); background: #FBF3D9; }
.note--win { border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.flashes { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 16px; border-radius: var(--radius); border-left: 4px solid var(--line-strong); background: #EEF2F7; margin: 0; }
.flash--success { border-color: var(--green); background: var(--green-soft); }
.flash--error { border-color: var(--red); background: var(--red-soft); }

/* Bloque informativo de contacto (cuentas limitadas) */
.contact {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    padding: 16px 18px;
    margin: 0 0 20px;
}
.contact__lead { margin: 0 0 12px; }
.contact__links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.contact__links .btn { display: inline-flex; align-items: center; gap: 8px; }
.ico { width: 16px; height: 16px; flex: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; border: 1px solid transparent; }
.badge--ok { background: var(--green-soft); color: var(--green-text); border-color: var(--green); }
.badge--ko { background: var(--red-soft); color: var(--red-text); border-color: var(--red); }
.badge--warn { background: #FBF3D9; color: #8A6A0B; border-color: var(--highlight); }
.badge--off { background: #EEF1F5; color: var(--ink-3); border-color: var(--line-strong); }
.badge--ink { background: var(--brand); color: #fff; }

.deflist { margin: 0; }
.deflist > div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.deflist dt { color: var(--ink-3); font-size: .9rem; }
.deflist dd { margin: 0; text-align: right; }

/* ----------------------------------------------------------- Administración */
.accounts { display: flex; flex-direction: column; gap: 14px; }
.account { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 18px 20px; }
.account__head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.account__name { font-size: 1.1rem; font-weight: 700; }
.account__user { color: var(--ink-3); font-size: .9rem; font-weight: 400; margin-left: 6px; }
.account__meta { font-size: .8rem; color: var(--ink-3); }
.account__flags { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.account__danger { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; padding-top: 12px; border-top: 1px dashed var(--line); }
.account__danger .check { color: var(--red-text); }

/* Acciones en bloque */
.bulk { margin-bottom: 22px; }
.bulk__row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.bulk__row .field { min-width: 160px; }
.account__pick { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.account__pick .account__name { margin: 0; }
.subnav form { margin: 0; }

/* ------------------------------------------------------------------ Gráficos */
.chartbox { position: relative; height: 280px; }
.chartbox--wide { height: 340px; }

/* ------------------------------------------------------------------- Sesión */
.guest {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}
/* Los avisos (flash) se apilan ENCIMA de la tarjeta, sin solaparse */
.guest > .flashes {
  width: min(720px, 100%);
  margin-bottom: 0;
  z-index: 1;
}
.guest > .flashes:empty { display: none; }
.guest::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url('/assets/brand/anim-bg.svg') center center / cover no-repeat;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}
.authcard {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 26px 24px;
    width: min(720px, 92vw);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,46,94,.10);
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}
.authcard--compact {
    width: min(380px, 100%);
    padding: 20px 22px 22px;
    font-size: 0.85rem;
}
.authband {
    margin: -20px -22px 16px;
    padding: 14px 18px;
    background: var(--brand-deep);
    display: flex;
    justify-content: center;
}
.authband__logo { width: 100%; max-width: 170px; height: auto; }
.authcard h1 { margin-top: 0; font-size: 1.25rem; margin-bottom: 10px; }
.authcard > p:last-child { margin-bottom: 0; }

.authcard .note { margin-bottom: 8px; font-size: 0.8rem; }
.authcard .field > span { font-size: 0.8rem; }
.authcard .field input { font-size: 0.9rem; padding: 8px 10px; }
.authcard .btn { font-size: 0.85rem; padding: 10px 16px; }

/* Botón principal del formulario de acceso centrado */
.authcard .form > button[type="submit"] {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 6px auto 0;
    text-align: center;
}
.authcard .muted { font-size: 0.75rem; }

/* Desplegable "¿Cómo me registro?" */
.howto {
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    background: var(--paper);
    margin: 0 0 14px;
    overflow: hidden;
}
.howto > summary {
    cursor: pointer;
    padding: 9px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--brand);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary::before {
    content: "›";
    display: inline-block;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform .15s;
}
.howto[open] > summary::before { transform: rotate(90deg); }
.howto[open] > summary { border-bottom: 1px solid var(--line); }
.howto__body { padding: 10px 12px 12px; }
.howto__steps {
    margin: 0 0 8px 1.1rem;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--ink-2);
}
.howto__steps li { margin-bottom: 3px; }
.howto__steps li:last-child { margin-bottom: 0; }
.howto__note { margin: 0; font-size: 0.78rem; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  .guest::before { opacity: 0.4; }
}

/* Formulario apaisado en pantallas anchas (solo para authcard normal, no compact) */
@media (min-width: 760px) {
    .authcard:not(.authcard--compact) .form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
    .authcard:not(.authcard--compact) .form > .field,
    .authcard:not(.authcard--compact) .form > .grid-2 { grid-column: span 2; }
    .authcard:not(.authcard--compact) .form > .field:first-child { grid-column: span 1; }
    .authcard:not(.authcard--compact) .form > .grid-2 { grid-column: 1 / -1; }
    .authcard:not(.authcard--compact) .form > button { grid-column: 1 / -1; justify-self: start; margin-top: 6px; }
}

/* Formulario apaisado en pantallas anchas */
@media (min-width: 760px) {
    .authcard .form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
    .authcard .form > .field,
    .authcard .form > .grid-2 { grid-column: span 2; }
    .authcard .form > .field:first-child { grid-column: span 1; }
    .authcard .form > .grid-2 { grid-column: 1 / -1; }
    .authcard .form > button { grid-column: 1 / -1; justify-self: start; margin-top: 6px; }
}

/* ------------------------------------------------------- Examen (rejilla) */
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 26px; align-items: start; }
.exam-main { min-width: 0; }
.exam-aside {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow: hidden auto;
}
.exam-aside h2 { font-size: 1.1rem; margin-bottom: .3em; }
.sheet--exam { max-width: 100%; }

.options--pick .option { cursor: pointer; }
.option__radio { position: absolute; opacity: 0; pointer-events: none; }
.option.is-chosen { border-color: var(--brand); background: var(--brand-tint); }
.option.is-chosen .bubble { background: var(--brand); border-color: var(--brand); color: #fff; }

.grid10 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; margin: 14px 0; }
/* Plantilla de corrección del examen: rejilla pequeña, como la del examen */
.grid10--result {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 4px;
    max-width: 260px;
}
.grid10--result button.cell { cursor: pointer; font-family: inherit; }
.grid10--result button.cell:hover { border-color: var(--brand); }
.grid10--result .cell.is-selected {
    outline: 3px solid var(--highlight);
    outline-offset: 1px;
}

/* Rejilla + detalle de la pregunta (resultado del examen) */
.correction {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 26px;
    align-items: start;
}
.correction__side { min-width: 0; }
.correction__detail {
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: var(--radius);
    background: var(--paper);
    padding: 18px 20px 20px;
    min-height: 220px;
}
.correction__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.correction__n { font-weight: 700; font-size: 1rem; }
.correction__q {
    font-size: 1.02rem;
    line-height: 1.45;
    font-weight: 600;
    margin: 0 0 16px;
}
.correction__opts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.correction__opt {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: .92rem;
}
.correction__opt.is-correct { border-color: var(--green); background: var(--green-soft); }
.correction__opt.is-correct .bubble { background: var(--green); border-color: var(--green); color: #fff; }
.correction__opt.is-wrong { border-color: var(--red); background: var(--red-soft); }
.correction__opt.is-wrong .bubble { background: var(--red); border-color: var(--red); color: #fff; }
.correction__tag {
    margin-left: auto;
    flex: none;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--green-text);
}
.correction__tag--ko { color: var(--red-text); }

@media (max-width: 900px) {
    .correction { grid-template-columns: 1fr; }
}
.cell {
    aspect-ratio: 1;
    min-width: 0;
    overflow: hidden;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    background: #fff;
    color: var(--ink-2);
    font-size: .68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0;
}
button.cell { cursor: pointer; font-family: inherit; }
button.cell:hover { border-color: var(--brand); }
.cell--answered { background: var(--brand); border-color: var(--brand); color: #fff; }
.cell--empty { background: #fff; }
.cell.is-current { outline: 3px solid var(--highlight); outline-offset: 1px; }
.cell--ok { background: var(--green); border-color: var(--green); color: #fff; }
.cell--ko { background: var(--red); border-color: var(--red); color: #fff; }
.cell--blank { background: #EFF1F5; border-color: var(--line-strong); color: var(--ink-3); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 18px; padding: 0; margin: 14px 0 0; font-size: .85rem; color: var(--ink-2); }
.legend .cell { float: left; width: 15px; height: 15px; aspect-ratio: auto; margin-right: 6px; border-radius: 2px; }

.btn--block { display: block; width: 100%; margin-top: 14px; text-align: center; }
.result__counts--3 { grid-template-columns: repeat(2, 1fr); }

.review-list { list-style: none; padding: 0; margin: 0; }
.review-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review-list li:last-child { border-bottom: 0; }
.review-list__q { margin: 0 0 4px; }
.review-list__n { font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }
.review-list__a { margin: 0; color: var(--ink-2); font-size: .92rem; }

/* ----------------------------------------------- Editor de preguntas / admin */
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--brand-strong); }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.option-row input[type="text"] { flex: 1; }
.opt-correct { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius); width: 100%; resize: vertical; }
.field textarea { width: 100%; }
textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(0,72,152,.14); }

/* ------------------------------------------------------------------- Móvil */
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    /* Capa oscura al abrir el menú: al pulsarla fuera se cierra. */
    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(6, 18, 38, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
    }
    .nav-toggle:checked ~ .nav-scrim { opacity: 1; pointer-events: auto; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar);
        max-width: 86vw;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 30;
        /* Si el menú no cabe en pantallas pequeñas, se desplaza en vez de
           esconderse el pie (donde está «Cerrar sesión»). */
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 28px;
    }
    .nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .nav__close {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: -8px;
        margin-left: auto;
        padding: 9px 12px;
        min-height: 44px;
        border: 1px solid rgba(255,255,255,.18);
        border-radius: 4px;
        color: #C3D2E6;
        font-size: .85rem;
        font-weight: 600;
        cursor: pointer;
    }
    .nav__close:active { background: rgba(255,255,255,.1); }
    .sidebar__foot { margin-top: auto; padding-top: 18px; }
    .nav__logout {
        display: block;
        margin-top: 10px;
        padding: 11px 14px;
        min-height: 44px;
        border: 1px solid rgba(255,255,255,.18);
        border-radius: 4px;
        text-align: center;
        color: #C3D2E6;
    }
    .nav__logout:hover { background: rgba(255,255,255,.08); color: #fff; }
    .topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 12px 18px;
        background: var(--brand-deep);
        color: #fff;
        position: sticky;
        top: 0;
        z-index: 20;
    }
    .topbar__menu { display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
    .topbar__menu span { width: 20px; height: 2px; background: #fff; display: block; }
    .topbar__brand { font-weight: 800; font-style: italic; letter-spacing: .06em; }
    .topbar__user { margin-left: auto; color: #A9C6EA; font-size: .85rem; }
    .main { padding: 24px 18px 56px; }
    .columns, .columns--charts, .grid-2 { grid-template-columns: 1fr; }
    .exam-layout { grid-template-columns: 1fr; }
    .exam-aside { position: static; }
    .result { grid-template-columns: 1fr; }
    .hero { padding: 24px 22px; }
    .hero__nota { text-align: left; }
    .sheet { padding: 18px; }
    .sheet__tab { margin: -18px -18px 14px; padding: 7px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
