:root {
    --shell-teal: #00bfa5;
    --shell-teal-soft: #e6faf6;
    --shell-ink: #1f2a37;
    --shell-muted: #6b7280;
    --shell-line: #e5e7eb;
    --shell-bg: #f7f8f9;
    --shell-white: #ffffff;
    --shell-topbar-h: 56px;
    --shell-side-w: 232px;
}

/* —— Carga global (API / BD) —— */
.mv-busy-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2500;
    overflow: hidden;
    pointer-events: none;
    background: rgba(0, 191, 165, 0.15);
}

.mv-busy-bar-inner {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, #00bfa5, #1a8fd0, #00bfa5);
    background-size: 200% 100%;
    animation: mvBusySlide 0.9s ease-in-out infinite;
}

@keyframes mvBusySlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.mv-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 2490;
    display: grid;
    place-items: center;
    background: rgba(247, 248, 249, 0.72);
    backdrop-filter: blur(2px);
}

.mv-busy-card {
    min-width: min(16rem, calc(100vw - 2rem));
    max-width: 22rem;
    padding: 1.35rem 1.5rem 1.2rem;
    border-radius: 0.85rem;
    background: #fff;
    border: 1px solid var(--shell-line);
    box-shadow: 0 12px 40px rgba(15, 39, 68, 0.18);
    display: grid;
    gap: 0.55rem;
    justify-items: center;
    text-align: center;
}

.mv-busy-title {
    margin: 0.35rem 0 0;
    font-family: "Manrope", system-ui, sans-serif;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--shell-ink);
}

.mv-busy-sub {
    margin: 0;
    color: var(--shell-muted);
    font-size: 0.86rem;
}

.shell-boot {
    min-height: 100vh;
    background: var(--shell-bg);
}

.shell-boot-bar {
    height: 3px;
    background: linear-gradient(90deg, var(--shell-teal), #1a8fd0);
    animation: shellPulse 1.1s ease infinite;
}

.shell-switch-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: rgba(247, 248, 249, 0.78);
    backdrop-filter: blur(2px);
}

.shell-switch-card {
    min-width: 12rem;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    background: var(--shell-white);
    border: 1px solid var(--shell-line);
    box-shadow: 0 10px 30px rgba(15, 39, 68, 0.08);
    display: grid;
    gap: 0.75rem;
    justify-items: center;
    text-align: center;
}

.shell-switch-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--shell-muted);
}

.shell-switch-spinner {
    width: 1.75rem;
    height: 1.75rem;
    border: 2.5px solid var(--shell-teal-soft);
    border-top-color: var(--shell-teal);
    border-radius: 50%;
    animation: shellSpin 0.7s linear infinite;
}

@keyframes shellSpin {
    to { transform: rotate(360deg); }
}

.shell-root {
    min-height: 100vh;
    background: var(--shell-bg);
    color: var(--shell-ink);
    font-family: "Manrope", system-ui, sans-serif;
}

.shell-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--shell-topbar-h);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem 0 0.75rem;
    background: var(--shell-white);
    border-bottom: 1px solid var(--shell-line);
}

.shell-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 11rem;
}

.shell-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--shell-ink);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.shell-logo-mark {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 0.4rem;
    background:
        radial-gradient(circle at 30% 30%, #7dffd8 0 35%, transparent 36%),
        radial-gradient(circle at 70% 35%, #00bfa5 0 42%, transparent 43%),
        radial-gradient(circle at 50% 75%, #149e8b 0 40%, transparent 41%),
        #e8fffa;
    box-shadow: inset 0 0 0 1px rgba(0, 191, 165, 0.25);
}

.shell-logo-text {
    font-family: "Manrope", system-ui, sans-serif;
}

.shell-search {
    justify-self: center;
    width: min(420px, 100%);
    display: flex;
    align-items: center;
    gap: 0.55rem;
    height: 2.25rem;
    padding: 0 0.85rem;
    border: 1px solid var(--shell-line);
    border-radius: 999px;
    background: #f9fafb;
    color: var(--shell-muted);
}

.shell-search input {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 0.9rem;
    color: var(--shell-ink);
}

.shell-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    justify-self: end;
}

.shell-icon-btn {
    width: 2.15rem;
    height: 2.15rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #4b5563;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.shell-icon-btn:hover {
    background: #f3f4f6;
    color: var(--shell-ink);
}

.shell-menu-toggle {
    display: inline-flex;
}

.shell-apps,
.shell-company {
    position: relative;
}

.shell-company-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-left: 0.35rem;
    padding: 0.25rem 0.55rem 0.25rem 0.3rem;
    border: 1px solid var(--shell-line);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    color: var(--shell-ink);
    font: inherit;
}

.shell-company-btn:hover {
    border-color: #cfd5db;
    background: #fafafa;
}

.shell-company-avatar {
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--shell-teal-soft);
    color: #00897a;
    font-size: 0.75rem;
    font-weight: 800;
}

.shell-company-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    text-align: left;
    max-width: 8.5rem;
}

.shell-company-meta strong {
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.shell-company-meta small {
    font-size: 0.68rem;
    color: var(--shell-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.shell-dropdown {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    min-width: 14rem;
    padding: 0.45rem;
    border: 1px solid var(--shell-line);
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    z-index: 50;
}

.shell-dropdown-title {
    margin: 0.2rem 0.45rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--shell-muted);
}

.shell-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: 0;
    background: transparent;
    border-radius: 0.55rem;
    padding: 0.55rem 0.6rem;
    text-align: left;
    cursor: pointer;
    color: var(--shell-ink);
    font: inherit;
}

.shell-dropdown-item:hover {
    background: #f3f4f6;
}

.shell-dropdown-item.is-active {
    background: var(--shell-teal-soft);
    color: #00796b;
}

.shell-dropdown-item small {
    color: var(--shell-muted);
    font-size: 0.7rem;
}

.shell-dropdown-item.is-danger {
    color: #b42318;
}

.shell-dropdown-sep {
    height: 1px;
    margin: 0.35rem 0.25rem;
    background: var(--shell-line);
}

.shell-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    min-height: calc(100vh - var(--shell-topbar-h));
    width: 100%;
}

