.system-nav-bar {
    /* Text not selectable, also with Ctrl+A or dragging from the page content (as on the website) */
    -webkit-user-select: none;
    user-select: none;
    background-color: var(--system-nav-bg);
    border-bottom: 1px solid var(--system-nav-border);
    height: var(--system-nav-height);
    position: fixed;
    z-index: 10000;
    top: 0;
    left: 0;
    right: 0;
    transition: box-shadow 0.3s;
}

.system-nav-bar.scrolled {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

#page-topbar {
    position: fixed !important;
    top: 95px !important;
    z-index: 1002;
}

.system-nav-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    gap: 40px;
    align-items: center;
    position: relative;
}

.system-nav-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.system-nav-logo img {
    height: 35px;
    width: auto;
}

.system-nav-links {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    height: 100%;
}

.system-nav-group {
    display: flex;
    gap: 28px;
    align-items: center;
    height: 100%;
}

/* Separator as a flex item: the group must not be positioned,
   otherwise the mega menu aligns to the group instead of the container */
.system-nav-group-services::before {
    content: "";
    height: 24px;
    border-left: 1px solid var(--system-nav-divider);
}

.system-nav-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
    position: relative;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: color 0.2s;
}

.system-nav-link:hover,
.system-nav-link:focus {
    color: #ffffff;
}

.system-nav-link.active {
    color: #ffffff;
}

.system-nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 2px;
    background-color: var(--system-nav-accent);
    opacity: 0.6;
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.system-nav-link:hover::after {
    transform: scaleX(1);
}

.system-nav-link.active::after {
    opacity: 1;
    transform: scaleX(1);
}

@media (prefers-reduced-motion: reduce) {
    .system-nav-link::after {
        transition: none;
    }
}

