.ivm-modal[hidden],
.ivm-modal [hidden] {
    display: none !important;
}

.ivm-modal {
    /* 60% Superficies */
    --ivm-surface: #FFFFFF;
    --ivm-soft: #F7FAFC;
    --ivm-tint: #EEF3F8;

    /* 30% Estructura */
    --ivm-navy: #071B33;
    --ivm-navy-mid: #0D2C52;
    --ivm-text: #0F172A;
    --ivm-text-sec: #334155;
    --ivm-muted: #64748B;

    /* 10% Acentos funcionales */
    --ivm-blue: #1479B8;
    --ivm-cyan: #00A8CC;
    --ivm-wa: #16A34A;
    --ivm-wa-deep: #15803D;
    --ivm-warn-bg: #FFFBEB;
    --ivm-warn-border: rgba(217, 119, 6, 0.34);
    --ivm-warn-text: #92400E;
    --ivm-err-bg: #FEF2F2;
    --ivm-err-text: #B91C1C;

    --ivm-border: rgba(7, 27, 51, 0.1);
    --ivm-border-strong: rgba(7, 27, 51, 0.18);
    --ivm-ease: cubic-bezier(0.16, 1, 0.3, 1);

    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ivm-text);
    line-height: 1.55;
    pointer-events: none;
    isolation: isolate;
    -webkit-font-smoothing: antialiased;
}

.ivm-modal.is-open {
    pointer-events: auto;
}

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

.ivm-modal a {
    text-decoration: none;
    color: inherit;
}

.ivm-modal button:focus-visible,
.ivm-modal input:focus-visible,
.ivm-modal textarea:focus-visible,
.ivm-modal a:focus-visible {
    outline: 3px solid rgba(20, 121, 184, 0.45);
    outline-offset: 2px;
}

/* Fondo difuminado */
.ivm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 27, 51, 0.58);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ivm-modal.is-open .ivm-modal__backdrop {
    opacity: 1;
}

/* Contenedor principal del diálogo (flex vertical con scroll solo en el cuerpo) */
.ivm-modal__panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(100%, 490px);
    max-height: min(88dvh, 720px);
    background: var(--ivm-surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 22px;
    box-shadow: 0 30px 80px -18px rgba(7, 27, 51, 0.38);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    transition: opacity 0.25s var(--ivm-ease), transform 0.34s var(--ivm-ease);
}

.ivm-leg__panel {
    width: min(100%, 660px);
    max-height: min(88dvh, 760px);
}

.ivm-modal.is-open .ivm-modal__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ivm-modal__grabber {
    display: none;
}

/* Cabecera fija */
.ivm-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--ivm-border);
    background: var(--ivm-surface);
    flex-shrink: 0;
}

.ivm-modal__close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    background: #F1F5F9;
    color: var(--ivm-muted);
    font-size: 15px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ivm-modal__close:hover {
    background: #E2E8F0;
    color: var(--ivm-navy);
}

/* Cuerpo con scroll interno limpio */
.ivm-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px 22px;
}

.ivm-modal__body::-webkit-scrollbar {
    width: 6px;
}

.ivm-modal__body::-webkit-scrollbar-thumb {
    background: rgba(7, 27, 51, 0.16);
    border-radius: 999px;
}

/* Pie fijo */
.ivm-modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 22px;
    border-top: 1px solid var(--ivm-border);
    background: var(--ivm-soft);
    flex-shrink: 0;
}

/* Tipografía interna */
.ivm-modal__icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(20, 121, 184, 0.1);
    color: var(--ivm-blue);
    display: grid;
    place-items: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.ivm-modal__title {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.22;
    letter-spacing: -0.02em;
    color: var(--ivm-navy);
}

.ivm-modal__desc {
    margin-top: 5px;
    font-size: 13.5px;
    color: var(--ivm-muted);
}

/* Botones aislados */
.ivm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border: 0;
    border-radius: 11px;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s var(--ivm-ease), box-shadow 0.2s ease, opacity 0.2s ease;
}

.ivm-btn:active {
    transform: scale(0.985);
}

.ivm-btn--primary {
    background: linear-gradient(135deg, var(--ivm-navy) 0%, var(--ivm-blue) 100%);
    color: #FFFFFF;
    box-shadow: 0 8px 20px -8px rgba(7, 27, 51, 0.35);
}

.ivm-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px -8px rgba(20, 121, 184, 0.45);
}

.ivm-btn--whatsapp {
    background: linear-gradient(135deg, #22C55E 0%, var(--ivm-wa) 55%, var(--ivm-wa-deep) 100%);
    color: #FFFFFF;
    box-shadow: 0 10px 24px -8px rgba(22, 163, 74, 0.45);
}

.ivm-btn--whatsapp:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -8px rgba(21, 128, 61, 0.55);
}

