/* Application layout and navigation. */
.app-shell {
    display: flex;
    min-height: 100dvh;
}

.brand {
    padding: 0 10px;
    display: block;
    margin-bottom: 35px;
}

.brand img {
    width: 175px;
    height: auto;
}

.logo-dark {
    display: none;
}

.nav-label {
    font-size: 0.6875rem;
    letter-spacing: 0.14em;
    color: var(--muted);
    padding: 0 14px;
    margin-bottom: 12px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    font-size: 0.875rem;
    color: var(--muted);
    border-radius: 7px;
    min-height: 42px;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--surface-soft);
    color: var(--ink);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-item .icon {
    width: 18px;
    height: 18px;
}

.nav-end {
    margin-left: auto;
}

.nav-button {
    border: 0;
    width: 100%;
    background: none;
    text-align: left;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 50px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--sage-ink);
    background: var(--sage);
    flex-shrink: 0;
}

.avatar-small {
    width: 29px;
    height: 29px;
}

.breadcrumbs strong {
    color: var(--ink);
    font-weight: 500;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.environment {
    font-size: 0.75rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 7px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--green);
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.topbar-divider {
    height: 18px;
    width: 1px;
    background: var(--border);
}

.app-footer a {
    display: flex;
    align-items: center;
    gap: 5px;
}

.app-footer a:hover {
    color: var(--ink);
}

.brand-headline .headline-line {
    display: block;
    white-space: nowrap;
}

.brand-headline .headline-accent {
    color: var(--accent);
}

.sidebar-backdrop[hidden] {
    display: none;
}

@media (max-width: 960px) {
    .sidebar-bottom {
        padding-top: 20px;
    }
}

@media (max-width: 650px) {
    .topbar-actions {
        gap: 10px;
    }

    .environment,
    .topbar-divider {
        display: none;
    }
}

@media (max-width: 650px) {
    .breadcrumbs > span,
    .breadcrumbs > .icon {
        display: none;
    }
}

.topbar-actions {
    flex-shrink: 0;
}

.user-dropdown {
    position: relative;
}

.user-dropdown summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}

.user-dropdown summary::-webkit-details-marker {
    display: none;
}

.user-menu {
    position: absolute;
    top: calc(100% + 16px);
    right: 0;
    width: 240px;
    max-width: 85vw;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 12px 28px #0002;
    display: grid;
    gap: 16px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

@media (max-width: 960px) {
    .user-name {
        display: none;
    }
}

@media (max-width: 650px) {
    .topbar-actions {
        margin-left: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .main-shell,
    .button,
    .icon-button,
    .nav-item,
    a,
    input,
    select,
    textarea {
        transition: none !important;
    }
}

.quick-results {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 390px;
    max-width: calc(100vw - 32px);
    max-height: 65vh;
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 28px #0002;
    display: grid;
    gap: 10px;
}

.quick-results strong {
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 6px;
}

.quick-results a {
    display: block;
    padding: 5px;
    overflow-wrap: anywhere;
    border-radius: 6px;
}

.quick-results a:hover,
.quick-results a:focus-visible {
    background: var(--surface-soft);
}

.sidebar > .brand {
    flex-shrink: 0;
    margin-bottom: 24px;
}

.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-bottom: 16px;
}

.sidebar-bottom {
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    background: var(--sidebar);
}

@media (max-height: 600px) {
    .sidebar > .brand {
        margin-bottom: 12px;
    }

    .sidebar-bottom {
        padding-top: 4px;
    }
}

.topbar-actions {
    gap: 8px;
}

.user-dropdown > summary {
    width: 44px;
    height: 44px;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.user-dropdown > summary:hover,
.user-dropdown[open] > summary {
    border-color: var(--accent);
}

.user-dropdown .avatar-small {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    overflow: hidden;
}

.user-dropdown .avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-menu {
    top: calc(100% + 8px);
    width: 300px;
    gap: 4px;
    padding: 12px;
    max-height: calc(100dvh - 88px);
    overflow-y: auto;
}

.user-menu-heading {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.user-menu-heading strong,
.user-menu-heading small {
    display: block;
}

.user-menu-heading small {
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 4px;
}

.user-menu > a {
    padding: 9px 8px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.user-menu > a:hover {
    background: var(--surface-soft);
}

.user-menu-theme {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    font-size: 0.8rem;
}

.user-menu-theme .theme-picker-panel {
    position: static;
    width: 100%;
    box-shadow: none;
    margin-top: 8px;
}

.user-menu-theme:has(.theme-picker[open]) {
    flex-wrap: wrap;
}

.user-menu-theme .theme-picker[open] {
    width: 100%;
    margin-top: 8px;
}

.user-menu form .button {
    width: 100%;
    margin-top: 8px;
}

.topbar-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--surface-soft);
}

.topbar-search input:focus-visible {
    outline: none;
    box-shadow: none;
}

.search-submit {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}

.search-shortcut {
    flex-shrink: 0;
    padding: 3px 5px;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
    font: 0.62rem var(--font);
    white-space: nowrap;
}

.quick-results {
    width: 100%;
    min-width: 280px;
    padding: 12px;
}

.quick-results a {
    padding: 9px;
}

@media (max-width: 650px) {
    .search-shortcut {
        display: none;
    }

    .user-menu {
        max-width: calc(100vw - 32px);
    }
}

.breadcrumbs a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

:root {
    --sidebar-width: 16rem;
    --page-gutter: clamp(1rem, 2.5vw, 2.25rem);
}

main {
    width: 100%;
    max-width: 1440px;
    margin-inline: auto;
    padding: 2rem var(--page-gutter);
    outline: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    height: 100dvh;
    padding: 1.5rem 1rem 0;
    border-right: 1px solid var(--border);
    background: var(--sidebar);
    overflow: hidden;
}

.sidebar-scroll {
    scrollbar-width: thin;
}

.main-shell {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100dvh;
    flex: 1;
    margin-left: var(--sidebar-width);
}

.main-shell > main {
    flex: 1 0 auto;
}

.main-shell > .app-footer {
    flex-shrink: 0;
    margin: auto var(--page-gutter) 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 26rem) auto;
    align-items: center;
    gap: 1rem;
    min-height: 4.25rem;
    padding: 0.625rem var(--page-gutter);
    border-bottom: 1px solid var(--border);
    background: var(--sidebar);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    font-size: 0.8125rem;
    color: var(--muted);
}

.breadcrumbs strong {
    overflow-wrap: anywhere;
}

.global-search {
    position: relative;
    width: 100%;
    min-width: 0;
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--canvas);
}

