:root {
    --gb-shell-sidebar-width: 260px;
    --gb-shell-sidebar-collapsed-width: 72px;
    --gb-shell-border: #dfe4ea;
    --gb-shell-muted: #667085;
    --gb-shell-surface: #ffffff;
    --gb-shell-soft: #f7f9fc;
    --gb-shell-workspace: #f4f6f9;
    --gb-shell-shadow: 0 12px 36px rgba(15, 23, 42, 0.14);
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--gb-shell-workspace);
}

.gb-dashboard-shell,
.gb-dashboard-shell * {
    box-sizing: border-box;
}

.gb-dashboard-shell {
    display: grid;
    grid-template-columns: var(--gb-shell-sidebar-width) minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    background: var(--gb-shell-workspace);
    transition: grid-template-columns 180ms ease;
}

.gb-dashboard-shell.is-sidebar-collapsed {
    grid-template-columns: var(--gb-shell-sidebar-collapsed-width) minmax(0, 1fr);
}

.gb-shell-mobile-bar {
    display: none;
}

.gb-shell-sidebar {
    position: sticky;
    top: 0;
    z-index: 1040;
    display: flex;
    width: 100%;
    min-width: 0;
    height: 100vh;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--gb-shell-border);
    background: var(--gb-shell-surface);
}

.gb-shell-sidebar-toolbar {
    flex: 0 0 auto;
    padding: 8px;
    border-bottom: 1px solid var(--gb-shell-border);
    background: var(--gb-shell-surface);
}

.gb-shell-sidebar-collapse {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--gb-shell-border);
    border-radius: 10px;
    background: var(--gb-shell-soft);
    color: #344054;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

.gb-shell-sidebar-collapse:hover,
.gb-shell-sidebar-collapse:focus-visible {
    border-color: #b9c3d0;
    background: #eef3f9;
    outline: 3px solid rgba(13, 110, 253, 0.16);
    outline-offset: 1px;
}

.gb-shell-collapse-icon {
    display: inline-flex;
    width: 20px;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
    transition: transform 180ms ease;
}

.gb-dashboard-shell.is-sidebar-collapsed .gb-shell-collapse-icon {
    transform: rotate(180deg);
}

.gb-shell-section {
    min-height: 0;
    border-bottom: 1px solid var(--gb-shell-border);
}

.gb-shell-section--tree {
    flex: 0 0 auto;
}

.gb-shell-section--menu {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    border-bottom: 0;
}

.gb-shell-section-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--gb-shell-border);
    background: var(--gb-shell-soft);
    color: #1f2937;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.gb-shell-section-toggle:hover,
.gb-shell-section-toggle:focus-visible {
    background: #eef3f9;
    outline: none;
}

.gb-shell-section-title {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
}

.gb-shell-section-icon {
    display: inline-flex;
    width: 22px;
    flex: 0 0 22px;
    align-items: center;
    justify-content: center;
}

.gb-shell-section-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-shell-chevron {
    display: inline-block;
    font-size: 0.75rem;
    transition: transform 180ms ease;
}

.gb-shell-section-toggle[aria-expanded="false"] .gb-shell-chevron {
    transform: rotate(-90deg);
}

.gb-shell-section-content {
    background: var(--gb-shell-surface);
}

.gb-shell-section-content[hidden] {
    display: none !important;
}

.gb-dashboard-tree {
    padding: 12px 14px 14px;
    text-align: center;
}

.gb-dashboard-tree img {
    display: block;
    width: 96px !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 112px;
    margin: 0 auto 10px !important;
    object-fit: contain;
}

.gb-dashboard-tree table {
    width: 100%;
}

.gb-dashboard-menu {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.gb-dashboard-menu .card,
.gb-dashboard-tree .card {
    border-radius: 1rem;
}

.gb-shell-main {
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    padding: 18px;
    background: var(--gb-shell-workspace);
    overflow-x: hidden;
}

.gb-shell-main > * {
    max-width: 100%;
}

.gb-shell-backdrop {
    display: none;
}

.gb-shell-mobile-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gb-shell-border);
    border-radius: 12px;
    background: #fff;
    color: #1f2937;
    font-size: 1.35rem;
    cursor: pointer;
}