.ivm-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    padding: 6px 4px;
    border: 0;
    background: transparent;
    color: var(--ivm-muted);
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease;
}

.ivm-link-btn:hover {
    color: var(--ivm-navy);
}

/* ==========================================================================
   MODAL DE SOPORTE TÉCNICO (.ivm-sup)
   ========================================================================== */
.ivm-sup__form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.ivm-sup__progress {
    flex: 1;
}

.ivm-sup__step-label {
    display: block;
    margin-bottom: 6px;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ivm-blue);
}

.ivm-sup__bars {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.ivm-sup__bar {
    height: 4px;
    border-radius: 999px;
    background: #E2E8F0;
    transition: background-color 0.25s ease;
}

.ivm-sup__bar.is-active {
    background: linear-gradient(90deg, var(--ivm-blue), var(--ivm-cyan));
}

.ivm-sup__step {
    animation: ivmStepSlide 0.28s var(--ivm-ease);
}

.ivm-sup__group {
    margin-top: 16px;
}

.ivm-sup__label {
    display: block;
    margin-bottom: 8px;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ivm-text-sec);
}

.ivm-sup__options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.ivm-sup__opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 76px;
    padding: 12px 8px;
    border-radius: 13px;
    border: 1.5px solid var(--ivm-border);
    background: var(--ivm-soft);
    color: var(--ivm-text-sec);
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ivm-sup__opt i {
    font-size: 18px;
    color: var(--ivm-blue);
}

.ivm-sup__opt:hover {
    border-color: rgba(20, 121, 184, 0.45);
    background: #F0F9FF;
}

.ivm-sup__opt.is-selected {
    background: var(--ivm-navy);
    border-color: var(--ivm-navy);
    color: #FFFFFF;
}

.ivm-sup__opt.is-selected i {
    color: #40E0D0;
}

.ivm-sup__chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.ivm-sup__chip {
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 11px;
    border: 1.5px solid var(--ivm-border);
    background: var(--ivm-soft);
    color: var(--ivm-text-sec);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ivm-sup__chip:hover {
    border-color: rgba(20, 121, 184, 0.45);
    color: var(--ivm-navy);
}

.ivm-sup__chip.is-selected {
    background: #F0F9FF;
    border-color: var(--ivm-blue);
    color: var(--ivm-navy);
    font-weight: 700;
}

/* Campos de formulario */
.ivm-sup__fields {
    display: grid;
    gap: 13px;
    margin-top: 16px;
}

.ivm-sup__field {
    display: grid;
    gap: 6px;
}

.ivm-sup__field label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ivm-text-sec);
}

.ivm-sup__field label span {
    color: var(--ivm-blue);
}

.ivm-sup__field label small {
    font-weight: 500;
    color: var(--ivm-muted);
}

.ivm-sup__field input,
.ivm-sup__field textarea {
    width: 100%;
    padding: 11px 13px;
    border-radius: 11px;
    border: 1.5px solid var(--ivm-border-strong);
    background: var(--ivm-surface);
    color: var(--ivm-text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ivm-sup__field input {
    min-height: 46px;
}

.ivm-sup__field textarea {
    resize: vertical;
    min-height: 98px;
}

.ivm-sup__field input:focus,
.ivm-sup__field textarea:focus {
    outline: none;
    border-color: var(--ivm-blue);
    box-shadow: 0 0 0 3px rgba(20, 121, 184, 0.14);
}

.ivm-sup__summary {
    display: grid;
    gap: 6px;
    margin: 14px 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ivm-soft);
    border: 1px solid var(--ivm-border);
    font-size: 12.5px;
}

.ivm-sup__summary > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.ivm-sup__summary span {
    color: var(--ivm-muted);
}

.ivm-sup__summary strong {
    color: var(--ivm-navy);
    text-align: right;
}

.ivm-sup__error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--ivm-err-bg);
    color: var(--ivm-err-text);
    font-size: 12.5px;
    font-weight: 600;
}

.ivm-sup__footer {
    justify-content: flex-end;
}

.ivm-sup__footer.has-prev {
    justify-content: space-between;
}

/* ==========================================================================
   MODAL LEGAL MULTI-VISTA (.ivm-leg)
   ========================================================================== */
.ivm-leg__header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-bottom: 14px;
}

.ivm-leg__head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ivm-leg__kicker {
    display: block;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ivm-blue);
    margin-bottom: 2px;
}