/* Dropdown */
.system-nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.system-nav-dropdown-toggle {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

.system-nav-dropdown-toggle .system-nav-glyph {
    font-size: 18px;
    opacity: 0.6;
    transition: transform 0.25s, opacity 0.2s;
}

.system-nav-dropdown:hover .system-nav-dropdown-toggle .system-nav-glyph,
.system-nav-dropdown.open .system-nav-dropdown-toggle .system-nav-glyph {
    opacity: 1;
    transform: rotate(180deg);
}

/* Same style as the mega menu categories */
.system-nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: -24px;
    min-width: 260px;
    overflow: hidden;
    /* Fades from the bar color, so the panel seems to come out from below */
    background: linear-gradient(180deg, var(--system-nav-bg) 0%, var(--system-nav-dropdown-bg) 60%);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 28px 56px rgba(4, 18, 32, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.system-nav-dropdown:hover .system-nav-dropdown-menu,
.system-nav-dropdown.open .system-nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.system-nav-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s, background-color 0.2s;
}

/* Opening: items slide in one after the other */
@media (min-width: 992px) {
    .system-nav-dropdown-menu .system-nav-dropdown-item {
        opacity: 0;
        transform: translateY(-4px);
        transition: color 0.2s, background-color 0.2s, opacity 0.25s ease-out, transform 0.25s ease-out;
    }

    .system-nav-dropdown:hover .system-nav-dropdown-item,
    .system-nav-dropdown.open .system-nav-dropdown-item {
        opacity: 1;
        transform: none;
    }

    .system-nav-dropdown-item:nth-child(2) { transition-delay: 0s, 0s, 0.04s, 0.04s; }
    .system-nav-dropdown-item:nth-child(3) { transition-delay: 0s, 0s, 0.08s, 0.08s; }
    .system-nav-dropdown-item:nth-child(4) { transition-delay: 0s, 0s, 0.12s, 0.12s; }
    .system-nav-dropdown-item:nth-child(5) { transition-delay: 0s, 0s, 0.16s, 0.16s; }
    .system-nav-dropdown-item:nth-child(6) { transition-delay: 0s, 0s, 0.2s, 0.2s; }
}

@media (prefers-reduced-motion: reduce) {
    .system-nav-dropdown-menu .system-nav-dropdown-item {
        transform: none;
        transition: color 0.2s, background-color 0.2s;
    }
}

/* Small arrow as in the mega menu categories */
.system-nav-dropdown-item::after {
    content: "";
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    opacity: 0;
    transform: translateX(-4px) rotate(45deg);
    transition: opacity 0.2s, transform 0.2s;
}

.system-nav-dropdown-item:hover,
.system-nav-dropdown-item:focus,
.system-nav-dropdown-item.active {
    color: var(--system-nav-bg);
    background-color: #ffffff;
}

.system-nav-dropdown-item:hover::after,
.system-nav-dropdown-item:focus::after,
.system-nav-dropdown-item.active::after {
    opacity: 1;
    transform: translateX(0) rotate(45deg);
}

.system-nav-dropdown-item .system-nav-glyph {
    font-size: 14px;
    opacity: 0.6;
    transition: transform 0.2s, opacity 0.2s;
}

.system-nav-dropdown-item:hover .system-nav-glyph {
    opacity: 1;
    transform: translate(2px, -2px);
}

/* Mega menu: as wide as the container, categories on the left and columns on the right */
.system-nav-dropdown-mega {
    position: static;
}

.system-nav-mega {
    position: absolute;
    top: 100%;
    left: 24px;
    right: 24px;
    display: flex;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.system-nav-dropdown:hover .system-nav-mega,
.system-nav-dropdown.open .system-nav-mega {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Categories share the full height: no empty space below the last one */
.system-nav-mega-tabs {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    width: 280px;
    background-color: var(--system-nav-dropdown-bg);
}

.system-nav-mega-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 20px 24px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.system-nav-mega-tab .system-nav-glyph {
    font-size: 20px;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s, transform 0.2s;
}

.system-nav-mega-tab:hover {
    color: #ffffff;
    background-color: var(--system-nav-hover-bg);
}

.system-nav-mega-tab.active {
    color: var(--system-nav-bg);
    background-color: #ffffff;
}

.system-nav-mega-tab.active .system-nav-glyph {
    opacity: 1;
    transform: translateX(0);
}

/* Fixed height: the menu does not resize when switching category */
.system-nav-mega-panes {
    flex: 1;
    height: 228px;
    overflow-y: auto;
    padding: 28px 36px 32px;
    background-color: #ffffff;
}

.system-nav-mega-pane {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px 40px;
}

.system-nav-mega-pane.active {
    display: grid;
}

.system-nav-mega-title {
    margin: 0 0 12px;
    color: #343f52;
    font-size: 15px;
    font-weight: 700;
}

.system-nav-mega-link {
    display: block;
    padding: 5px 0;
    color: #60697b;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    break-inside: avoid;
    transition: color 0.2s;
}

.system-nav-mega-link:hover,
.system-nav-mega-link:focus {
    color: #327ea8;
}

.system-nav-mega-link .system-nav-glyph {
    font-size: 13px;
    opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
    .system-nav-dropdown-menu,
    .system-nav-mega,
    .system-nav-dropdown-toggle .system-nav-glyph {
        transition: none;
    }
}

.system-nav-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.system-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 19px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    opacity: 0.72;
    transition: opacity 0.2s, background-color 0.2s;
}

.system-nav-icon:hover {
    opacity: 1;
    background-color: var(--system-nav-hover-bg);
}

/* Login: white button, like the selected menu items */
.system-nav-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 18px 7px 14px;
    border: 1px solid #ffffff;
    border-radius: 999px;
    background-color: #ffffff;
    color: var(--system-nav-bg);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

.system-nav-login .system-nav-glyph {
    font-size: 18px;
    color: #327ea8;
}

/* Same hover as the website theme .btn buttons */
.system-nav-login:hover,
.system-nav-login:focus {
    color: var(--system-nav-bg);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(30, 34, 40, 0.15);
}

@media (prefers-reduced-motion: reduce) {
    .system-nav-login {
        transition: none;
    }
}

.system-nav-login:focus-visible {
    outline: 2px solid var(--system-nav-accent);
    outline-offset: 2px;
}

.system-nav-actions .logged-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--system-nav-border);
    transition: border-color 0.2s;
}

/* Initials when no avatar url is given */
.system-nav-actions .logged-user-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--system-nav-accent);
    color: var(--system-nav-bg);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    word-spacing: normal;
}

.system-nav-actions .system-nav-user-info .logged-user-avatar-placeholder {
    font-size: 16px;
}

.system-nav-actions .logged-user-avatar:hover {
    border-color: var(--system-nav-accent);
}

