/* Desktop navigation, independent of each page's UI framework. */
:root { --sidebar-width: clamp(18rem, 20vw, 19rem); }
body.has-shared-sidebar { padding-left: var(--sidebar-width); box-sizing: border-box; }
.shared-sidebar.app-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 45;
    display: flex; flex-direction: column;
    width: var(--sidebar-width); height: 100vh; min-height: 0;
    overflow: hidden; box-sizing: border-box;
    border-right: 1px solid #33415580; background: #0f172a;
    color: #cbd5e1; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
.shared-sidebar *, .shared-sidebar *::before, .shared-sidebar *::after { box-sizing: border-box; }
.shared-sidebar [hidden] { display: none !important; }
.shared-sidebar ul { list-style: none; padding: 0; margin: 0; }
.shared-sidebar li { margin: 0; padding: 0; }
.shared-sidebar #nav-menu li { position: relative; }
.shared-sidebar p, .shared-sidebar h1 { margin: 0; }
.shared-sidebar svg { display: block; width: 20px; height: 20px; flex: 0 0 auto; }
.shared-sidebar > div { flex: 0 0 auto; }
.shared-sidebar > div:first-child { padding: 24px; border-bottom: 1px solid #33415580; }
.shared-sidebar > div > div { display: flex; align-items: center; gap: 12px; }
.shared-sidebar > div > div > div:first-child { width: 40px; height: 40px; flex: 0 0 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; background: #334155; }
.shared-sidebar > div:first-child > div > div:first-child { background: white; border: 1px solid #ffffff33; }
.shared-sidebar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.shared-sidebar h1 { font-size: 18px; font-weight: 700; color: white; }
.shared-sidebar p { font-size: 12px; color: #64748b; }
.shared-sidebar .sidebar-nav { flex: 1 1 0%; overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 16px; scrollbar-gutter: stable; overscroll-behavior: contain; }
.shared-sidebar #nav-menu > li + li { margin-top: 4px; }
.shared-sidebar .nav-item, .shared-sidebar .nav-item-sub {
    display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0;
    margin: 0; border: 0; padding: 12px 16px; border-radius: 12px;
    background: transparent; color: #cbd5e1; font: inherit; text-align: left;
    text-decoration: none; cursor: pointer; box-shadow: none; position: relative;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.shared-sidebar .nav-item-sub { padding: 10px 16px; border-radius: 8px; color: #94a3b8; }
.shared-sidebar #nav-menu li > .nav-item, .shared-sidebar #nav-menu li > .nav-item-sub { padding-right: 52px; }
.shared-sidebar .sidebar-pin-button {
    position: absolute; top: 7px; right: 8px;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 6px; border: 0; border-radius: 8px;
    background: transparent; color: #64748b; opacity: .7; cursor: pointer;
}
.shared-sidebar li > .nav-item-sub ~ .sidebar-pin-button { top: 4px; }
.shared-sidebar .sidebar-pin-button svg { width: 17px; height: 17px; }
.shared-sidebar .sidebar-pin-button:hover, .shared-sidebar .sidebar-pin-button:focus-visible,
.shared-sidebar .sidebar-pinned > .sidebar-pin-button { background: #334155; color: #a5b4fc; opacity: 1; }
.shared-sidebar .sidebar-pin-button:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 1px; }
.shared-sidebar .nav-item-sub svg { width: 16px; height: 16px; }
.shared-sidebar .nav-item > span, .shared-sidebar .nav-item-sub > span, .shared-sidebar .nav-dropdown-trigger > div > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.shared-sidebar .nav-dropdown-trigger { justify-content: space-between; }
.shared-sidebar .nav-dropdown-trigger > div { display: flex; align-items: center; gap: 12px; min-width: 0; }
.shared-sidebar .nav-dropdown-trigger > svg { width: 16px; height: 16px; }
/* Expanded folders indicate hierarchy; only the current page gets an accent. */
.shared-sidebar .nav-item:hover, .shared-sidebar .nav-item-sub:hover {
    background: #1c293d; color: #f1f5f9; transform: none;
}
.shared-sidebar .nav-item::before, .shared-sidebar .nav-item-sub::before { display: none; }
.shared-sidebar .nav-dropdown-trigger.nav-dropdown-active {
    background: #1b283b; color: #e2e8f0;
    box-shadow: inset 0 0 0 1px #94a3b824;
}
.shared-sidebar .nav-dropdown-trigger.nav-dropdown-active:hover { background: #223147; }
.shared-sidebar .nav-dropdown-trigger > div > svg { color: #94a3b8; }
.shared-sidebar .nav-dropdown-trigger > svg { color: #64748b; }
.shared-sidebar .nav-dropdown-trigger[aria-expanded="true"] > svg { color: #cbd5e1; }
.shared-sidebar .nav-item:not(.nav-dropdown-trigger).active, .shared-sidebar .nav-item-sub.active {
    background: #252d48; color: #e0e7ff; font-weight: 600;
    box-shadow: inset 0 0 0 1px #a5b4fc24;
}
.shared-sidebar .nav-item:not(.nav-dropdown-trigger).active:hover, .shared-sidebar .nav-item-sub.active:hover { background: #2d3653; }
.shared-sidebar .nav-item:not(.nav-dropdown-trigger).active > svg, .shared-sidebar .nav-item-sub.active > svg { color: #b4bffe; }
.shared-sidebar .nav-item:not(.nav-dropdown-trigger).active::before, .shared-sidebar .nav-item-sub.active::before {
    content: ''; display: block; position: absolute; left: 0; top: 50%; bottom: auto;
    width: 3px; height: 18px; border-radius: 0 3px 3px 0;
    background: #a5b4fc; transform: translateY(-50%); transition: none;
}
.shared-sidebar .nav-item:focus-visible, .shared-sidebar .nav-item-sub:focus-visible, .shared-sidebar #logout-btn:focus-visible { outline: 2px solid #a5b4fc; outline-offset: -2px; }
.shared-sidebar .nav-submenu { display: none; margin: 8px 0 0 24px; max-height: none; opacity: 1; transform: none; }
.shared-sidebar .nav-submenu > li + li { margin-top: 4px; }
.shared-sidebar .nav-submenu.open { display: block; max-height: none; }
/* Nested X7/X8 groups: a distinct folder header and a guided list of pages. */
.shared-sidebar #office-process-submenu > .nav-feature-group { margin: 6px 0; }
.shared-sidebar #nav-menu .nav-feature-group > .nav-feature-trigger {
    min-height: 42px; padding: 8px 50px 8px 15px;
    border: 1px solid #344861; border-radius: 10px;
    background: #17263a; color: #dbeafe;
}
.shared-sidebar #nav-menu .nav-feature-group > .nav-feature-trigger:hover,
.shared-sidebar #nav-menu .nav-feature-group > .nav-feature-trigger.nav-dropdown-active {
    background: #20334b; border-color: #527198; color: #f8fafc;
}
.shared-sidebar .nav-feature-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.shared-sidebar .nav-feature-code {
    flex: 0 0 auto; padding: 2px 5px; border: 1px solid #456789; border-radius: 5px;
    background: #213d5a; color: #a8d8ff; font-size: 10px; font-weight: 700; line-height: 1.3;
}
.shared-sidebar .nav-feature-trigger .nav-feature-title { min-width: 0; font-size: 12px; font-weight: 600; white-space: nowrap; }
.shared-sidebar .nav-feature-trigger > svg { width: 14px; height: 14px; }
.shared-sidebar .nav-feature-group > .sidebar-pin-button { top: 5px; }
.shared-sidebar #nav-menu .nav-feature-menu {
    margin: 5px 0 9px 12px; padding: 3px 0 2px 11px;
    border-left: 1px solid #405874;
}
.shared-sidebar #nav-menu .nav-feature-menu > li + li { margin-top: 2px; }
.shared-sidebar #nav-menu .nav-feature-menu > li::before {
    content: ''; position: absolute; top: 18px; left: -11px; width: 9px;
    border-top: 1px solid #405874;
}
.shared-sidebar #nav-menu .nav-feature-menu li > .nav-feature-link {
    min-height: 36px; gap: 7px; padding: 7px 41px 7px 8px;
    border-radius: 7px; font-size: 12px;
}
.shared-sidebar #nav-menu .nav-feature-menu .nav-feature-main > .nav-feature-link {
    background: #1b3048; color: #dbeafe; font-weight: 600;
}
.shared-sidebar #nav-menu .nav-feature-menu .nav-feature-child > .nav-feature-link { padding-left: 13px; color: #a8bad0; }
.shared-sidebar .nav-feature-entry-code {
    flex: 0 0 35px; padding: 2px 1px; border-radius: 4px;
    background: #314963; color: #d5e8fb; font-size: 10px; font-weight: 700;
    line-height: 1.35; text-align: center;
}
.shared-sidebar .nav-feature-child .nav-feature-entry-code { background: #26394d; color: #91a9c2; font-weight: 500; }
.shared-sidebar .nav-feature-entry-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-sidebar #nav-menu .nav-feature-menu .nav-feature-link:hover { background: #29415b; color: #fff; }
.shared-sidebar #nav-menu .nav-feature-menu .nav-feature-link.active {
    background: #293b5b; color: #e0e7ff; box-shadow: inset 0 0 0 1px #a5b4fc55;
}
.shared-sidebar [aria-expanded="true"] > svg { transform: rotate(180deg); }
.shared-sidebar > div:last-child { padding: 16px; border-top: 1px solid #33415580; }
.shared-sidebar > div:last-child > div > div:nth-child(2) { flex: 1; min-width: 0; }
.shared-sidebar #user-name { color: white; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-sidebar #logout-btn { display: block; flex: 0 0 auto; padding: 8px; border: 0; background: transparent; color: #64748b; cursor: pointer; }
.shared-sidebar #logout-btn:hover { color: #f87171; }
.sidebar-login-link { position: fixed; top: 16px; left: 16px; z-index: 100; padding: 10px 16px; border-radius: 10px; background: #334155; color: white; text-decoration: none; }

body.has-shared-sidebar[data-sidebar-load-user] { padding-left: calc(var(--sidebar-width) + 20px); }

@media (prefers-reduced-motion: reduce) {
    .shared-sidebar .nav-item, .shared-sidebar .nav-item-sub { transition: none; }
}