.shell-sidebar {
    width: var(--shell-side-w);
    background: var(--shell-white);
    border-right: 1px solid var(--shell-line);
    padding: 0.65rem 0.45rem 1.25rem;
    overflow: hidden auto;
    min-width: 0;
    opacity: 1;
    transform: translateX(0);
    transition:
        width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.24s ease,
        border-color 0.24s ease,
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.32s ease;
    will-change: width, opacity, transform;
}

.shell-main {
    padding: 1.15rem 1.25rem 2rem;
    min-width: 0;
    width: 100%;
}

.shell-nav-backdrop {
    display: none;
}

/* Escritorio: contraer con animación de ancho */
@media (min-width: 961px) {
    .shell-root.is-collapsed .shell-sidebar {
        width: 0;
        padding-left: 0;
        padding-right: 0;
        opacity: 0;
        border-right-color: transparent;
        pointer-events: none;
        overflow: hidden;
    }
}

.shell-sidebar-app {
    margin: 0.25rem 0.55rem 0.75rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.55rem;
    background: #f9fafb;
    color: var(--shell-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.shell-tree {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: calc(var(--shell-side-w) - 0.9rem);
}

.shell-tree-node {
    display: flex;
    flex-direction: column;
}

.shell-tree-item {
    --tree-depth: 0;
    display: grid;
    grid-template-columns: 1.25rem 1fr auto;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 2.2rem;
    margin: 0;
    padding: 0.4rem 0.55rem 0.4rem calc(0.55rem + (var(--tree-depth) * 0.85rem));
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: #374151;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    position: relative;
}

.shell-tree-item.is-branch {
    font-weight: 600;
    color: #111827;
}

.shell-tree-item:hover {
    background: #f3f4f6;
    color: var(--shell-ink);
}

.shell-tree-item.is-active {
    background: var(--shell-teal-soft);
    color: #00796b;
    font-weight: 700;
}

.shell-tree-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.35rem;
    bottom: 0.35rem;
    width: 3px;
    border-radius: 999px;
    background: var(--shell-teal);
}

.shell-tree-item.is-open-path:not(.is-active) {
    color: #0f766e;
}

.shell-tree-icon {
    width: 1.15rem !important;
    height: 1.15rem !important;
    color: inherit;
    opacity: 0.85;
}

.shell-tree-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-tree-chevron {
    display: inline-flex;
    color: #9ca3af;
    transition: transform 0.18s ease;
}

.shell-tree-chevron.is-open {
    transform: rotate(90deg);
    color: var(--shell-teal);
}

.shell-tree-children {
    display: none;
    flex-direction: column;
    gap: 0.02rem;
    padding-left: 0;
}

.shell-tree-children.is-open {
    display: flex;
}

.shell-tree-item.is-leaf {
    grid-template-columns: 1.25rem 1fr;
}

.shell-main > * {
    max-width: 100%;
}

@keyframes shellPulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

@media (max-width: 960px) {
    .shell-search {
        display: none;
    }

    .shell-menu-toggle {
        display: inline-flex;
    }

    /* Sidebar overlay: no reservar fila en el grid */
    .shell-body {
        display: block;
        position: relative;
        min-width: 0;
    }

    .shell-main {
        width: 100%;
        min-width: 0;
    }

    .shell-nav-backdrop {
        display: block;
        position: fixed;
        top: var(--shell-topbar-h);
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 100;
        margin: 0;
        padding: 0;
        border: 0;
        background: rgba(15, 39, 68, 0.45);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .shell-sidebar {
        position: fixed;
        top: var(--shell-topbar-h);
        left: 0;
        bottom: 0;
        width: min(82vw, 16.5rem) !important;
        max-width: 16.5rem;
        padding: 0.65rem 0.45rem 1.25rem !important;
        z-index: 110;
        overflow: auto;
        border-right: 1px solid var(--shell-line);
        background: var(--shell-white);
        box-shadow: 10px 0 30px rgba(15, 23, 42, 0.18);
        transform: translateX(-105%);
        opacity: 0;
        pointer-events: none;
        transition:
            transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
            opacity 0.14s ease,
            box-shadow 0.18s ease;
    }

    .shell-root.is-open .shell-sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .shell-root.is-collapsed .shell-sidebar {
        width: min(82vw, 16.5rem) !important;
        padding: 0.65rem 0.45rem 1.25rem !important;
        transform: translateX(-105%);
        opacity: 0;
        pointer-events: none;
        border-right-color: var(--shell-line);
        box-shadow: none;
    }

    .shell-tree {
        min-width: 0;
    }

    .shell-company-meta {
        display: none;
    }

    .shell-root.is-open {
        overflow: hidden;
    }
}

@media (max-width: 640px) {
    .shell-topbar-left {
        min-width: 0;
        flex: 1 1 auto;
    }

    .shell-logo-text {
        font-size: 0.95rem;
    }

    .shell-topbar-optional {
        display: none;
    }

    .shell-topbar-right {
        gap: 0.2rem;
    }

    .shell-company-btn {
        padding-inline: 0.35rem;
    }

    .shell-main {
        padding: 0.75rem 0.7rem 1.1rem;
    }
}
