/* Mobile ≤767px */
@media (max-width: 767px) {

    /* El sidebar flota sobre el contenido en mobile */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--transition-speed) ease;
        width: var(--sidebar-width);
    }

    /* Clase añadida por JS al abrir en mobile */
    #sidebar.open {
        transform: translateX(0);
    }

    /* Backdrop real — div que cierra el sidebar al tocarlo.
     * z-index 199: por encima del topbar (160) y cualquier contenido,
     * pero por debajo del sidebar (200). Garantiza que el toque en
     * cualquier zona fuera del sidebar cierre correctamente. */
    #sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 199;
    }

    #sidebar-backdrop.active {
        display: block;
    }

    /* El wrapper ocupa todo el ancho disponible */
    #main-wrapper {
        width: 100%;
    }

    #content {
        padding: 16px;
    }
}
