:root {
    --brand-red: #7a0b0b;
    --brand-red-2: #5f0808;

    --bg: #f4f5f7;
    --card: #ffffff;
    --border: #e6e7ea;

    --sidebar-w: 260px;
    --header-h: 64px;
}

body {
    background: var(--bg);
    color: #1b1b1b;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 20;
}

.header-logo {
    height: 36px;
    width: auto;
    border-radius: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    background: #f8f9fb;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    color: #222;
}

.user-name {
    font-weight: 600;
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 0px 18px 14px;
    z-index: 30;
}

.sidebar-title {
    font-weight: 800;
    color: #222;
    margin-bottom: 12px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #222;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: rgba(122, 11, 11, .06);
    border-color: rgba(122, 11, 11, .18);
    color: #222;
}

.sidebar-link.active {
    background: rgba(122, 11, 11, .10);
    border-color: rgba(122, 11, 11, .25);
    color: var(--brand-red);
    font-weight: 700;
}

/* Main content */
.app-main {
    padding-top: calc(var(--header-h) + 16px);
    padding-left: calc(var(--sidebar-w) + 16px);
    padding-right: 16px;
    padding-bottom: 24px;
}

/* Botones marca */
.btn-outline-brand {
    background: transparent;
    border-color: rgba(122, 11, 11, .45);
    color: var(--brand-red);
}

.btn-outline-brand:hover,
.btn-outline-brand:focus {
    background: rgba(122, 11, 11, .06);
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.btn-brand {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: #fff;
}

.btn-brand:hover,
.btn-brand:focus {
    background: var(--brand-red-2);
    border-color: var(--brand-red-2);
    color: #fff;
}

/* Responsive: sidebar se vuelve superior (simple) */
@media (max-width: 991.98px) {
    :root {
        --sidebar-w: 0px;
    }

    .app-sidebar {
        display: none;
    }

    .app-header {
        left: 0;
    }

    .app-main {
        padding-left: 16px;
    }
}

/* ===== Mobile sidebar toggle ===== */
.btn-sidebar-toggle {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    line-height: 1;
}

@media (max-width: 991.98px) {
    .btn-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Overlay cuando el sidebar está abierto */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 40;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    /* Sidebar offcanvas */
    .app-sidebar {
        display: block;
        /* ya no lo ocultamos */
        transform: translateX(-110%);
        transition: transform .22s ease;
        z-index: 50;
        /* arriba del header */
        width: 280px;
        /* ancho cómodo en mobile */
        max-width: 86vw;
        padding-top: 0px;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    /* Header */
    .app-header {
        left: 0;
    }

    /* Main */
    .app-main {
        padding-left: 16px;
    }

    /* User name truncado */
    .user-pill {
        max-width: 52vw;
    }

    .user-name {
        display: inline-block;
        max-width: 34vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Botón salir: solo icono */
    #btnLogout .btn-text {
        display: none;
    }
}

/* Aux */
#btnLogin:disabled {
    background-color: var(--brand-red);
}

.choices .choices__list {
    z-index: 20;
}

.choices__list--single .choices__item {
    max-height: 21px;
    overflow: hidden;
}

input[readonly] {
    background-color: transparent !important;
    border: none;
    padding-left: 0;
}

/* Aux */
table.dataTable thead>tr>th.th-no-sort.dt-ordering-asc .dt-column-order:before {
    display: none;
}

table.dataTable.table-sm>thead>tr th.th-no-sort.dt-ordering-asc .dt-column-order {
    display: none;
}

.dt-length {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

@media(max-width: 500px) {
    .dt-search {
        justify-self: left;
    }

    .dt-search input[type="search"] {
        margin: 0 !important;
    }
}