:root {
    --app-primary: #4f46e5;
    --app-primary-dark: #3730a3;
    --app-sidebar: #111827;
    --app-sidebar-muted: #9ca3af;
    --app-surface: #f5f7fb;
    --app-text: #172033;
    --app-sidebar-width: 17rem;
    --app-sidebar-collapsed-width: 5.25rem;
    --app-topbar-height: 5rem;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--app-text);
    background: var(--app-surface);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    --bs-offcanvas-width: var(--app-sidebar-width);
    color: #fff;
    background: var(--app-sidebar);
}

.app-sidebar .offcanvas-body {
    overflow-x: hidden;
}

.sidebar-brand {
    align-items: center;
    min-height: 5rem;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand-icon {
    display: inline-grid;
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 2.5rem;
    place-items: center;
    font-size: 1.4rem;
    border-radius: 0.75rem;
    background: var(--app-primary);
}

.sidebar-brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.2;
    white-space: nowrap;
}

.sidebar-brand-copy small {
    margin-top: 0.2rem;
    color: var(--app-sidebar-muted);
    font-size: 0.72rem;
}

.sidebar-navigation {
    padding: 1.25rem 0.75rem;
}

.sidebar-section-title {
    margin: 0 0.75rem 0.6rem;
    color: var(--app-sidebar-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    gap: 0.8rem;
    color: #d1d5db;
    text-decoration: none;
    border-radius: 0.65rem;
    white-space: nowrap;
    transition: color 150ms ease, background-color 150ms ease;
}

.sidebar-link i {
    flex: 0 0 auto;
    font-size: 1.35rem;
}

.sidebar-link:hover,
.sidebar-link:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    color: #fff;
    background: var(--app-primary);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    min-height: 3.5rem;
    padding: 0.75rem 1.25rem;
    gap: 0.65rem;
    color: var(--app-sidebar-muted);
    font-size: 0.78rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.sidebar-status {
    width: 0.55rem;
    height: 0.55rem;
    flex: 0 0 0.55rem;
    border-radius: 50%;
    background: #22c55e;
}

.app-workspace {
    display: flex;
    min-width: 0;
    min-height: 100vh;
    padding-top: var(--app-topbar-height);
    flex: 1 1 auto;
    flex-direction: column;
}

.app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--app-sidebar-width);
    z-index: 1030;
    display: flex;
    height: var(--app-topbar-height);
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    transition: left 180ms ease;
}

.app-topbar-main,
.app-topbar-heading {
    min-width: 0;
}

.app-topbar-main {
    flex: 1 1 auto;
}

.app-topbar-heading {
    overflow: hidden;
}

.app-topbar > .dropdown {
    flex: 0 0 auto;
}

.app-user-menu {
    padding: 0.35rem 0.5rem;
    border: 0;
}

.app-user-icon {
    display: inline-grid;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--app-primary);
    font-size: 1.15rem;
    border-radius: 50%;
    background: #eef2ff;
    place-items: center;
}

.sidebar-toggle {
    display: inline-flex;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    color: var(--app-primary);
    border-color: #cbd5de;
    background: #f1f4f7;
}

.sidebar-toggle i {
    font-size: 1.35rem;
}

.app-module-name {
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-breadcrumb {
    --bs-breadcrumb-divider: "›";
    flex-wrap: nowrap;
    overflow: hidden;
    line-height: 1.2;
}

.app-breadcrumb .breadcrumb-item {
    color: #6b7280;
    white-space: nowrap;
}

.app-breadcrumb .breadcrumb-item a {
    color: inherit;
    text-decoration: none;
}

.app-breadcrumb .breadcrumb-item a:hover,
.app-breadcrumb .breadcrumb-item a:focus-visible {
    color: var(--app-primary);
}

.app-breadcrumb .breadcrumb-item.active {
    overflow: hidden;
    color: #6b7280;
    text-overflow: ellipsis;
}

.app-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: #9ca3af;
}

.app-page-title {
    overflow: hidden;
    font-size: 1.25rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-main {
    flex: 1 0 auto;
    padding: 1.5rem;
}

/* El pie de la vista. */
.app-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

@media (max-width: 575.98px) {
    .app-footer-bar {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        width: var(--app-sidebar-width);
        height: 100vh;
        flex: 0 0 var(--app-sidebar-width);
        visibility: visible !important;
        transform: none !important;
        transition: width 180ms ease, flex-basis 180ms ease;
    }

    .app-sidebar .offcanvas-body {
        display: flex;
    }

    .sidebar-collapsed .app-sidebar {
        width: var(--app-sidebar-collapsed-width);
        flex-basis: var(--app-sidebar-collapsed-width);
    }

    .sidebar-collapsed .app-topbar {
        left: var(--app-sidebar-collapsed-width);
    }

    .sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding-inline: 0;
    }

    .sidebar-collapsed .sidebar-brand-copy,
    .sidebar-collapsed .sidebar-section-title,
    .sidebar-collapsed .sidebar-label,
    /* En la barra colapsada el chevron dejaría dos iconos por fila. */
    .sidebar-collapsed .sidebar-caret {
        display: none;
    }

    .sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding-inline: 0;
    }

    /* Los subenlaces pierden su sangría (viene con !important) y quedan centrados. */
    .sidebar-collapsed .sidebar-sublink {
        padding-right: 0 !important;
        padding-left: 0 !important;
        justify-content: center;
    }

    /* Los iconos del submenú se distinguen del icono del grupo. */
    .sidebar-collapsed .sidebar-sublink i {
        font-size: 1.1rem;
        opacity: 0.85;
    }

    .sidebar-collapsed .sidebar-footer {
        justify-content: center;
        padding-inline: 0;
    }
}

@media (max-width: 991.98px) {
    :root {
        --app-topbar-height: 4.5rem;
    }

    .app-topbar {
        left: 0;
        padding-inline: 1rem;
    }

    .app-main {
        padding: 1rem;
    }
}
