body.app-authenticated {
    --nav-navy: #0b1739;
    --nav-blue: #3157d5;
    --nav-blue-soft: #eef3ff;
    --nav-border: #e6eaf2;
    --nav-text: #1c2943;
    --nav-muted: #7c879b;
}

body.app-authenticated .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

body.app-authenticated .sidebar,
body.app-authenticated .sidebar-backdrop {
    display: none !important;
}

body.app-authenticated .main-area {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
}

.app-header {
    position: sticky;
    z-index: 900;
    top: 0;
    width: 100%;
    color: var(--nav-text);
    background: rgba(255, 255, 255, .98);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: 0 8px 30px rgba(11, 23, 57, .055);
    backdrop-filter: blur(18px);
}

.app-header-main {
    display: grid;
    grid-template-columns: minmax(210px, .7fr) minmax(280px, 1.5fr) auto;
    align-items: center;
    gap: clamp(18px, 3vw, 44px);
    min-height: 58px;
    padding: 7px clamp(18px, 3.5vw, 56px);
}

.app-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    width: max-content;
    color: var(--nav-navy);
    text-decoration: none;
}

.app-header .brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    color: #fff;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .08em;
    background: linear-gradient(145deg, #183374, #2f5de1);
    border-radius: 11px;
    box-shadow: 0 9px 22px rgba(47, 93, 225, .24);
}

.app-header .brand > span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.app-header .brand strong {
    font-size: 13px;
    font-weight: 680;
    letter-spacing: -.015em;
}

.app-header .brand small {
    margin-top: 3px;
    color: var(--nav-muted);
    font-size: 10px;
    font-weight: 450;
}

.app-header .top-search {
    width: min(100%, 660px);
    margin: 0 auto;
}

.app-header .top-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    justify-self: end;
}

.app-header .top-search input {
    height: 36px;
}

.theme-toggle {
    position: relative;
}

.theme-toggle [data-theme-icon] {
    position: absolute;
}

.theme-toggle [data-theme-icon="light"] {
    display: none;
}

html[data-theme="dark"] .theme-toggle [data-theme-icon="dark"] {
    display: none;
}

html[data-theme="dark"] .theme-toggle [data-theme-icon="light"] {
    display: block;
}

.nav-toggle {
    display: none !important;
}

.horizontal-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 43px;
    padding: 0 clamp(18px, 3.5vw, 56px);
    background: #f4f7fb;
    border-top: 1px solid #dfe5ef;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
}

.horizontal-nav svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    stroke-width: 1.8;
}

.nav-direct,
.nav-dropdown-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 35px;
    padding: 0 13px;
    color: #526078;
    font: inherit;
    font-size: 12px;
    font-weight: 540;
    white-space: nowrap;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease;
}

.nav-direct:hover,
.nav-dropdown-toggle:hover,
.nav-direct.active,
.nav-dropdown.active > .nav-dropdown-toggle {
    color: #244ac2;
    background: #e7edfb;
}

