#app-header.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    min-height: 68px;
    align-items: center;
    gap: clamp(12px, 1.8vw, 28px);
    padding: 8px clamp(14px, 2vw, 28px);
    overflow: visible;
    border-bottom: 1px solid var(--border-color);
    background: rgb(15 17 23 / 96%);
    box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
    backdrop-filter: blur(12px);
    transform: translateY(0);
    transition: transform 190ms ease;
    will-change: transform;
}

.app-header--hidden { transform: translateY(calc(-100% - 1px)); }
.app-header--visible { transform: translateY(0); }

.app-brand {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 11px;
    min-width: 0;
    color: #f8fafc;
    text-decoration: none;
}

.app-brand-logo {
    display: block;
    width: auto;
    height: 28px;
    flex: 0 0 auto;
    object-fit: contain;
}

.app-brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.05;
}

.app-brand-copy strong { font-size: 1rem; letter-spacing: 0.04em; }
.app-brand-copy small {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.66rem;
    white-space: nowrap;
}

.app-greeting {
    min-width: 0;
    max-width: 220px;
    margin: 0;
    overflow: hidden;
    color: #cbd5e1;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-greeting strong { color: #fff; }

.app-header .app-nav {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex-wrap: nowrap;
}

.app-header .app-nav-link {
    min-height: 38px;
    padding: 8px 11px;
    white-space: nowrap;
}

.app-profile { position: relative; flex: 0 0 auto; margin-left: 2px; }

.app-profile-trigger,
.app-profile-logout {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #334155;
    border-radius: 9px;
    background: #172033;
    color: #e2e8f0;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.app-profile-trigger { padding: 8px 11px; }
.app-profile-trigger:hover,
.app-profile.is-open .app-profile-trigger {
    border-color: #60a5fa;
    background: rgb(59 130 246 / 14%);
    color: #fff;
}

.app-profile-chevron { font-size: 0.62rem; transition: transform 150ms ease; }
.app-profile.is-open .app-profile-chevron { transform: rotate(180deg); }

.app-profile-menu {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    z-index: 50;
    width: min(280px, calc(100vw - 28px));
    overflow: hidden;
    border: 1px solid #334155;
    border-radius: 12px;
    background: #111827;
    box-shadow: 0 18px 45px rgb(0 0 0 / 42%);
}

.app-profile-identity {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    padding: 15px;
}

.app-profile-identity strong,
.app-profile-identity span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-profile-identity strong { color: #f8fafc; font-size: 0.88rem; }
.app-profile-identity span { color: #cbd5e1; font-size: 0.75rem; }
.app-profile-identity small { color: #60a5fa; font-size: 0.7rem; font-weight: 700; }

.app-profile-logout {
    width: 100%;
    justify-content: flex-start;
    padding: 11px 15px;
    border: 0;
    border-top: 1px solid #293246;
    border-radius: 0;
    background: transparent;
    color: #fca5a5;
}

.app-profile-logout:hover { background: rgb(239 68 68 / 10%); color: #fecaca; }

.app-profile-trigger:focus-visible,
.app-profile-logout:focus-visible,
.app-brand:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 2px;
}

.app-page-heading {
    padding: 16px 24px 2px;
}

.app-page-heading--dashboard {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-block: 10px;
}

.app-page-heading-copy {
    flex: 0 0 auto;
    min-width: 0;
}

.dashboard-filter-panel {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.app-page-heading h1 { margin: 0; font-size: 1.25rem; }
.app-page-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.76rem; }

@media (max-width: 1120px) {
    #app-header.app-header { gap: 10px; padding-inline: 14px; }
    .app-brand-copy small { font-size: 0.6rem; }
    .app-greeting { max-width: 145px; }
    .app-header .app-nav-link { padding-inline: 8px; }
    .app-page-heading--dashboard { gap: 10px; padding-inline: 14px; }
}

@media (max-width: 900px) {
    .app-brand-copy small { display: none; }
    .app-greeting { max-width: 120px; }
    .app-header .app-nav-link span { display: none; }
    .app-header .app-nav-link { width: 38px; padding: 8px; justify-content: center; }
    .app-page-heading--dashboard { align-items: stretch; flex-direction: column; gap: 6px; }
}

@media (max-width: 720px) {
    #app-header.app-header {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        min-height: 62px;
        gap: 7px 10px;
        padding: 7px 10px;
    }
    .app-brand-logo { height: 23px; }
    .app-brand-copy small { display: none; }
    .app-greeting { max-width: none; }
    .app-header .app-nav {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
    .app-header .app-nav-link { width: auto; flex: 1 1 0; }
    .app-header .app-nav-link span { display: inline; }
    .app-profile-trigger span { display: none; }
    .app-profile-trigger { width: 38px; padding: 8px; }
    .app-profile-chevron { display: none; }
    .app-page-heading { padding: 13px 14px 0; }
}

@media (max-width: 460px) {
    .app-brand-copy { display: none; }
    .app-greeting { font-size: 0.75rem; }
    .app-header .app-nav-link { padding-inline: 5px; font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
    .app-header,
    .app-profile-chevron { transition: none; }
}