.ivm-leg__tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: 13px;
    background: var(--ivm-tint);
}

.ivm-leg__tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ivm-text-sec);
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.ivm-leg__tab:hover:not(.is-active) {
    color: var(--ivm-navy);
}

.ivm-leg__tab.is-active {
    background: var(--ivm-navy);
    color: #FFFFFF;
    box-shadow: 0 4px 12px -4px rgba(7, 27, 51, 0.35);
}

/* Contenido legal escaneable */
.ivm-leg__view {
    animation: ivmStepSlide 0.26s var(--ivm-ease);
}

.ivm-leg__meta {
    font-size: 12px;
    font-weight: 600;
    color: var(--ivm-muted);
    margin-bottom: 14px;
}

.ivm-leg__notice {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ivm-soft);
    border: 1px solid var(--ivm-border);
    font-size: 13px;
    color: var(--ivm-text-sec);
    margin-bottom: 16px;
}

.ivm-leg__alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border-radius: 12px;
    background: var(--ivm-warn-bg);
    border: 1px solid var(--ivm-warn-border);
    color: var(--ivm-warn-text);
    font-size: 13px;
    line-height: 1.52;
    margin: 10px 0 14px;
}

.ivm-leg__alert i {
    margin-top: 3px;
    font-size: 15px;
    flex-shrink: 0;
}

.ivm-leg__alert strong {
    color: #78350F;
}

.ivm-leg__block {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--ivm-soft);
    border: 1px solid var(--ivm-border);
    margin-bottom: 12px;
}

.ivm-leg__block:last-child {
    margin-bottom: 0;
}

.ivm-leg__block h4 {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 14.5px;
    font-weight: 800;
    color: var(--ivm-navy);
    margin-bottom: 8px;
}

.ivm-leg__block p {
    font-size: 13.5px;
    color: var(--ivm-text-sec);
    line-height: 1.58;
    margin-bottom: 8px;
}

.ivm-leg__block p:last-child {
    margin-bottom: 0;
}

.ivm-leg__block ul {
    list-style: none;
    display: grid;
    gap: 7px;
    margin-top: 6px;
}

.ivm-leg__block li {
    position: relative;
    padding-left: 16px;
    font-size: 13.5px;
    color: var(--ivm-text-sec);
    line-height: 1.52;
}

.ivm-leg__block li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ivm-blue);
}

.ivm-leg__block strong {
    color: var(--ivm-navy);
}

.ivm-leg__muted {
    font-size: 12.5px !important;
    color: var(--ivm-muted) !important;
}

.ivm-leg__contact-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.ivm-leg__contact-row a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--ivm-surface);
    border: 1px solid var(--ivm-border-strong);
    color: var(--ivm-navy);
    font-size: 13px;
    font-weight: 700;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.ivm-leg__contact-row a:hover {
    border-color: var(--ivm-blue);
    color: var(--ivm-blue);
}

.ivm-leg__footer-note {
    font-size: 12px;
    color: var(--ivm-muted);
    font-weight: 600;
}

/* Animación entre pasos/pestañas */
@keyframes ivmStepSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVIDAD MÓVIL (BOTTOM-SHEET NATIVO <= 640px)
   ========================================================================== */
@media (max-width: 640px) {
    .ivm-modal {
        align-items: flex-end;
        padding: 0;
    }

    .ivm-modal__panel,
    .ivm-leg__panel {
        width: 100%;
        max-height: 90dvh;
        border-radius: 22px 22px 0 0;
        transform: translateY(100%);
    }

    .ivm-modal.is-open .ivm-modal__panel {
        transform: translateY(0);
    }

    .ivm-modal__grabber {
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 999px;
        background: #CBD5E1;
        margin: 10px auto 2px;
        flex-shrink: 0;
    }

    .ivm-modal__header {
        padding: 12px 18px 12px;
    }

    .ivm-modal__body {
        padding: 16px 18px;
    }

    .ivm-modal__footer {
        padding: 12px 18px max(16px, env(safe-area-inset-bottom));
    }

    .ivm-modal__title {
        font-size: 18.5px;
    }

    .ivm-leg__tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ivm-leg__footer-note {
        display: none;
    }

    .ivm-leg__footer .ivm-btn {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .ivm-sup__options,
    .ivm-sup__chips {
        grid-template-columns: 1fr;
    }

    .ivm-sup__opt {
        flex-direction: row;
        justify-content: flex-start;
        min-height: 48px;
        padding: 10px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ivm-modal,
    .ivm-modal *,
    .ivm-modal *::before,
    .ivm-modal *::after {
        transition: none !important;
        animation: none !important;
    }
}