.nav-direct.active::after,
.nav-dropdown.active > .nav-dropdown-toggle::after {
    position: absolute;
    right: 13px;
    bottom: -4px;
    left: 13px;
    height: 2px;
    content: "";
    background: #3157d5;
    border-radius: 2px 2px 0 0;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle svg:last-child {
    width: 14px;
    height: 14px;
    margin-left: 1px;
    transition: transform .18s ease;
}

.nav-dropdown.open > .nav-dropdown-toggle svg:last-child {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    z-index: 930;
    top: calc(100% + 10px);
    left: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(230px, 1fr));
    gap: 5px;
    width: min(530px, calc(100vw - 32px));
    padding: 9px;
    visibility: hidden;
    opacity: 0;
    background: rgba(255, 255, 255, .99);
    border: 1px solid var(--nav-border);
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(11, 23, 57, .16);
    transform: translateY(-6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.nav-dropdown-menu.compact {
    grid-template-columns: 1fr;
    width: 285px;
}

.nav-dropdown-menu.admin-menu {
    width: min(555px, calc(100vw - 32px));
}

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

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 58px;
    padding: 10px 12px;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: 11px;
    transition: background-color .16s ease, color .16s ease, transform .16s ease;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
    color: #244ac2;
    background: #f1f5ff;
    transform: translateX(2px);
}

.nav-dropdown-menu a > svg {
    width: 20px;
    height: 20px;
    padding: 9px;
    overflow: visible;
    color: #3157d5;
    background: #e8efff;
    border-radius: 10px;
    box-sizing: content-box;
}

.nav-dropdown-menu a > span {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.nav-dropdown-menu strong {
    font-size: 13px;
    font-weight: 630;
}

.nav-dropdown-menu small {
    margin-top: 3px;
    color: var(--nav-muted);
    font-size: 11px;
    font-weight: 430;
}

.nav-backdrop {
    position: fixed;
    z-index: 880;
    inset: 0;
    display: none;
    background: rgba(8, 18, 42, .34);
    backdrop-filter: blur(2px);
}

.assignment-auto {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    color: #1b397e;
    background: #f0f5ff;
    border: 1px solid #dce7ff;
    border-radius: 12px;
}

.assignment-auto-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: #3157d5;
    background: #fff;
    border-radius: 10px;
}

.assignment-auto span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.assignment-auto strong {
    font-size: 12px;
    font-weight: 650;
}

.assignment-auto small {
    margin-top: 3px;
    color: #66789e;
    font-size: 11px;
    line-height: 1.4;
}

@media (max-width: 1120px) {
    .app-header-main {
        grid-template-columns: minmax(190px, .7fr) minmax(230px, 1.2fr) auto;
        gap: 18px;
    }

    .nav-direct,
    .nav-dropdown-toggle {
        padding-inline: 10px;
    }
}

@media (max-width: 920px) {
    .app-header {
        position: sticky;
    }

    .app-header-main {
        display: flex;
        min-height: 58px;
        gap: 10px;
        padding: 7px 16px;
    }

    .app-header .brand {
        margin-right: auto;
    }

    .app-header .top-search {
        display: none;
    }

    .nav-toggle {
        display: inline-grid !important;
        order: 2;
    }

    .app-header .top-actions {
        order: 3;
    }

    .horizontal-nav {
        position: absolute;
        z-index: 910;
        top: 100%;
        right: 12px;
        left: 12px;
        display: flex;
        max-height: min(72vh, 650px);
        min-height: 0;
        padding: 10px;
        overflow-y: auto;
        visibility: hidden;
        flex-direction: column;
        align-items: stretch;
        opacity: 0;
        background: #fff;
        border: 1px solid var(--nav-border);
        border-radius: 0 0 16px 16px;
        box-shadow: 0 24px 54px rgba(11, 23, 57, .18);
        transform: translateY(-8px);
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }

    body.nav-open .horizontal-nav {
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
    }

    body.nav-open .nav-backdrop {
        display: block;
    }

    .nav-direct,
    .nav-dropdown-toggle {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
    }

    .nav-dropdown-toggle svg:last-child {
        margin-left: auto;
    }

    .nav-direct.active::after,
    .nav-dropdown.active > .nav-dropdown-toggle::after {
        top: 9px;
        right: auto;
        bottom: 9px;
        left: -2px;
        width: 3px;
        height: auto;
    }

    .nav-dropdown-menu,
    .nav-dropdown-menu.compact,
    .nav-dropdown-menu.admin-menu {
        position: static;
        display: none;
        grid-template-columns: 1fr;
        width: 100%;
        padding: 5px 5px 7px 18px;
        visibility: visible;
        opacity: 1;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        transform: none;
    }

    .nav-dropdown.open > .nav-dropdown-menu {
        display: grid;
    }

    .nav-dropdown-menu a {
        min-height: 54px;
        background: #f8faff;
    }
}

@media (max-width: 560px) {
    .app-header-main {
        padding-inline: 12px;
    }

    .app-header .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .app-header .brand strong {
        font-size: 13px;
    }

    .app-header .brand small,
    .app-header .user-pill > span:not(.avatar) {
        display: none;
    }

    .app-header .top-actions {
        gap: 5px;
    }

    .app-header .top-actions > .icon-button {
        display: none;
    }

    .horizontal-nav {
        right: 8px;
        left: 8px;
    }
}
