:root {
    --bg: #050505;
    --panel: #0d0d0d;
    --panel-2: #111;
    --line: #292929;
    --gold: #d4b06a;
    --gold-soft: #e5ca91;
    --text: #f4f0e9;
    --muted: #9a968f;
    --green: #91d6a5;
    --red: #e09a9a;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    background: radial-gradient(circle at 50% -10%, rgba(212,176,106,.08), transparent 34%), var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }

.student-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.student-card {
    width: min(100%, 480px);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,255,255,.015), transparent), var(--panel);
    box-shadow: 0 24px 80px rgba(0,0,0,.46);
}

.student-brand {
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 22px;
    border-bottom: 1px solid var(--line);
}
.student-brand img {
    width: 145px;
    max-height: 52px;
    object-fit: contain;
    object-position: left center;
}
.student-brand span,
.eyebrow,
.student-form label > span,
.plan-card > span,
footer span {
    color: var(--gold);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
}

.view-block,
.account-hero,
.scanner-view {
    padding: 26px 22px;
}

.view-block h1,
.account-hero h1,
.scanner-welcome h1 {
    margin: 8px 0 10px;
    font-size: clamp(30px, 9vw, 42px);
    line-height: 1;
}

.muted,
.plan-card p,
.scanner-message,
.scanner-fallback p,
.detail-item small {
    color: var(--muted);
    line-height: 1.55;
}

.student-form {
    display: grid;
    gap: 17px;
    margin-top: 28px;
}
.student-form label { display: grid; gap: 8px; }
.student-form input {
    width: 100%;
    height: 54px;
    border: 1px solid #343434;
    outline: 0;
    background: #090909;
    color: var(--text);
    padding: 0 14px;
    font-size: 16px;
}
.student-form input:focus {
    border-color: rgba(212,176,106,.75);
    box-shadow: 0 0 0 2px rgba(212,176,106,.08);
}
.student-form button,
.scan-main,
.capture-button {
    min-height: 56px;
    border: 1px solid var(--gold);
    background: linear-gradient(90deg, #cda75f, #e5c786);
    color: #090909;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.7px;
}
.student-form button:disabled { opacity: .55; cursor: wait; }
.form-message { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }

.account-hero { border-bottom: 1px solid var(--line); }
.account-hero h1 { text-transform: uppercase; }

.plan-card {
    margin: 20px 22px 0;
    padding: 20px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}
.plan-card strong { display: block; margin-top: 8px; font-size: 22px; }
.plan-card p { margin: 6px 0 0; font-size: 13px; }

.scan-main {
    width: calc(100% - 44px);
    margin: 16px 22px 0;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}
.scan-main strong { display: block; font-size: 13px; }
.scan-main small { display: block; margin-top: 3px; font-size: 10px; letter-spacing: 1px; opacity: .72; }
.scan-icon { font-size: 27px; line-height: 1; }

.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 10px 22px 0;
}
.account-tile {
    min-height: 92px;
    padding: 15px;
    border: 1px solid var(--line);
    background: #0a0a0a;
    color: var(--text);
    text-align: left;
}
.account-tile span { display: block; color: var(--muted); font-size: 9px; letter-spacing: 1.5px; }
.account-tile strong { display: block; margin-top: 10px; color: var(--gold-soft); font-size: 24px; }

