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

        :root {
            --brand-primary: var(--brand, var(--sx-primary));
            --brand-dark: var(--sx-primary-hover, #0A6382);
            --brand-light: var(--brand-light, var(--sx-primary-soft));
            --brand-soft: var(--brand-soft, var(--sx-primary-soft));
            --bg-main: var(--bg-main);
            --text-primary: var(--text-primary);
            --text-secondary: var(--text-secondary);
            --text-muted: var(--text-muted);
            --surface: #FFFFFF;
            --border: rgba(0,0,0,0.06);
            --success: var(--success);
            --danger: var(--danger);
            --radius-xl: 20px;
            --radius-lg: 16px;
            --radius-md: 12px;
            --radius-sm: 8px;
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
            --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
            --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
        }

        .apply-page {
            font-family: var(--font, system-ui), 'Segoe UI', Roboto, sans-serif;
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            background: var(--bg-main);
            -webkit-font-smoothing: antialiased;
        }

        /* ── Desktop layout ── */
        @media (min-width: 768px) {
            .apply-page {
                height: auto;
                min-height: 100vh;
                overflow: auto;
                background: linear-gradient(135deg, var(--sx-surface-3) 0%, var(--sx-surface-3) 100%);
                align-items: flex-start;
                justify-content: center;
                padding: 48px 24px;
            }
        }

        .shell {
            display: flex;
            flex-direction: column;
            height: 100%;
            max-width: 520px;
            width: 100%;
            margin: 0 auto;
            background: var(--surface);
        }

        .shell--modal {
            display: flex;
            flex-direction: column;
            max-height: calc(100dvh - 32px);
            height: calc(100dvh - 32px);
            max-width: 680px;
            overflow: hidden;
            border-radius: var(--radius-xl);
            box-shadow: var(--shadow-lg);
        }
        .shell--modal .form-body {
            flex: 1 1 auto;
            min-height: 0;
            overflow-y: auto;
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
        }
        .shell--modal .form-footer {
            flex-shrink: 0;
            position: sticky;
            bottom: 0;
            z-index: 4;
            background: var(--surface);
            box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.07);
        }
        .shell--modal .brand-header,
        .shell--modal .powered-by {
            flex-shrink: 0;
        }

        @media (min-width: 768px) {
            .shell--modal {
                height: auto;
                max-height: calc(100dvh - 32px);
                overflow: hidden;
            }
            .shell--modal .form-body {
                overflow-y: auto;
            }
        }


        /* Tablet: tarjeta flotante pequeña */
        @media (min-width: 560px) and (max-width: 767px) {
            .apply-page { background: var(--sx-surface-3); }
            .shell {
                height: calc(100dvh - 40px);
                margin-top: 20px;
                border-radius: var(--radius-xl);
                overflow: hidden;
                border: 1px solid var(--border);
                box-shadow: var(--shadow-lg);
            }
        }

        /* Desktop: tarjeta más ancha, altura natural */
        @media (min-width: 768px) {
            .shell {
                max-width: 680px;
                height: auto;
                border-radius: var(--radius-xl);
                overflow: visible;
                border: 1px solid var(--border);
                box-shadow: var(--shadow-lg);
                margin: 0 auto;
            }
            /* Modal en landing: no heredar overflow:visible de .shell */
            .shell.shell--modal {
                overflow: hidden;
                max-height: calc(100dvh - 32px);
            }
            .shell.shell--modal .form-body {
                overflow-y: auto;
            }
        }

        /* ── Brand Header ── */
        .brand-header {
            background: var(--brand-primary);
            padding: 0;
            flex-shrink: 0;
            position: relative;
        }

        @media (min-width: 768px) {
            .brand-header {
                border-top-left-radius: var(--radius-xl);
                border-top-right-radius: var(--radius-xl);
            }
        }
        .brand-header::after {
            content: '';
            position: absolute;
            bottom: 0; left: 0; right: 0;
            height: 3px;
            background: linear-gradient(90deg, var(--brand-dark), var(--brand-primary), var(--brand-dark));
            opacity: 0.4;
        }
        .header-main {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 14px 18px;
        }
        .header-logo {
            width: 42px; height: 42px;
            border-radius: var(--radius-sm);
            background: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0,0,0,0.12);
        }
        .header-logo img {
            width: 100%; height: 100%;
            object-fit: contain;
            padding: 3px;
        }
        .header-logo .logo-placeholder {
            font-size: 18px; font-weight: 800;
            color: var(--brand-primary);
            text-transform: uppercase;
        }
        .header-info { flex: 1; min-width: 0; }
        .header-info h1 {
            font-size: 15px; font-weight: 700;
            color: #fff; line-height: 1.2;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        .header-info .sub {
            font-size: 11px; color: rgba(255,255,255,0.75);
            margin-top: 2px; font-weight: 500;
            letter-spacing: 0.3px; text-transform: uppercase;
        }

        /* ── Form body ── */
        .form-body {
            flex: 1;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 24px 20px 20px;
            background: var(--bg-main);
        }

        @media (min-width: 768px) {
            .form-body {
                overflow-y: visible;
                padding: 32px 36px 28px;
                border-radius: 0;
            }
            .shell--modal .form-body {
                overflow-y: auto;
                padding: 24px 20px 20px;
            }
        }

        .form-intro {
            text-align: center;
            margin-bottom: 24px;
        }
        .form-intro h2 {
            font-size: 20px; font-weight: 700;
            color: var(--text-primary);
        }
        .form-intro p {
            font-size: 13px; color: var(--text-secondary);
            margin-top: 6px; line-height: 1.5;
        }

        .error-banner {
            background: rgba(229, 62, 62, 0.06);
            border: 1px solid rgba(229, 62, 62, 0.18);
            border-radius: var(--radius-md);
            padding: 12px 16px;
            margin-bottom: 20px;
            color: var(--danger);
            font-size: 13px;
            line-height: 1.5;
        }
        .error-banner ul { margin: 6px 0 0 16px; }
        .error-banner li { margin-bottom: 2px; }

        .form-group { margin-bottom: 16px; }

        .form-label {
            display: block;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 6px;
        }
        .form-label .req { color: var(--danger); margin-left: 2px; }

        .form-input,
        .form-select,
        .form-textarea {
            width: 100%;
            padding: 11px 14px;
            border: 1.5px solid var(--border-strong);
            border-radius: var(--radius-md);
            font-size: 15px;
            color: var(--text-primary);
            background: var(--surface);
            transition: border-color var(--sx-base), box-shadow var(--sx-base);
            outline: none;
            font-family: inherit;
        }

        .form-input:focus,
        .form-select:focus,
        .form-textarea:focus {
            border-color: var(--brand-primary);
            box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
        }

        .form-input.error,
        .form-textarea.error { border-color: var(--danger); }
        .form-textarea { resize: vertical; min-height: 90px; }

        /* Ocultar flechas de inputs numéricos */
        .form-input[type="number"]::-webkit-outer-spin-button,
        .form-input[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        .form-input[type="number"] {
            -moz-appearance: textfield;
        }

        .field-hint {
            display: block;
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 6px;
            line-height: 1.4;
            transition: color var(--sx-base);
        }
        .field-hint.error { color: var(--danger); font-weight: 600; }
        .field-hint.ok { color: var(--success); font-weight: 600; }

        /* ── T&C ── */
        .tnc-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 10px;
            flex-wrap: wrap;
        }

        .btn-print {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 5px 12px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: var(--surface);
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            cursor: pointer;
            white-space: nowrap;
            transition: background var(--sx-base);
            flex-shrink: 0;
        }
        .btn-print svg { width: 14px; height: 14px; }
        .btn-print:hover { background: var(--border-strong); }

        .tnc-wrapper {
            position: relative;
            display: flex;
            flex-direction: column;
            border: 1px solid var(--border-strong);
            border-radius: var(--radius-md);
            overflow: hidden;
        }

        .tnc-section {
            max-height: 200px;
            overflow-y: auto;
            padding: 16px;
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.7;
            background: var(--surface);
            overscroll-behavior: contain;
            touch-action: pan-y;
        }
        .shell--modal .tnc-section {
            max-height: min(240px, 32vh);
        }
        /* La barra se ve siempre: es la señal de que el texto sigue. Con la
           barra fina y casi transparente de antes, en móvil no aparecía hasta
           tocar y nadie sabía que había que bajar. */
        .tnc-section { scrollbar-width: auto; scrollbar-color: var(--brand-primary, #0B7A9F) rgba(0,0,0,.07); }
        .tnc-section::-webkit-scrollbar { width: 10px; }
        .tnc-section::-webkit-scrollbar-track { background: rgba(0,0,0,0.07); border-radius: 6px; }
        .tnc-section::-webkit-scrollbar-thumb {
            background: var(--brand-primary, #0B7A9F); border-radius: 6px;
            border: 3px solid transparent; background-clip: content-box;
        }
        .tnc-section::-webkit-scrollbar-thumb:hover { background-clip: border-box; }

        .tnc-progress-bar {
            width: 100%; height: 6px;
            background: var(--border-strong);
            overflow: hidden;
            flex-shrink: 0;
        }
        .tnc-progress-fill {
            height: 100%; width: 0%;
            background: linear-gradient(90deg, var(--sx-primary, var(--brand-primary)), var(--sx-primary-hover, var(--brand-dark)));
            transition: width 0.12s ease-out, background var(--sx-slow, 0.25s ease);
        }
        .tnc-progress-fill.complete { background: linear-gradient(90deg, var(--success), var(--success)); }

        /* El pie es el control de lectura: dice cuánto llevas y baja una
           pantalla al tocarlo. Antes esto era un letrero y encima del texto
           flotaba una pastilla de «seguir leyendo» que partía la línea que se
           estaba leyendo. Un solo sitio, y ninguno tapa nada. */
        .tnc-scroll-hint {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            width: 100%;
            padding: 10px 14px;
            background: var(--bg-main);
            color: var(--text-muted);
            font-family: inherit;
            font-size: 11.5px;
            font-weight: 600;
            border: 0;
            border-top: 1px solid var(--border-strong);
            flex-shrink: 0;
            cursor: pointer;
            transition: background var(--sx-slow), color var(--sx-slow);
        }
        .tnc-scroll-hint:disabled { cursor: default; }
        .tnc-scroll-hint:not(:disabled):hover {
            background: color-mix(in srgb, var(--sx-primary, var(--brand-primary)) 16%, var(--bg-main));
        }
        .tnc-scroll-hint:not(:disabled):active { padding-top: 11px; padding-bottom: 9px; }
        .tnc-scroll-hint.is-scrolling {
            background: color-mix(in srgb, var(--sx-primary, var(--brand-primary)) 8%, var(--bg-main));
            color: var(--sx-primary, var(--brand-primary));
        }
        .tnc-scroll-hint svg {
            width: 13px; height: 13px; flex-shrink: 0;
            animation: bounceDown 1.5s infinite;
        }
        .tnc-scroll-hint.complete {
            background: rgba(56,161,105,0.06);
            color: var(--success);
        }
        .tnc-scroll-hint.complete svg { animation: none; }
        @keyframes bounceDown {
            0%, 100% { transform: translateY(0); }
            50%      { transform: translateY(3px); }
        }

        .divider {
            border: none;
            border-top: 1px solid var(--border-strong);
            margin: 24px 0;
        }

        .check-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            margin-bottom: 16px;
            cursor: pointer;
        }
        .check-row input[type="checkbox"] {
            width: 18px; height: 18px;
            margin-top: 1px;
            cursor: pointer;
            flex-shrink: 0;
            accent-color: var(--brand-primary);
        }
        .check-row span {
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.5;
        }
        .check-row input:disabled + span { opacity: 0.45; }

        /* ── Footer ── */
        .form-footer {
            padding: 16px 20px;
            padding-bottom: max(16px, env(safe-area-inset-bottom));
            border-top: 1px solid var(--border);
            background: var(--surface);
            flex-shrink: 0;
        }

        @media (min-width: 768px) {
            .form-footer {
                padding: 24px 36px 32px;
            }
        }

        /* Evitar que selexion-bridge.css pise el hover del botón en el modal */
        .apply-public .btn-submit {
            position: relative;
            z-index: 1;
            transform: none !important;
            opacity: 1 !important;
            visibility: visible !important;
            background: var(--brand-primary) !important;
            color: #fff !important;
            border: none !important;
        }
        .apply-public .btn-submit:hover:not(:disabled),
        .apply-public .btn-submit:focus-visible:not(:disabled) {
            background: var(--brand-dark) !important;
            color: #fff !important;
            box-shadow: 0 2px 8px color-mix(in srgb, var(--brand-primary) 30%, transparent) !important;
            transform: none !important;
        }
        .apply-public .btn-submit:active:not(:disabled) {
            transform: scale(0.99) !important;
            background: var(--brand-dark) !important;
            color: #fff !important;
        }
        .apply-public .btn-submit:disabled {
            opacity: 0.45 !important;
            color: #fff !important;
        }

        .btn-submit {
            width: 100%;
            padding: 14px;
            border: none;
            border-radius: var(--radius-md);
            background: var(--brand-primary);
            color: #fff;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: background var(--sx-base), transform var(--sx-fast);
            box-shadow: 0 2px 8px color-mix(in srgb, var(--brand-primary) 30%, transparent);
        }
        .btn-submit:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
        .btn-submit:active:not(:disabled) { transform: scale(0.98); }
        .btn-submit:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; color: #fff; }

        .privacy-note {
            font-size: 11px;
            color: var(--text-muted);
            text-align: center;
            margin-top: 12px;
            line-height: 1.5;
        }

        .powered-by {
            text-align: center; padding: 6px; font-size: 10px;
            color: var(--text-muted); background: var(--surface);
            border-top: 1px solid var(--border); flex-shrink: 0; letter-spacing: 0.3px;
        }
        .powered-by span { font-weight: 600; color: var(--text-secondary); }

        @media (min-width: 768px) {
            .powered-by {
                border-bottom-left-radius: var(--radius-xl);
                border-bottom-right-radius: var(--radius-xl);
            }
        }


        .hp-field { position: absolute; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; }

        .name-warning {
            display: flex;
            gap: 12px;
            background: rgba(237, 137, 54, 0.08);
            border: 1px solid rgba(237, 137, 54, 0.25);
            border-radius: var(--radius-md);
            padding: 14px 16px;
            margin-bottom: 20px;
        }
        .name-warning-icon { flex-shrink: 0; color: var(--brand); margin-top: 1px; }
        .name-warning-body { flex: 1; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
        .name-warning-body strong { color: var(--text-primary); display: block; margin-bottom: 4px; }
        .name-official {
            font-weight: 700;
            color: var(--text-primary);
            font-size: 15px;
            background: #ffffff;
            padding: 6px 10px;
            border-radius: var(--radius-sm);
            margin: 6px 0;
            border: 1px solid rgba(0,0,0,0.06);
        }
        .btn-use-name {
            display: inline-block;
            margin-top: 6px;
            padding: 7px 16px;
            border: none;
            border-radius: var(--radius-sm);
            background: var(--brand-primary);
            color: #fff;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: background var(--sx-base);
        }
        .btn-use-name:hover { background: var(--brand-dark); }

        .blocked-banner {
            display: flex;
            gap: 12px;
            background: rgba(229, 62, 62, 0.07);
            border: 1px solid rgba(229, 62, 62, 0.22);
            border-radius: var(--radius-md);
            padding: 16px;
            margin-bottom: 20px;
        }
        .blocked-banner-icon { flex-shrink: 0; color: var(--danger); margin-top: 1px; }
        .blocked-banner-body { flex: 1; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
        .blocked-banner-body strong { color: var(--danger); display: block; margin-bottom: 4px; font-size: 14px; }
    </style>

/* ═══ Entrada del formulario ═══════════════════════════════════════════════
   El formulario llega después del sello de «Correo confirmado», así que no
   debe aparecer de golpe: la tarjeta sube, y los campos entran en cascada.
   Sólo en la página propia (`.apply-page`), no en el modal del landing, que
   ya tiene su propia transición de apertura. */
.apply-page .shell.apply-public {
    animation: sxCardIn .55s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes sxCardIn {
    from { opacity: 0; transform: translateY(18px) scale(.985); }
    to   { opacity: 1; transform: none; }
}
.apply-page .form-intro,
.apply-page .form-group,
.apply-page .consent-block,
.apply-page .submit-row,
.apply-page button[type="submit"] {
    animation: sxFieldIn .45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes sxFieldIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.apply-page .form-intro          { animation-delay: .10s; }
.apply-page .form-group:nth-of-type(1)  { animation-delay: .16s; }
.apply-page .form-group:nth-of-type(2)  { animation-delay: .21s; }
.apply-page .form-group:nth-of-type(3)  { animation-delay: .26s; }
.apply-page .form-group:nth-of-type(4)  { animation-delay: .31s; }
.apply-page .form-group:nth-of-type(5)  { animation-delay: .36s; }
.apply-page .form-group:nth-of-type(6)  { animation-delay: .40s; }
.apply-page .form-group:nth-of-type(7)  { animation-delay: .44s; }
.apply-page .form-group:nth-of-type(n+8){ animation-delay: .48s; }
.apply-page .consent-block,
.apply-page .submit-row,
.apply-page button[type="submit"] { animation-delay: .54s; }

/* Un campo bloqueado (el correo que acaba de confirmarse) se señala una vez:
   así se entiende que ya viene resuelto y no hay que escribirlo. */
.apply-page input[readonly], .apply-page input:disabled {
    animation: sxLockedGlow 1.5s ease-out .7s 1;
}
@keyframes sxLockedGlow {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sx-primary, #0B7A9F) 45%, transparent); }
    100% { box-shadow: 0 0 0 12px transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .apply-page .shell.apply-public,
    .apply-page .form-intro, .apply-page .form-group, .apply-page .consent-block,
    .apply-page .submit-row, .apply-page button[type="submit"],
    .apply-page input[readonly], .apply-page input:disabled { animation: none; }
}
