/* ── Register: variables y base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --blue-50: #f0f5f9;
    --blue-100: #dae4ed;
    --blue-400: #6893b7;
    --blue-600: #365d78;
    --blue-700: #2b4b63;
    --blue-800: #20394e;
    --dark-900: #0f172a;
    --white: #fff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .04);
    --shadow: 0 4px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, .08);
    --danger: #ef4444;
    --success: #22c55e;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--blue-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.nav-logo img {
    height: 32px;
    width: auto;
}

.nav-back {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: var(--blue-600);
    font-weight: 600;
    font-size: .9rem;
    transition: color .2s;
}

.nav-back:hover {
    color: var(--blue-700);
}

/* ── Main y card ── */
.main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.card {
    width: 100%;
    max-width: 480px;
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--blue-600), var(--blue-400));
}

/* ── Header del formulario ── */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header .logo {
    height: 36px;
    width: auto;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: .5rem;
}

.header p {
    font-size: .9rem;
    color: var(--text-secondary);
}

/* ── Tipo de cuenta (individual / institución) ── */
.register-type {
    margin-bottom: 1.5rem;
}

.register-type-label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
    margin-bottom: .6rem;
}

.register-type-toggle {
    display: flex;
    gap: .5rem;
    padding: .35rem;
    background: var(--blue-50);
    border-radius: 14px;
    border: 1.5px solid var(--border);
}

.register-type-option {
    flex: 1;
    position: relative;
}

.register-type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.register-type-option label {
    display: block;
    text-align: center;
    padding: .65rem .5rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: background .2s, color .2s, box-shadow .2s;
}

.register-type-option input:focus-visible + label {
    outline: 2px solid var(--blue-600);
    outline-offset: 2px;
}

.register-type-option input:checked + label {
    background: var(--white);
    color: var(--blue-700);
    box-shadow: var(--shadow-sm);
}

.register-type-hint {
    margin-top: .65rem;
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.register-type-hint strong {
    color: var(--blue-600);
}

/* ── Formulario ── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .4rem;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: .9rem;
}

.form-input {
    width: 100%;
    padding: .75rem .75rem .75rem 2.6rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: .9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--blue-50);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(54, 93, 120, .12);
    background: var(--white);
}

.form-input.error {
    border-color: var(--danger);
}

.form-input.success {
    border-color: var(--success);
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: .9rem;
    padding: 4px;
}

.password-toggle:hover {
    color: var(--text-primary);
}

/* ── Requisitos de contraseña ── */
.password-reqs {
    margin-top: .5rem;
    padding: .75rem;
    background: var(--blue-50);
    border-radius: 10px;
    font-size: .78rem;
}

.password-reqs .req {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: var(--text-light);
    margin-bottom: .25rem;
    transition: color .2s;
}

.password-reqs .req:last-child {
    margin-bottom: 0;
}

.password-reqs .req.met {
    color: var(--success);
}

.password-reqs .req i {
    font-size: .7rem;
    width: 14px;
    text-align: center;
}

/* ── Alertas ── */
.alert {
    padding: .85rem 1rem;
    border-radius: 12px;
    font-size: .85rem;
    margin-bottom: 1.25rem;
    display: none;
    align-items: flex-start;
    gap: .6rem;
    line-height: 1.5;
}

.alert.show {
    display: flex;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* ── Botón ── */
.btn {
    width: 100%;
    padding: .85rem;
    border: none;
    border-radius: 12px;
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
    color: var(--white);
    box-shadow: 0 4px 12px rgba(43, 75, 99, .25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(43, 75, 99, .3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
}

.footer-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .88rem;
    color: var(--text-secondary);
}

.footer-link a {
    color: var(--blue-600);
    text-decoration: none;
    font-weight: 600;
}

.footer-link a:hover {
    text-decoration: underline;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Pantalla post-registro ── */
.success-screen {
    display: none;
    text-align: center;
    padding: 1rem 0;
}

.success-screen.show {
    display: block;
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-600), var(--blue-400));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: var(--white);
}

.success-screen h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: .75rem;
    color: var(--text-primary);
}

.success-screen p {
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.7;
    margin-bottom: .5rem;
}

.success-screen .email-highlight {
    display: inline-block;
    background: var(--blue-50);
    padding: .3rem .8rem;
    border-radius: 8px;
    font-weight: 700;
    color: var(--blue-700);
    margin: .5rem 0 1rem;
    font-size: .95rem;
    word-break: break-all;
}

.success-screen .tip {
    font-size: .82rem;
    color: var(--text-light);
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── Cédula jurídica + Hacienda ── */
.label-req {
    color: var(--danger);
    font-weight: 700;
}

.field-hint {
    font-size: .78rem;
    color: var(--text-secondary);
    margin: 0 0 .6rem;
    line-height: 1.45;
}

.input-row-hacienda {
    display: flex;
    gap: .6rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.input-wrapper--grow {
    flex: 1;
    min-width: 140px;
}

.btn-hacienda {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: 0 1rem;
    font-size: .82rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--white);
    background: linear-gradient(135deg, #0e7490, #155e75);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 2px 8px rgba(14, 116, 144, .35);
}

.btn-hacienda:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 116, 144, .4);
}

.btn-hacienda:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.hacienda-status {
    font-size: .78rem;
    margin: .5rem 0 0;
    min-height: 1.2em;
    color: var(--text-secondary);
}

.hacienda-status--loading {
    color: var(--blue-600);
}

.hacienda-status--ok {
    color: var(--success);
}

.hacienda-status--err {
    color: var(--danger);
}

.hacienda-extra {
    margin-top: .65rem;
    padding: .75rem .85rem;
    background: var(--blue-50);
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: .78rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.hacienda-extra-inner strong {
    color: var(--blue-700);
}

/* ── Responsive ── */
@media (max-width: 540px) {
    .main {
        padding: 1rem;
    }
    .card {
        padding: 1.75rem 1.25rem;
        border-radius: 16px;
    }
    .header h1 {
        font-size: 1.35rem;
    }
    .input-row-hacienda {
        flex-direction: column;
    }
    .btn-hacienda {
        width: 100%;
        padding: .75rem 1rem;
    }
}