.topbar-search input {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 0.5rem 0.25rem;
    border: 0;
    background: transparent;
    font-size: 0.875rem;
}

.quick-results {
    min-width: 0;
    max-width: calc(100vw - 2rem);
}

.user-menu {
    width: min(20rem, calc(100vw - 2rem));
}

.mobile-menu {
    display: none;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: #171e1b80;
}

@media (max-width: 60rem) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        visibility: hidden;
        width: min(var(--sidebar-width), calc(100vw - 2rem));
    }

    .main-shell {
        margin-left: 0;
    }

    .mobile-menu {
        display: grid;
    }

    .menu-open .sidebar {
        left: 0;
        visibility: visible;
    }

    .menu-open {
        overflow: hidden;
    }

    .topbar {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.75rem;
    }

    .topbar .breadcrumbs {
        grid-column: 1;
        grid-row: 1;
    }

    .topbar-actions {
        grid-column: 2;
        grid-row: 1;
    }

    .global-search {
        grid-column: 1 / -1;
        grid-row: 2;
        order: initial;
    }
}

@media (max-height: 38rem) {
    .sidebar {
        padding-top: 0.75rem;
    }
}

.app-footer > * {
    min-width: 0;
}

.user-dropdown:not([open]) > .user-menu {
    display: none;
}

/* Footer grid keeps legal links inside the viewport at every text size. */
.app-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid var(--border);
    padding-block: 1.25rem;
    margin-top: 1.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}
.app-footer > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}
.app-footer > .legal-links {
    grid-column: 1 / -1;
    margin: 0;
}
@media (max-width: 40rem) {
    .app-footer {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }
}

/* Customer navigation: one hierarchy, no duplicated account or promotional blocks. */
.customer-dashboard {
    --sidebar-width: 14rem;
    --page-gutter: clamp(1.25rem, 3vw, 2.75rem);
}
.customer-dashboard .sidebar {
    padding: 2rem 1rem 1.25rem;
}
.customer-dashboard .sidebar > .brand {
    padding: 0 0.625rem;
    margin-bottom: 2.5rem;
}
.customer-dashboard .brand img {
    width: 9rem;
}
.customer-dashboard .nav-list {
    gap: 0.375rem;
}
.customer-dashboard .nav-item {
    min-height: 2.75rem;
    padding: 0.75rem;
    gap: 0.75rem;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
}
.customer-dashboard .nav-item.active {
    background: var(--surface-soft);
    color: var(--ink);
    font-weight: 700;
}
.customer-dashboard .nav-item .icon {
    width: 1.125rem;
    height: 1.125rem;
    stroke-width: 1.75;
}
.customer-dashboard .sidebar-bottom {
    padding-top: 1rem;
}
.customer-dashboard .topbar {
    min-height: 4.5rem;
    background: var(--canvas);
    border-bottom-color: var(--border);
}
.customer-dashboard .topbar-search {
    background: var(--surface);
    border-radius: 0.5rem;
}
.customer-dashboard .user-dropdown > summary {
    width: auto;
    gap: 0.5rem;
    padding: 0.625rem;
    border: 0;
    background: transparent;
}
.customer-dashboard .user-menu > a {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.customer-dashboard .main-shell > main {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
}
.customer-dashboard .page-heading {
    margin-bottom: 2rem;
}
.customer-dashboard .page-heading h1 {
    font-size: clamp(1.625rem, 1.2rem + 1vw, 2.125rem);
    letter-spacing: -0.045em;
}
.customer-dashboard .page-heading p {
    font-size: 0.875rem;
    line-height: 1.6;
}
.customer-dashboard .app-footer {
    padding-block: 1.25rem;
}
.customer-dashboard .app-footer .legal-links {
    gap: 0.5rem 1.25rem;
    font-size: 0.6875rem;
}
.search-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.text-link > .icon {
    vertical-align: middle;
}
@media (max-width: 60rem) {
    .customer-dashboard .sidebar {
        width: min(17rem, calc(100vw - 2rem));
    }
    .customer-dashboard .main-shell > main {
        padding-top: 1.5rem;
    }
}