.detail-panel {
    margin: 14px 22px 0;
    border: 1px solid var(--line);
    background: #0a0a0a;
}
.detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}
.detail-head h2 { margin: 5px 0 0; font-size: 20px; }
.text-button,
.logout-link,
.secondary-button {
    border: 1px solid #3a3a3a;
    background: transparent;
    color: var(--text);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
}
.text-button { padding: 9px 10px; }
.detail-list { max-height: 280px; overflow: auto; }
.detail-item { padding: 14px 16px; border-bottom: 1px solid #202020; }
.detail-item:last-child { border-bottom: 0; }
.detail-item strong { display: block; font-size: 14px; }
.detail-item small { display: block; margin-top: 5px; font-size: 12px; }

.logout-link {
    width: calc(100% - 44px);
    margin: 18px 22px 24px;
    min-height: 46px;
}

.scanner-view { text-align: center; }
.scanner-welcome { margin-bottom: 20px; }
.scanner-hello {
    margin: 0;
    color: var(--gold);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 2px;
}
.scanner-welcome h1 { color: var(--gold-soft); font-size: clamp(28px, 8vw, 38px); }
.reader {
    width: 100%;
    min-height: 250px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #080808;
}
.reader video { object-fit: cover !important; }
.scanner-message { margin: 14px 0 0; font-size: 13px; }
.scanner-fallback {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}
.capture-button {
    margin-top: 12px;
    min-height: 48px;
    display: grid;
    place-items: center;
}
.capture-button input { display: none; }
.secondary-button {
    width: 100%;
    min-height: 48px;
    margin-top: 16px;
}

footer {
    padding: 17px 22px calc(17px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    text-align: center;
}
.hidden { display: none !important; }

@media (max-width: 520px) {
    .student-shell { padding: 0; place-items: stretch; }
    .student-card { width: 100%; min-height: 100dvh; border: 0; }
    .student-brand { padding-top: calc(17px + env(safe-area-inset-top)); }
}


/* ==========================================
   SCANNER MOBILE · v15.2
========================================== */
.scanner-view {
    padding: 24px 22px 22px;
}

.scanner-welcome {
    margin: 0 auto 18px;
    max-width: 390px;
}

.scanner-hello {
    font-size: 10px;
    letter-spacing: 2.6px;
}

.scanner-welcome h1 {
    max-width: 360px;
    margin: 10px auto 0;
    font-size: clamp(27px, 7vw, 34px);
    line-height: .98;
    letter-spacing: -.7px;
}

.reader {
    width: min(100%, 360px);
    min-height: 0;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border-color: #343434;
    background:
        linear-gradient(90deg, var(--gold) 22px, transparent 22px) top left / 46px 1px no-repeat,
        linear-gradient(var(--gold) 22px, transparent 22px) top left / 1px 46px no-repeat,
        linear-gradient(270deg, var(--gold) 22px, transparent 22px) top right / 46px 1px no-repeat,
        linear-gradient(var(--gold) 22px, transparent 22px) top right / 1px 46px no-repeat,
        linear-gradient(90deg, var(--gold) 22px, transparent 22px) bottom left / 46px 1px no-repeat,
        linear-gradient(0deg, var(--gold) 22px, transparent 22px) bottom left / 1px 46px no-repeat,
        linear-gradient(270deg, var(--gold) 22px, transparent 22px) bottom right / 46px 1px no-repeat,
        linear-gradient(0deg, var(--gold) 22px, transparent 22px) bottom right / 1px 46px no-repeat,
        #080808;
}

.reader > div,
.reader video {
    width: 100% !important;
    height: 100% !important;
}

.scanner-message {
    max-width: 360px;
    margin: 12px auto 0;
    font-size: 12px;
    line-height: 1.5;
}

.scanner-fallback {
    max-width: 360px;
    margin: 14px auto 0;
    padding: 18px 17px;
    text-align: left;
    border-color: #313131;
    background: #0a0a0a;
}

.scanner-fallback-kicker {
    margin: 0 0 9px !important;
    color: var(--gold) !important;
    font-size: 9px !important;
    font-weight: 900;
    letter-spacing: 2px;
}

.scanner-fallback strong {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-size: 15px;
}

.scanner-fallback p:not(.scanner-fallback-kicker) {
    margin: 0;
    font-size: 12px;
    line-height: 1.55;
}

.capture-button-secondary {
    min-height: 44px;
    margin-top: 14px;
    border-color: #3b3b3b;
    background: transparent;
    color: var(--text);
    font-size: 9px;
    letter-spacing: 1.5px;
}

.scanner-view.is-external-scan .reader {
    display: none;
}

.scanner-view.is-external-scan .scanner-message {
    margin-top: 0;
    padding: 10px 12px;
    border: 1px solid #2c2c2c;
    background: #080808;
}

.scanner-view .secondary-button {
    max-width: 360px;
    margin: 14px auto 0;
    display: block;
}

@media (max-width: 520px) {
    .student-brand {
        min-height: 78px;
        padding: calc(13px + env(safe-area-inset-top)) 20px 13px;
    }

    .student-brand img {
        width: 132px;
        max-height: 44px;
    }

    .scanner-view {
        padding: 22px 20px 20px;
    }

    .scanner-welcome {
        margin-bottom: 16px;
    }

    .scanner-welcome h1 {
        max-width: 310px;
        font-size: clamp(26px, 8vw, 32px);
    }

    .scanner-fallback {
        padding: 16px;
    }
}


/* ==========================================
   MI CUENTA · FIT TO SCREEN · v15.3
========================================== */
.student-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    padding: 7px 20px calc(7px + env(safe-area-inset-bottom));
}

.student-partners {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
}

.partner-logo {
    display: block;
    object-fit: contain;
    opacity: .84;
}

.partner-logo-mqr {
    width: 58px;
    height: 38px;
}

.partner-logo-emuna {
    width: 70px;
    height: 38px;
}

.partner-divider {
    width: 1px;
    height: 25px;
    background: #303030;
}

@media (max-width: 520px) {
    html,
    body {
        height: 100%;
    }

    body.is-account-view {
        height: 100dvh;
        overflow: hidden;
    }

    body.is-account-view .student-shell {
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    body.is-account-view .student-card {
        height: 100dvh;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.is-account-view .student-brand {
        flex: 0 0 auto;
        min-height: 70px;
        padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
    }

    body.is-account-view .student-brand img {
        width: 124px;
        max-height: 40px;
    }

    body.is-account-view #accountView:not(.hidden) {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.is-account-view .account-hero {
        flex: 0 0 auto;
        padding: 16px 20px 14px;
    }

    body.is-account-view .account-hero .eyebrow {
        margin: 0;
        font-size: 9px;
        letter-spacing: 1.9px;
    }

    body.is-account-view .account-hero h1 {
        margin: 7px 0 5px;
        font-size: clamp(30px, 9vw, 38px);
        line-height: .98;
    }

    body.is-account-view .account-hero .muted {
        margin: 0;
        font-size: 14px;
        line-height: 1.25;
    }

    body.is-account-view .plan-card {
        flex: 0 0 auto;
        margin: 11px 20px 0;
        padding: 13px 15px;
    }

    body.is-account-view .plan-card > span {
        font-size: 8px;
        letter-spacing: 1.8px;
    }

    body.is-account-view .plan-card strong {
        margin-top: 6px;
        font-size: 19px;
    }

    body.is-account-view .plan-card p {
        margin-top: 4px;
        font-size: 11px;
        line-height: 1.3;
    }

    body.is-account-view .scan-main {
        flex: 0 0 auto;
        min-height: 56px;
        width: calc(100% - 40px);
        margin: 9px 20px 0;
        padding: 11px 15px;
        gap: 12px;
    }

    body.is-account-view .scan-main strong {
        font-size: 11px;
    }

    body.is-account-view .scan-main small {
        font-size: 9px;
    }

    body.is-account-view .scan-icon {
        font-size: 22px;
    }

    body.is-account-view .account-grid {
        flex: 0 0 auto;
        gap: 8px;
        margin: 8px 20px 0;
    }

    body.is-account-view .account-tile {
        min-height: 68px;
        padding: 11px 13px;
    }

    body.is-account-view .account-tile span {
        font-size: 8px;
        letter-spacing: 1.25px;
    }

    body.is-account-view .account-tile strong {
        margin-top: 6px;
        font-size: 21px;
    }

    body.is-account-view .logout-link {
        flex: 0 0 auto;
        width: calc(100% - 40px);
        min-height: 40px;
        margin: 8px 20px 9px;
        font-size: 9px;
    }

    body.is-account-view .student-footer {
        flex: 0 0 auto;
        min-height: 50px;
        padding: 5px 20px calc(5px + env(safe-area-inset-bottom));
    }

    body.is-account-view .partner-logo-mqr {
        width: 50px;
        height: 32px;
    }

    body.is-account-view .partner-logo-emuna {
        width: 61px;
        height: 32px;
    }

    body.is-account-view .partner-divider {
        height: 22px;
    }

    /* Los historiales no agrandan la pantalla principal: se abren encima. */
    body.is-account-view .detail-panel:not(.hidden) {
        position: fixed;
        z-index: 50;
        inset: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
        margin: 0;
        display: flex;
        flex-direction: column;
        background: #090909;
        box-shadow: 0 20px 70px rgba(0,0,0,.78);
    }

    body.is-account-view .detail-list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================
   MI CUENTA · FIRMA DE MARCA · v15.4
   - MI CUENTA limpio arriba
   - 3 logos juntos abajo
   - sin líneas ni separadores
========================================== */
.student-brand {
    justify-content: flex-end;
}

.student-brand > span {
    margin-left: auto;
}

.student-footer {
    border-top: 0;
    background: transparent;
}

.student-partners {
    width: 100%;
    gap: 22px;
}

.partner-logo {
    flex: 0 0 auto;
    opacity: .94;
}

.partner-logo-mambo {
    width: 112px;
    height: 44px;
}

.partner-logo-mqr {
    width: 64px;
    height: 44px;
}

.partner-logo-emuna {
    width: 78px;
    height: 44px;
}

.partner-divider {
    display: none !important;
}

@media (max-width: 520px) {
    body.is-account-view .student-brand {
        min-height: 58px;
        padding: calc(9px + env(safe-area-inset-top)) 20px 9px;
    }

    body.is-account-view .account-hero {
        padding-top: 13px;
    }

    body.is-account-view .student-footer {
        min-height: 66px;
        padding: 8px 18px calc(8px + env(safe-area-inset-bottom));
    }

    body.is-account-view .student-partners {
        gap: 19px;
    }

    body.is-account-view .partner-logo-mambo {
        width: 110px;
        height: 42px;
    }

    body.is-account-view .partner-logo-mqr {
        width: 62px;
        height: 42px;
    }

    body.is-account-view .partner-logo-emuna {
        width: 75px;
        height: 42px;
    }
}

@media (max-width: 370px) {
    .student-partners,
    body.is-account-view .student-partners {
        gap: 14px;
    }

    .partner-logo-mambo,
    body.is-account-view .partner-logo-mambo {
        width: 100px;
    }

    .partner-logo-mqr,
    body.is-account-view .partner-logo-mqr {
        width: 58px;
    }

    .partner-logo-emuna,
    body.is-account-view .partner-logo-emuna {
        width: 70px;
    }
}

/* ==========================================
   ESCÁNER INTEGRADO · RESULTADO · v15.5
========================================== */
.scanner-result {
    width: min(100%, 360px);
    margin: 2px auto 0;
    padding: 24px 20px;
    border: 1px solid #343434;
    background:
        radial-gradient(circle at 50% 0%, rgba(212,176,106,.08), transparent 58%),
        #0a0a0a;
    text-align: left;
}

.scanner-result-kicker {
    display: block;
    margin-bottom: 10px;
    color: var(--green);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 2px;
}

.scanner-result h2 {
    margin: 0;
    color: var(--text);
    font-size: clamp(24px, 7vw, 31px);
    line-height: 1.02;
}

.scanner-result p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.scanner-result .scanner-result-extra {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #252525;
    color: var(--gold-soft);
    font-size: 12px;
    font-weight: 800;
}

.scanner-result.is-info .scanner-result-kicker {
    color: var(--gold-soft);
}

.scanner-result.is-error {
    border-color: #4a3030;
}

.scanner-result.is-error .scanner-result-kicker {
    color: var(--red);
}

.scanner-view.has-result .reader,
.scanner-view.has-result .scanner-fallback {
    display: none !important;
}

.scanner-view.has-result .scanner-welcome {
    margin-bottom: 18px;
}

.scanner-view.has-result .secondary-button {
    margin-top: 12px;
}

@media (max-width: 520px) {
    body.is-scanner-view {
        min-height: 100dvh;
    }

    .scanner-result {
        padding: 22px 18px;
    }
}


/* ==========================================
   PERFIL RESPONSIVE · v16.3
   - Foto/avatar a la derecha del nombre
   - QR solo en teléfono/tablet
========================================== */

.account-profile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.account-identity {
    min-width: 0;
    flex: 1 1 auto;
}

.account-plan-status {
    margin: 9px 0 0;
    color: var(--gold-soft);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

.profile-avatar {
    flex: 0 0 112px;
    width: 112px;
    height: 112px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(212, 176, 106, .48);
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 25%, rgba(229, 202, 145, .13), transparent 35%),
        linear-gradient(145deg, #15130f, #090909 72%);
    box-shadow:
        inset 0 0 0 5px rgba(255,255,255,.015),
        0 16px 40px rgba(0,0,0,.30);
}

.profile-avatar span {
    color: var(--gold-soft);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
}

/* En escritorio el QR no aporta: queda reservado para móvil/tablet. */
@media (min-width: 1025px) {
    body.is-account-view .scan-main {
        display: none;
    }

    body.is-account-view .account-grid {
        margin-top: 16px;
    }
}

@media (max-width: 1024px) {
    .profile-avatar {
        flex-basis: 92px;
        width: 92px;
        height: 92px;
    }

    .profile-avatar span {
        font-size: 23px;
    }
}

@media (max-width: 520px) {
    body.is-account-view .account-profile-hero {
        gap: 16px;
    }

    body.is-account-view .account-identity {
        min-width: 0;
    }

    body.is-account-view .account-plan-status {
        margin-top: 5px;
        font-size: 9px;
        letter-spacing: .9px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.is-account-view .profile-avatar {
        flex: 0 0 70px;
        width: 70px;
        height: 70px;
    }

    body.is-account-view .profile-avatar span {
        font-size: 18px;
    }
}


/* ==========================================
   MI CUENTA · HISTORIAL + DESKTOP FIT · v16.4
========================================== */

.recent-attendance-card {
    margin: 14px 22px 0;
    padding: 16px 17px;
    border: 1px solid var(--line);
    background: #0a0a0a;
}

.recent-attendance-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.recent-attendance-head > div {
    min-width: 0;
}

.recent-attendance-head span {
    display: block;
    color: var(--gold);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.8px;
}

.recent-attendance-head strong {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.history-button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid #383838;
    background: transparent;
    color: var(--gold-soft);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 1.4px;
}

.history-button:hover {
    border-color: rgba(212, 176, 106, .68);
}

.recent-attendance-list {
    margin-top: 10px;
}

.recent-attendance-row {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 0;
    border-top: 1px solid #202020;
}

.recent-attendance-row > div {
    min-width: 0;
}

.recent-attendance-row strong,
.recent-attendance-row small {
    display: block;
}

.recent-attendance-row strong {
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.recent-attendance-row small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.recent-attendance-row time {
    flex: 0 0 auto;
    color: var(--gold-soft);
    font-size: 10px;
    font-weight: 800;
}

.recent-attendance-empty {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}


/* Historial en modal: no agranda la pantalla principal. */
.detail-panel:not(.hidden) {
    position: fixed;
    z-index: 100;
    inset: 50% auto auto 50%;
    width: min(680px, calc(100vw - 30px));
    max-height: min(78dvh, 690px);
    margin: 0;
    display: flex;
    flex-direction: column;
    transform: translate(-50%, -50%);
    overflow: hidden;
    border: 1px solid #383838;
    background: #090909;
    box-shadow:
        0 0 0 100vmax rgba(0,0,0,.72),
        0 28px 90px rgba(0,0,0,.78);
}

.detail-panel:not(.hidden) .detail-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

.history-filters {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: end;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #0b0b0b;
}

.history-filters label {
    display: grid;
    gap: 7px;
}

.history-filters label > span {
    color: var(--gold);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 1.5px;
}

.history-filters select {
    width: 100%;
    height: 38px;
    border: 1px solid #343434;
    outline: 0;
    background: #080808;
    color: var(--text);
    padding: 0 10px;
    font-size: 11px;
}

.history-count {
    margin: 0;
    padding: 0 2px 10px;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}

.attendance-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.attendance-history-item > div {
    min-width: 0;
}

.attendance-history-item time {
    flex: 0 0 auto;
    color: var(--gold-soft);
    font-size: 11px;
    font-weight: 800;
}


/* Escritorio: el contenido completo entra sin scroll de página. */
@media (min-width: 1025px) {
    html,
    body {
        height: 100%;
    }

    body.is-account-view {
        height: 100dvh;
        overflow: hidden;
    }

    body.is-account-view .student-shell {
        height: 100dvh;
        min-height: 0;
        padding: 10px;
        overflow: hidden;
    }

    body.is-account-view .student-card {
        width: min(760px, calc(100vw - 24px));
        height: min(760px, calc(100dvh - 20px));
        max-height: calc(100dvh - 20px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.is-account-view .student-brand {
        flex: 0 0 auto;
        min-height: 54px;
        padding: 11px 26px;
    }

    body.is-account-view #accountView:not(.hidden) {
        flex: 1 1 auto;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "hero hero"
            "plan recent"
            "stats stats"
            "logout logout";
        gap: 12px;
        align-content: start;
        padding: 0 22px 12px;
        overflow: hidden;
    }

    body.is-account-view .account-profile-hero {
        grid-area: hero;
        min-height: 138px;
        margin: 0 -22px;
        padding: 17px 28px;
    }

    body.is-account-view .profile-avatar {
        flex-basis: 102px;
        width: 102px;
        height: 102px;
    }

    body.is-account-view .profile-avatar span {
        font-size: 25px;
    }

    body.is-account-view .plan-card {
        grid-area: plan;
        min-height: 136px;
        margin: 0;
        padding: 16px 18px;
    }

    body.is-account-view .recent-attendance-card {
        grid-area: recent;
        min-height: 136px;
        margin: 0;
        padding: 14px 16px;
    }

    body.is-account-view .recent-attendance-row:nth-child(n + 3) {
        display: none;
    }

    body.is-account-view .account-grid {
        grid-area: stats;
        margin: 0;
        gap: 12px;
    }

    body.is-account-view .account-tile {
        min-height: 70px;
        padding: 12px 15px;
    }

    body.is-account-view .account-tile strong {
        margin-top: 6px;
        font-size: 22px;
    }

    body.is-account-view .logout-link {
        grid-area: logout;
        width: 100%;
        min-height: 42px;
        margin: 0;
    }

    body.is-account-view .student-footer {
        flex: 0 0 58px;
        min-height: 58px;
        padding: 4px 18px;
    }
}


/* Teléfono: mantenemos la pantalla principal compacta. */
@media (max-width: 520px) {
    body.is-account-view .recent-attendance-card {
        display: none;
    }

    .history-filters {
        grid-template-columns: 1fr 1fr;
    }

    .history-count {
        grid-column: 1 / -1;
        padding-bottom: 0;
    }

    .detail-panel:not(.hidden) {
        inset: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
        width: auto;
        max-height: none;
        transform: none;
    }
}


/* ==========================================
   HISTORIAL · REFINAMIENTO v16.4.1
========================================== */

.history-close {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border: 1px solid #3b3b3b;
    background: transparent;
    color: var(--text);
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    transition:
        border-color .2s ease,
        color .2s ease,
        background .2s ease;
}

.history-close:hover {
    border-color: rgba(212,176,106,.75);
    color: var(--gold-soft);
    background: rgba(212,176,106,.04);
}

.history-total {
    min-height: 54px;
    padding: 9px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid #2f2f2f;
    background: #090909;
}

.history-total span {
    display: block;
    color: var(--muted);
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.history-total strong {
    display: block;
    margin-top: 4px;
    color: var(--gold-soft);
    font-size: 17px;
    line-height: 1;
}

/* El nombre de la clase ya alcanza: quitamos subtítulos redundantes. */
.attendance-history-item strong {
    font-size: 14px;
}

.recent-attendance-row strong {
    margin: 0;
}

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

    .history-total {
        grid-column: 1 / -1;
        min-height: 48px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .history-total strong {
        margin-top: 0;
        font-size: 18px;
    }
}


/* ==========================================
   PRÓXIMAS CLASES · v17.2
   Bloque aislado para preservar el estilo actual.
========================================== */

.upcoming-classes-card {
    margin: 14px 22px 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: #0a0a0a;
}

.upcoming-classes-head span {
    display: block;
    color: var(--gold);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.8px;
}

.upcoming-classes-head strong {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.upcoming-classes-list {
    margin-top: 9px;
}

.upcoming-class-row {
    padding: 7px 0;
    border-top: 1px solid #202020;
}

.upcoming-class-row strong,
.upcoming-class-row small {
    display: block;
}

.upcoming-class-row strong {
    overflow: hidden;
    color: var(--text);
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.upcoming-class-row small {
    margin-top: 3px;
    color: var(--gold-soft);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .8px;
}

.upcoming-classes-empty {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

@media (min-width: 1025px) {
    body.is-account-view #accountView:not(.hidden) {
        grid-template-areas:
            "hero hero"
            "plan upcoming"
            "recent recent"
            "stats stats"
            "logout logout";
        gap: 10px;
    }

    body.is-account-view .account-profile-hero {
        min-height: 118px;
        padding-top: 13px;
        padding-bottom: 13px;
    }

    body.is-account-view .profile-avatar {
        flex-basis: 92px;
        width: 92px;
        height: 92px;
    }

    body.is-account-view .plan-card {
        grid-area: plan;
        min-height: 112px;
        padding: 14px 16px;
    }

    body.is-account-view .upcoming-classes-card {
        grid-area: upcoming;
        min-height: 112px;
        margin: 0;
        padding: 12px 15px;
    }

    body.is-account-view .upcoming-class-row {
        padding: 5px 0;
    }

    body.is-account-view .upcoming-class-row:nth-child(n + 3) {
        display: none;
    }

    body.is-account-view .recent-attendance-card {
        grid-area: recent;
        min-height: 92px;
        padding-top: 11px;
        padding-bottom: 11px;
    }

    body.is-account-view .recent-attendance-row {
        padding: 6px 0;
    }

    body.is-account-view .recent-attendance-row:nth-child(n + 2) {
        display: none;
    }

    body.is-account-view .account-tile {
        min-height: 62px;
    }
}

@media (max-width: 520px) {
    body.is-account-view .upcoming-classes-card {
        margin-top: 10px;
        padding: 11px 14px;
    }

    body.is-account-view .upcoming-classes-head strong {
        display: none;
    }

    body.is-account-view .upcoming-classes-list {
        margin-top: 7px;
    }

    body.is-account-view .upcoming-class-row {
        padding: 5px 0;
    }

    body.is-account-view .upcoming-class-row:nth-child(n + 3) {
        display: none;
    }

    body.is-account-view .upcoming-class-row strong {
        font-size: 10px;
    }

    body.is-account-view .upcoming-class-row small {
        font-size: 8px;
    }
}


/* ==========================================
   PRÓXIMAS CLASES · AJUSTE DESKTOP v17.2.1
   Evita que la segunda clase quede cortada.
========================================== */

@media (min-width: 1025px) {
    body.is-account-view .upcoming-classes-head strong {
        display: none;
    }

    body.is-account-view .upcoming-classes-list {
        margin-top: 6px;
    }

    body.is-account-view .upcoming-class-row {
        padding: 7px 0;
    }

    body.is-account-view .upcoming-class-row > div {
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    body.is-account-view .upcoming-class-row strong {
        min-width: 0;
        flex: 1 1 auto;
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.is-account-view .upcoming-class-row small {
        flex: 0 0 auto;
        margin-top: 0;
        font-size: 8px;
        white-space: nowrap;
    }
}

/* Historial por categoría · v18 */
.attendance-history-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 1.1px;
}

/* Login compacto: mantiene los campos y el mensaje visibles sin recortar contenido. */
body.is-login-view .student-shell {
    padding: 16px;
    place-items: center;
}
body.is-login-view .student-card {
    width: min(100%, 420px);
    min-height: 0;
    border: 1px solid var(--line);
}
body.is-login-view .student-brand {
    min-height: 36px;
    padding: 10px 20px;
}
body.is-login-view #loginView { padding: 18px 20px; }
body.is-login-view #loginView .eyebrow { margin: 0 0 8px; font-size: 9px; }
body.is-login-view #loginView h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.1; }
body.is-login-view #loginView > .muted { margin: 0; font-size: 13px; line-height: 1.5; }
body.is-login-view .student-form { margin-top: 18px; gap: 12px; }
body.is-login-view .student-form label { gap: 6px; }
body.is-login-view .student-form input { height: 44px; font-size: 16px; }
body.is-login-view .student-form button { min-height: 44px; }
body.is-login-view .form-message { min-height: 0; font-size: 12px; line-height: 1.4; }
body.is-login-view .form-message:empty { display: none; }
body.is-login-view .student-footer { padding: 8px 20px 16px; }
body.is-login-view .student-partners { gap: 18px; }
body.is-login-view .partner-logo-mambo { width: 86px; height: 38px; object-fit: contain; }
body.is-login-view .partner-logo-mqr { width: 42px; height: 42px; object-fit: contain; }
body.is-login-view .partner-logo-emuna { width: 70px; height: 42px; object-fit: contain; }
@media (max-width: 520px) {
    body.is-login-view .student-shell { padding: 12px; }
}

/* Perfil adaptable: contenido y pie en flujo, sin recortar Cerrar sesión. */
body.is-account-view { height: auto; min-height: 100dvh; overflow: auto; }
body.is-account-view .student-shell {
    height: auto; min-height: 100dvh; padding: 12px;
    overflow: visible; place-items: center;
}
body.is-account-view .student-card {
    width: min(680px, 100%); height: auto; min-height: 0; max-height: none;
    display: flex; flex-direction: column; overflow: visible;
}
body.is-account-view .student-brand { min-height: 36px; padding: 10px 18px; }
body.is-account-view #accountView:not(.hidden) {
    flex: 0 0 auto; overflow: visible; min-height: 0;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "hero hero" "plan upcoming" "recent recent" "stats stats" "logout logout";
    gap: 10px; padding: 0 16px 12px;
}
body.is-account-view .account-profile-hero {
    grid-area: hero; min-height: 0; margin: 0 -16px; padding: 14px 18px; gap: 16px;
}
body.is-account-view .account-identity { min-width: 0; }
body.is-account-view .account-hero h1 { font-size: 26px; line-height: 1.1; margin: 0 0 6px; overflow-wrap: anywhere; }
body.is-account-view .account-hero .muted { font-size: 13px; margin: 0; }
body.is-account-view .account-plan-status { margin: 7px 0 0; font-size: 10px; }
body.is-account-view .profile-avatar { flex: 0 0 64px; width: 64px; height: 64px; }
body.is-account-view .profile-avatar span { font-size: 20px; }
body.is-account-view .plan-card,
body.is-account-view .upcoming-classes-card,
body.is-account-view .recent-attendance-card { min-height: 0; margin: 0; padding: 12px; }
body.is-account-view .plan-card { grid-area: plan; }
body.is-account-view .upcoming-classes-card { grid-area: upcoming; }
body.is-account-view .recent-attendance-card { grid-area: recent; }
body.is-account-view .plan-card strong { font-size: 20px; margin-top: 6px; }
body.is-account-view .plan-card p { font-size: 12px; margin: 6px 0 0; }
body.is-account-view .upcoming-class-row > div { display: block; }
body.is-account-view .upcoming-class-row strong { white-space: normal; overflow: visible; font-size: 11px; }
body.is-account-view .upcoming-class-row small { white-space: normal; margin-top: 3px; font-size: 9px; }
body.is-account-view .account-grid { grid-area: stats; margin: 0; gap: 10px; }
body.is-account-view .account-tile { min-height: 54px; padding: 10px 12px; }
body.is-account-view .account-tile strong { margin-top: 4px; font-size: 20px; }
body.is-account-view .logout-link {
    grid-area: logout; width: 100%; min-height: 44px; margin: 0; padding: 10px;
    flex-shrink: 0; font-size: 11px;
}
body.is-account-view .student-footer { flex: 0 0 auto; min-height: 0; padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); }
body.is-account-view .student-partners { gap: 20px; }
body.is-account-view .partner-logo-mambo { width: 86px; height: 38px; object-fit: contain; }
body.is-account-view .partner-logo-mqr { width: 42px; height: 38px; object-fit: contain; }
body.is-account-view .partner-logo-emuna { width: 64px; height: 38px; object-fit: contain; }
@media (max-width: 1024px) {
    body.is-account-view .student-card { width: min(480px, 100%); }
    body.is-account-view #accountView:not(.hidden) {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "hero" "plan" "upcoming" "scan" "stats" "logout";
        gap: 8px; padding: 0 14px 10px;
    }
    body.is-account-view .account-profile-hero { margin: 0 -14px; padding: 12px 16px; }
    body.is-account-view .account-hero h1 { font-size: 24px; }
    body.is-account-view .recent-attendance-card { display: none; }
    body.is-account-view .scan-main { grid-area: scan; width: 100%; margin: 0; min-height: 52px; padding: 10px 14px; }
    body.is-account-view .upcoming-classes-head strong { display: none; }
    body.is-account-view .upcoming-classes-list { margin-top: 6px; }
    body.is-account-view .upcoming-class-row { padding: 5px 0; }
}
@media (max-width: 520px) {
    body.is-account-view .student-shell { padding: 0; }
    body.is-account-view .student-card { border: 0; }
    body.is-account-view .student-brand { padding-top: calc(10px + env(safe-area-inset-top)); }
}
