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

:root {
    --color-primario: rgb(23, 152, 213);
    --color-primario-oscuro: rgb(18, 122, 171);
    --color-fondo: #eef7fc;
    --color-blanco: #ffffff;
    --color-texto: #1e293b;
    --color-texto-suave: #5a7a8a;
    --color-borde: #b8d9eb;
    --color-error: #dc2626;
    --color-exito: #16a34a;
    --radio: clamp(8px, 2vw, 12px);
    --sombra: 0 4px 24px rgba(23, 152, 213, 0.1);
    --altura-barra: clamp(3rem, 8vh, 3.25rem);
    --espacio-campo: clamp(0.45rem, 1.6vh, 0.9rem);
    --padding-input-y: clamp(0.55rem, 1.5vh, 0.8rem);
    --padding-input-x: clamp(0.75rem, 2vw, 1rem);
    --altura-input: clamp(2.35rem, 6vh, 2.75rem);
    --padding-header: clamp(0.6rem, 2vh, 1rem);
    --padding-contenedor: clamp(0.5rem, 1.5vh, 1rem);
    --padding-tarjeta: clamp(0.75rem, 2vh, 1.25rem);
}

html {
    -webkit-text-size-adjust: 100%;
    height: 100%;
}

body {
    margin: 0;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    line-height: 1.35;
    color: var(--color-texto);
    background: var(--color-fondo);
}

.pagina {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.formulario-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.encabezado {
    flex-shrink: 0;
    background: var(--color-primario);
    color: var(--color-blanco);
    padding: var(--padding-header) 1rem;
    text-align: center;
}

.encabezado h1 {
    margin: 0;
    font-size: clamp(1rem, 4vw, 1.25rem);
    font-weight: 700;
    line-height: 1.2;
}

.encabezado p {
    margin: 0.2rem 0 0;
    font-size: clamp(0.75rem, 3vw, 0.875rem);
    opacity: 0.9;
    line-height: 1.2;
}

.contenedor {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: var(--padding-contenedor) 0.75rem 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.formulario-layout .contenedor {
    padding-bottom: calc(var(--altura-barra) + var(--padding-contenedor) + env(safe-area-inset-bottom));
}

.tarjeta {
    position: relative;
    overflow: hidden;
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: var(--padding-tarjeta);
    background: rgba(255, 255, 255, 0.93);
    height: 100%;
}

.tarjeta__logo-fondo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(280px, 80%);
    transform: translate(-50%, -50%);
    opacity: 0.24;
    filter: brightness(0) saturate(100%) invert(58%) sepia(79%) saturate(2476%) hue-rotate(176deg) brightness(95%) contrast(91%);
    pointer-events: none;
    z-index: 2;
}

.tarjeta__contenido {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.alerta {
    padding: 0.75rem 0.875rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.alerta--error {
    background: #fef2f2;
    color: var(--color-error);
    border: 1px solid #fecaca;
}

.alerta--exito {
    background: #f0fdf4;
    color: var(--color-exito);
    border: 1px solid #bbf7d0;
}

.formulario {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    flex: 1;
    gap: var(--espacio-campo);
    min-height: 0;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex-shrink: 0;
}

.campo label {
    font-size: clamp(0.75rem, 2.8vw, 0.875rem);
    font-weight: 600;
    color: var(--color-texto);
    line-height: 1.2;
}

.campo input,
.campo select {
    width: 100%;
    height: var(--altura-input);
    padding: 0 var(--padding-input-x);
    font-size: clamp(0.875rem, 2.8vw, 1rem);
    font-family: inherit;
    color: var(--color-texto);
    background: var(--color-blanco);
    border: 1.5px solid var(--color-borde);
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.campo input:focus,
.campo select:focus {
    outline: none;
    border-color: var(--color-primario);
    box-shadow: 0 0 0 3px rgba(23, 152, 213, 0.2);
}

.campo--select {
    position: relative;
}

.campo--select::after {
    content: '';
    position: absolute;
    right: 1rem;
    bottom: calc(var(--altura-input) / 2 - 3px);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--color-texto-suave);
    pointer-events: none;
}

.campo .ayuda {
    font-size: clamp(0.625rem, 2.2vw, 0.7rem);
    color: var(--color-texto-suave);
    line-height: 1.2;
}

.barra-inferior {
    position: fixed;
    bottom: 0;
    left: 50%;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem max(0.5rem, env(safe-area-inset-bottom));
    background: var(--color-fondo);
}

.boton {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--altura-barra);
    margin: 0;
    padding: 0 1rem;
    font-size: clamp(0.9rem, 2.8vw, 1rem);
    font-weight: 600;
    font-family: inherit;
    color: var(--color-blanco);
    background: var(--color-primario);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.boton:hover {
    background: var(--color-primario-oscuro);
}

.boton:active {
    transform: scale(0.98);
}

.boton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-height: 640px) {
    :root {
        --espacio-campo: clamp(0.35rem, 1.2vh, 0.6rem);
        --altura-input: clamp(2.1rem, 5.5vh, 2.5rem);
        --padding-tarjeta: clamp(0.5rem, 1.5vh, 0.75rem);
    }

    .tarjeta__logo-fondo {
        width: min(220px, 70%);
        opacity: 0.18;
    }
}

@media (max-height: 520px) {
    body {
        overflow: auto;
    }

    .pagina {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .formulario-layout {
        overflow: visible;
    }

    .formulario {
        justify-content: flex-start;
    }
}

@media (min-width: 481px) {
    .contenedor {
        padding-top: 1rem;
    }

    .encabezado h1 {
        font-size: 1.35rem;
    }
}