/* User menu: same panel as the Company dropdown, right aligned */
.system-nav-user {
    position: relative;
}

.system-nav-user-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--system-nav-height);
    padding: 0;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
}

.system-nav-user-toggle > .system-nav-glyph {
    font-size: 18px;
    opacity: 0.6;
    transition: transform 0.25s, opacity 0.2s;
}

.system-nav-user:hover .system-nav-user-toggle .logged-user-avatar,
.system-nav-user.open .system-nav-user-toggle .logged-user-avatar {
    border-color: var(--system-nav-accent);
}

.system-nav-user:hover .system-nav-user-toggle > .system-nav-glyph,
.system-nav-user.open .system-nav-user-toggle > .system-nav-glyph {
    opacity: 1;
    transform: rotate(180deg);
}

.system-nav-user-toggle:focus-visible {
    outline: 2px solid var(--system-nav-accent);
    outline-offset: 2px;
}

.system-nav-user-menu {
    position: absolute;
    top: 100%;
    right: -24px;
    min-width: 280px;
    overflow: hidden;
    background: linear-gradient(180deg, var(--system-nav-bg) 0%, var(--system-nav-dropdown-bg) 60%);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 28px 56px rgba(4, 18, 32, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.system-nav-user:hover .system-nav-user-menu,
.system-nav-user.open .system-nav-user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.system-nav-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    background-color: rgba(255, 255, 255, 0.04);
}

.system-nav-actions .system-nav-user-info .logged-user-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
}

.system-nav-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.system-nav-user-details .logged-user-name {
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.system-nav-user-details .logged-user-email {
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.system-nav-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 24px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s, background-color 0.2s;
}

/* Custom items without url are buttons: same look as the links */
button.system-nav-user-item {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
}

.system-nav-user-item .system-nav-glyph {
    font-size: 18px;
    opacity: 0.7;
}

.system-nav-user-item:hover,
.system-nav-user-item:focus {
    color: var(--system-nav-bg);
    background-color: #ffffff;
}

.system-nav-user-item:hover .system-nav-glyph,
.system-nav-user-item:focus .system-nav-glyph {
    opacity: 1;
}

/* Impersonation by an administrator: orange avatar ring, ghost badge and name */
.logged-user-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.system-nav-actions .logged-user-impersonated .logged-user-avatar,
.system-nav-user:hover .system-nav-user-toggle .logged-user-impersonated .logged-user-avatar,
.system-nav-user.open .system-nav-user-toggle .logged-user-impersonated .logged-user-avatar {
    border-color: var(--system-nav-impersonation);
}

.system-nav-actions .system-nav-user-info .logged-user-impersonated .logged-user-avatar {
    border: 2px solid var(--system-nav-impersonation);
}

.logged-user-impersonation-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--system-nav-bg);
    background-color: var(--system-nav-impersonation);
    color: var(--system-nav-bg);
}

.logged-user-impersonation-badge .system-nav-glyph {
    font-size: 11px;
    line-height: 1;
}

.system-nav-user-details .logged-user-name.logged-user-impersonated {
    color: var(--system-nav-impersonation);
}

.system-nav-user-item.system-nav-user-item-impersonation {
    color: var(--system-nav-impersonation);
}

.system-nav-user-item.system-nav-user-item-impersonation:hover,
.system-nav-user-item.system-nav-user-item-impersonation:focus {
    color: #ffffff;
    background-color: var(--system-nav-impersonation);
}

@media (max-width: 991.98px) {
    .system-nav-user-menu {
        right: -16px;
        max-width: 100vw;
    }

    /* On touch devices the menu opens only on tap */
    .system-nav-user:hover .system-nav-user-menu {
        opacity: 0;
        visibility: hidden;
    }

    .system-nav-user.open .system-nav-user-menu {
        opacity: 1;
        visibility: visible;
    }
}

.system-nav-link:focus-visible,
.system-nav-icon:focus-visible,
.system-nav-hamburger:focus-visible,
.system-nav-logo:focus-visible {
    outline: 2px solid var(--system-nav-accent);
    outline-offset: 2px;
}

.system-nav-hamburger {
    display: none;
    position: relative;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
}

.system-nav-hamburger:hover {
    background-color: var(--system-nav-hover-bg);
}

