:root {
    --navy: #332d85;
    --accent: #1a5ce0;
    --fondo: #eef2fb;
    --texto: #1d2140;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Outfit, sans-serif;
    background: var(--fondo);
    color: var(--texto);
}

.af-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--navy);
    color: #fff;
}

.af-top img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    object-fit: contain;
}

.af-top strong, .af-top span { display: block; }
.af-top span { font-size: 13px; opacity: .8; }
.af-top-acciones {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.af-salir { color: #fff; font-weight: 600; text-decoration: none; }
.af-campana {
    position: relative;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.af-campana span {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e23b3b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.af-aviso-item {
    display: block;
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e6ebf5;
    color: inherit;
    text-decoration: none;
}
.af-aviso-item time, .af-aviso-item span { font-size: .85rem; color: #5c647d; }
.af-aviso-item span { float: right; font-weight: 700; }
.af-aviso-item p { margin: 8px 0 0; clear: both; }
.af-aviso-item.no-leido { background: #f4f6ff; }
.af-aviso-item.no-leido p { font-weight: 700; }
.af-aviso-item.no-leido span { color: var(--accent); }
.af-aviso-texto { white-space: pre-wrap; line-height: 1.5; }

.af-main {
    width: min(640px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.af-card, .carnet {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(26, 22, 72, .08);
}

h1 { margin: 0 0 8px; font-size: 1.6rem; color: var(--navy); }

.af-ayuda { color: #5c647d; line-height: 1.45; }
.af-ayuda ul { padding-left: 18px; }

.af-form label, .af-form .form-label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 600;
}

.af-input, .af-form input, .af-form select, .form-control {
    width: 100%;
    min-height: 48px;
    border: 1px solid #cfd5e6;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}

.af-boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: 18px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.af-boton-chico { width: auto; margin-top: 0; padding: 0 16px; }
.af-boton:disabled,
.af-boton.is-inactivo {
    opacity: .55;
    pointer-events: none;
}
.af-centro { text-align: center; }
.af-centro a, .af-ayuda a { color: var(--accent); }

.af-aviso { padding: 12px 14px; border-radius: 12px; }
.af-aviso-ok { background: #e7f7ee; color: #146c43; }
.af-aviso-error { background: #fdecec; color: #9b1c1c; }
.form-errors { color: #9b1c1c; padding-left: 18px; }

.af-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
    border-bottom: 1px solid #d9dfef;
}

.af-nav a {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    color: #5c647d;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.15;
}

.af-beneficio {
    display: block;
    padding: 14px 0;
    border-top: 1px solid #e6ebf5;
}

.af-beneficio h2 { margin: 0 0 6px; font-size: 1.15rem; }
.af-beneficio p { margin: 0 0 8px; }
.af-beneficio .af-input { margin-bottom: 8px; }
.af-excluidos { margin: 8px 0 0; padding-left: 18px; color: #5c647d; }

.af-nav a.activo { color: var(--navy); }

.carnet header, .af-encabezado, .af-item {
    display: flex;
    gap: 12px;
    align-items: center;
}

.carnet header img { width: 54px; height: 54px; object-fit: contain; }
.carnet header span, .af-item span { display: block; color: #5c647d; }
.carnet h1 { margin-top: 18px; }
.carnet-qr { display: block; width: min(240px, 70vw); margin: 18px auto 0; }

.af-encabezado { justify-content: space-between; margin-bottom: 12px; }
.af-encabezado h1 { margin: 0; }
.af-item {
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid #e6ebf5;
}
.af-estado-ok { color: #146c43; font-weight: 700; }
.af-estado-no { color: #9b1c1c; font-weight: 700; }

.af-datos { margin: 0; }
.af-datos > div { padding: 10px 0; border-top: 1px solid #e6ebf5; }
.af-datos dt { font-size: .85rem; color: #5c647d; }
.af-datos dd { margin: 2px 0 0; font-weight: 600; }

.af-dato-actualizar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid #e6ebf5;
}

.af-dato-actualizar dd { margin: 2px 0 8px; }
.af-dato-actualizar dd:last-child { margin-bottom: 0; }

.af-boton-linea {
    background: #fff;
    color: var(--navy);
    border: 2px solid var(--navy);
}

.af-acceso {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f4f6ff;
}

.af-acceso p { margin: 0 0 12px; line-height: 1.45; }
.af-acceso .af-acceso-iphone { display: none; }
.af-acceso.es-iphone .af-acceso-android { display: none; }
.af-acceso.es-iphone .af-acceso-iphone { display: block; }
.af-acceso .af-boton-chico { width: 100%; }

.af-obligatorio {
    color: #c62828;
    font-weight: 700;
}

.af-req {
    list-style: none;
    margin: 14px 0 0;
    padding: 12px 14px;
    background: #f4f6ff;
    border: 1px solid #d6d9f0;
    border-radius: 12px;
}

.af-req li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    color: #5c647d;
    font-size: .9rem;
    font-weight: 600;
}

.af-req li::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    flex: none;
    box-sizing: border-box;
}

.af-req li.is-ok { color: #1e5a45; }

.af-req li.is-ok::before {
    content: "";
    background: #2e7d32 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.2 6.4 11l6.1-6.2'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
    border-color: #2e7d32;
}

body.pagina-carnet {
    background: #eef2fb;
    padding: 0;
    color: var(--texto);
}

.af-foto {
    width: 96px;
    height: 96px;
    margin: 0 auto 14px;
    display: block;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e6ebf5;
}

.carnet-vista {
    container-type: inline-size;
    width: 100%;
    max-width: 516px;
    aspect-ratio: 516 / 324;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

body.pagina-carnet .carnet-header h1 {
    color: #fff;
}

body.pagina-carnet .carnet-vista .carnet-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 516px !important;
    height: 324px !important;
    transform: scale(calc(100cqw / 516px));
    transform-origin: top left;
}

.carnet-cerrar {
    display: none;
}

body.carnet-abierto {
    overflow: hidden;
    background: #070226;
}

body.carnet-abierto .af-top,
body.carnet-abierto .af-nav,
body.carnet-abierto .carnet-actions {
    display: none;
}

body.carnet-abierto .af-main {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    background: #070226;
}

#carnet-pantalla:fullscreen,
#carnet-pantalla:-webkit-full-screen {
    width: 100%;
    height: 100%;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #070226;
    padding: 52px 8px 8px;
}

#carnet-pantalla:fullscreen .carnet-vista,
#carnet-pantalla:-webkit-full-screen .carnet-vista,
body.carnet-abierto .carnet-vista {
    width: min(100%, calc((100vh - 60px) * 516 / 324));
    max-width: none;
    cursor: default;
}

body.carnet-abierto .carnet-cerrar {
    display: inline-flex;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 20;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: var(--navy);
    font: inherit;
    font-weight: 700;
}

.carnet-ayuda {
    margin: 10px 0 0;
    text-align: center;
    color: #5c647d;
    font-size: .9rem;
}

body.carnet-abierto .carnet-ayuda {
    display: none;
}