.gb-shell-mobile-toggle:hover,
.gb-shell-mobile-toggle:focus-visible {
    background: var(--gb-shell-soft);
    outline: 3px solid rgba(13, 110, 253, 0.18);
    outline-offset: 1px;
}

.gb-shell-mobile-title {
    min-width: 0;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Desktop icon-only rail. The legacy Vue menu remains intact for Phase 1. */
@media (min-width: 992px) {
    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-collapse-label,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-section-label,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-chevron,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-tree-title,
    .gb-dashboard-shell.is-sidebar-collapsed #appDiffuserRank,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu img,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .cbp-vimenu div,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu form,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .btn-link {
        display: none !important;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-sidebar-toolbar {
        padding: 8px 7px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-sidebar-collapse {
        padding-inline: 6px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-shell-section-toggle {
        justify-content: center;
        padding-inline: 8px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-tree {
        padding: 10px 6px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-tree img {
        width: 46px !important;
        max-height: 54px;
        margin-bottom: 0 !important;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu {
        padding: 8px 6px;
        overflow-y: auto;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .cbp-vimenu {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .cbp-vimenu > li {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .link-button {
        display: flex !important;
        width: 100%;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        padding: 8px 4px !important;
        border: 0;
        font-size: 0 !important;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu .link-button > span {
        margin: 0 !important;
        font-size: 1.15rem !important;
    }
}

@media (max-width: 991.98px) {
    body.gb-shell-open {
        overflow: hidden;
    }

    .gb-dashboard-shell,
    .gb-dashboard-shell.is-sidebar-collapsed {
        display: block;
        min-height: 100vh;
    }

    .gb-shell-mobile-bar {
        position: sticky;
        top: 0;
        z-index: 1030;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 62px;
        padding: 9px 12px;
        border-bottom: 1px solid var(--gb-shell-border);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
    }

    .gb-shell-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        height: 100vh;
        transform: translateX(-105%);
        box-shadow: var(--gb-shell-shadow);
        transition: transform 220ms ease;
    }

    .gb-dashboard-shell.is-sidebar-open .gb-shell-sidebar {
        transform: translateX(0);
    }

    .gb-shell-sidebar-toolbar {
        display: none;
    }

    .gb-shell-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1035;
        display: block;
        border: 0;
        background: rgba(15, 23, 42, 0.48);
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease;
    }

    .gb-dashboard-shell.is-sidebar-open .gb-shell-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .gb-shell-main {
        min-height: calc(100vh - 62px);
        padding: 12px;
    }

    .gb-dashboard-tree img {
        width: 78px !important;
        max-height: 92px;
    }
}

@media (max-width: 575.98px) {
    .gb-shell-main {
        padding: 9px;
    }

    .gb-dashboard-menu {
        padding: 10px;
    }

    .gb-dashboard-tree {
        padding: 10px 12px 12px;
    }

    .gb-dashboard-tree img {
        width: 66px !important;
        max-height: 78px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gb-dashboard-shell,
    .gb-shell-sidebar,
    .gb-shell-backdrop,
    .gb-shell-chevron,
    .gb-shell-collapse-icon {
        transition: none;
    }
}

/* Dashboard Shell Phase 2: modern Vue navigation */
[v-cloak] {
    display: none !important;
}

.gb-nav {
    width: 100%;
    min-width: 0;
}

.gb-nav-list {
    display: grid;
    gap: 6px;
}

.gb-nav-group {
    min-width: 0;
}

.gb-nav-parent,
.gb-nav-child,
.gb-nav-subchild {
    appearance: none;
    border: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.gb-nav-parent {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 18px;
    width: 100%;
    min-height: 48px;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
    background: transparent;
    color: #344054;
    font-weight: 700;
    transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.gb-nav-parent:hover,
.gb-nav-parent:focus-visible {
    background: #eef4fb;
    color: #174f88;
    outline: none;
}

.gb-nav-parent:focus-visible,
.gb-nav-child:focus-visible,
.gb-nav-subchild:focus-visible {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.17);
}

.gb-nav-parent.is-active {
    background: #e8f1fb;
    color: #0b5cab;
}

.gb-nav-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f0f5fa;
    color: #2774ae;
    font-size: 1.05rem;
}

.gb-nav-parent.is-active .gb-nav-icon {
    background: #dcecfb;
    color: #0b5cab;
}

.gb-nav-label,
.gb-nav-child-label,
.gb-nav-subchild-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gb-nav-arrow,
.gb-nav-child-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: transform 150ms ease;
}

.gb-nav-parent[aria-expanded="true"] .gb-nav-arrow {
    transform: rotate(180deg);
}

.gb-nav-children {
    position: relative;
    display: grid;
    gap: 3px;
    margin: 3px 0 5px 18px;
    padding: 2px 0 2px 16px;
}

.gb-nav-children::before {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: 2px;
    border-radius: 999px;
    background: #dbe5ef;
    content: "";
}

.gb-nav-form {
    margin: 0;
}

.gb-nav-child,
.gb-nav-subchild {
    display: grid;
    width: 100%;
    align-items: center;
    border-radius: 9px;
    background: transparent;
    color: #475467;
    transition: background-color 150ms ease, color 150ms ease;
}

.gb-nav-child {
    grid-template-columns: 12px minmax(0, 1fr) 16px;
    min-height: 39px;
    gap: 7px;
    padding: 6px 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.gb-nav-child:hover,
.gb-nav-child:focus-visible,
.gb-nav-child.is-active {
    background: #f0f5fa;
    color: #174f88;
    outline: none;
}

.gb-nav-child[aria-expanded="true"] .gb-nav-child-arrow {
    transform: rotate(90deg);
}

.gb-nav-child-marker {
    width: 6px;
    height: 6px;
    justify-self: center;
    border-radius: 50%;
    background: #98a2b3;
}

.gb-nav-child.is-active .gb-nav-child-marker {
    background: #0d6efd;
}

.gb-nav-subchildren {
    display: grid;
    gap: 2px;
    margin-left: 20px;
    padding: 2px 0 4px 8px;
    border-left: 1px dashed #cdd8e5;
}

.gb-nav-subchild {
    grid-template-columns: 9px minmax(0, 1fr);
    min-height: 34px;
    gap: 7px;
    padding: 5px 8px;
    font-size: 0.84rem;
}

.gb-nav-subchild:hover,
.gb-nav-subchild:focus-visible,
.gb-nav-subchild.is-active {
    background: #f5f8fc;
    color: #0b5cab;
    outline: none;
}

.gb-nav-subchild-marker {
    width: 4px;
    height: 4px;
    justify-self: center;
    border-radius: 50%;
    background: #b2bcc8;
}

.gb-nav-subchild.is-active .gb-nav-subchild-marker {
    background: #0d6efd;
}

.gb-nav-state {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border: 1px dashed #d0d9e5;
    border-radius: 12px;
    background: #f8fafc;
    color: var(--gb-shell-muted);
    font-size: 0.875rem;
    text-align: center;
}

.gb-nav-state--error {
    border-color: #f1b7bd;
    background: #fff5f6;
    color: #9f2634;
}

@media (min-width: 992px) {
    .gb-dashboard-shell.is-sidebar-collapsed .gb-dashboard-menu {
        padding: 8px 6px;
        overflow: visible;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-list {
        gap: 5px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-group {
        position: relative;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-parent {
        display: flex;
        width: 48px;
        min-height: 48px;
        margin: 0 auto;
        justify-content: center;
        padding: 6px;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-label,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-arrow,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-children,
    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-state-label {
        display: none !important;
    }

    .gb-dashboard-shell.is-sidebar-collapsed .gb-nav-icon {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
    }
}

@media (max-width: 991.98px) {
    .gb-nav-parent {
        min-height: 50px;
    }
}

/* Phase 2 hotfix: escape legacy constrained wrappers and preserve full workspace width. */
.gb-dashboard-shell {
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

.gb-shell-main {
    max-width: none;
    overflow-x: auto;
}

.gb-shell-main > * {
    min-width: 0;
}

@media (max-width: 991.98px) {
    .gb-dashboard-shell,
    .gb-dashboard-shell.is-sidebar-collapsed {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}