.system-nav-hamburger span,
.system-nav-hamburger span::before,
.system-nav-hamburger span::after {
    position: absolute;
    left: 10px;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background-color: #ffffff;
    transition: transform 0.25s, background-color 0.25s;
}

.system-nav-hamburger span {
    top: 19px;
}

.system-nav-hamburger span::before,
.system-nav-hamburger span::after {
    content: "";
    left: 0;
}

.system-nav-hamburger span::before {
    transform: translateY(-6px);
}

.system-nav-hamburger span::after {
    transform: translateY(6px);
}

.system-nav-hamburger[aria-expanded="true"] span {
    background-color: transparent;
}

.system-nav-hamburger[aria-expanded="true"] span::before {
    transform: rotate(45deg);
}

.system-nav-hamburger[aria-expanded="true"] span::after {
    transform: rotate(-45deg);
}

/* Tablet and mobile: hamburger menu */
@media (max-width: 991.98px) {
    .system-nav-container {
        gap: 8px;
        padding: 0 16px;
    }

    .system-nav-logo {
        margin-right: auto;
    }

    .system-nav-hamburger {
        display: block;
    }

    .system-nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: auto;
        max-height: calc(100vh - var(--system-nav-height));
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 12px 16px 20px;
        background-color: var(--system-nav-bg);
        border-bottom: 1px solid var(--system-nav-border);
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
    }

    .system-nav-links.open {
        display: flex;
        animation: system-nav-open 0.2s ease-out;
    }

    .system-nav-group {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        height: auto;
    }

    .system-nav-group-services::before {
        display: none;
    }

    .system-nav-link {
        align-self: flex-start;
        margin: 6px 8px;
        font-size: 16px;
    }

    /* In the panel the dropdowns are always-open sections */
    .system-nav-dropdown {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        margin-top: 20px;
    }

    .system-nav-dropdown-toggle,
    .system-nav-dropdown-toggle.active {
        align-self: stretch;
        gap: 12px;
        margin: 0 8px 6px;
        padding: 0;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--system-nav-accent);
        pointer-events: none;
    }

    /* Thin line following the section label */
    .system-nav-dropdown-toggle::after,
    .system-nav-dropdown-toggle.active::after {
        position: static;
        flex: 1;
        height: 1px;
        border-radius: 0;
        background-color: var(--system-nav-divider);
        opacity: 1;
        transform: none;
        transition: none;
    }

    .system-nav-dropdown-toggle .system-nav-glyph {
        display: none;
    }

    .system-nav-dropdown-menu {
        position: static;
        min-width: 0;
        padding: 0;
        background: none;
        border: none;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
    }

    .system-nav-dropdown-menu {
        overflow: visible;
        border-radius: 0;
    }

    .system-nav-dropdown-item {
        justify-content: flex-start;
        padding: 12px 8px;
        border-radius: 8px;
        color: rgba(255, 255, 255, 0.72);
        font-size: 16px;
    }

    .system-nav-dropdown-item::after {
        display: none;
    }

    .system-nav-dropdown-item:hover,
    .system-nav-dropdown-item:focus {
        color: #ffffff;
        background-color: var(--system-nav-hover-bg);
    }

    .system-nav-dropdown-item.active {
        color: var(--system-nav-accent);
        background-color: transparent;
    }

    /* Mega menu in the panel: categories in sequence, no tabs */
    .system-nav-mega {
        position: static;
        display: block;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
    }

    .system-nav-mega-tabs {
        display: none;
    }

    .system-nav-mega-panes {
        height: auto;
        overflow: visible;
        padding: 0;
        background: none;
    }

    .system-nav-mega-pane,
    .system-nav-mega-pane.active {
        display: block;
    }

    .system-nav-mega-column {
        margin-top: 8px;
    }

    .system-nav-mega-title {
        margin: 8px 8px 0;
        color: rgba(255, 255, 255, 0.45);
        font-size: 12px;
        font-weight: 700;
    }

    .system-nav-mega-link {
        padding: 10px 8px;
        color: rgba(255, 255, 255, 0.72);
        font-size: 16px;
        font-weight: 600;
    }

    .system-nav-mega-link:hover,
    .system-nav-mega-link:focus {
        color: #ffffff;
    }
}

@keyframes system-nav-open {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */
@media (max-width: 768px) {
    #layout-wrapper {
        padding-top: 96px;
    }
}
