:root {
    --app-header-height: 72px;
    --app-header-border: #e5e7eb;
    --app-header-bg: #ffffff;
    --app-header-text: #111827;
    --app-header-muted: #9ca3af;
    --app-header-accent: #4f46e5;
    --app-header-hover: #f5f3ff;
    --app-header-focus: #6366f1;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 2000;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    min-height: var(--app-header-height);
    margin-bottom: 24px;
    padding: 0 16px;
    border-bottom: 1px solid var(--app-header-border);
    background: var(--app-header-bg);
    color: var(--app-header-text);
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-shrink: 0;
    justify-self: start;
    z-index: 1;
}

.app-header__brand-link {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.app-header__brand-link:focus-visible {
    outline: 2px solid var(--app-header-focus);
    outline-offset: 3px;
    border-radius: 6px;
}

.app-header__brand-text {
    min-width: 0;
}

.app-header__brand-text .eyebrow {
    margin: 0 0 2px;
    color: var(--app-header-muted);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
}

.app-header__brand-text h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--app-header-text);
}

.app-header__primary {
    display: flex;
    align-items: stretch;
    justify-self: center;
    gap: 8px;
    height: 100%;
    z-index: 0;
}

.app-header__link {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--app-header-text);
    text-decoration: none;
    font: inherit;
    font-size: 0.98rem;
    line-height: 1.2;
}

.app-header__link:hover {
    color: var(--app-header-accent);
}

.app-header__link:focus-visible {
    outline: 2px solid var(--app-header-focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.app-header__link.is-active {
    color: var(--app-header-accent);
    font-weight: 600;
    border-bottom-color: var(--app-header-accent);
}

.app-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    z-index: 1;
}

.app-header__actions--session {
    justify-self: end;
    gap: 6px;
}

.app-header__action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--app-header-text);
    text-decoration: none;
    font: inherit;
    line-height: 1;
}

.app-header__action--icon {
    justify-content: center;
    width: 40px;
    padding: 8px;
    color: var(--app-header-text);
}

.app-header__action:hover {
    background: var(--app-header-hover);
    color: var(--app-header-accent);
}

.app-header__action:focus-visible {
    outline: 2px solid var(--app-header-focus);
    outline-offset: 2px;
}

.app-header__action-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.app-header__action-label {
    font-size: 0.95rem;
}

.app-header__account {
    position: relative;
}

.app-header__account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 4px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--app-header-text);
    font: inherit;
    cursor: pointer;
}

.app-header__account-trigger:focus-visible,
.app-header__account.is-open .app-header__account-trigger {
    outline: 2px solid var(--app-header-focus);
    outline-offset: 2px;
}

.app-header__account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--app-header-accent);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 700;
}

.app-header__account-name {
    display: none;
}

.app-header__account-chevron {
    width: 16px;
    height: 16px;
    color: var(--app-header-text);
}

.app-header__account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 40;
    min-width: 220px;
    padding: 10px;
    border: 1px solid var(--app-header-border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.app-header__account-menu[hidden] {
    display: none;
}

.app-header__account-meta {
    padding: 6px 8px 10px;
    border-bottom: 1px solid var(--app-header-border);
    margin-bottom: 8px;
}

.app-header__account-meta-name {
    margin: 0;
    font-weight: 600;
}

.app-header__account-meta-role {
    margin: 2px 0 0;
    color: var(--app-header-muted);
    font-size: 0.85rem;
}

.app-header__account-link,
.app-header__account-logout {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--app-header-text);
    text-align: left;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
}

.app-header__account-link:hover,
.app-header__account-logout:hover {
    background: var(--app-header-hover);
}

.app-header__account-link:focus-visible,
.app-header__account-logout:focus-visible {
    outline: 2px solid var(--app-header-focus);
    outline-offset: 1px;
}

.app-header__account-logout-form {
    margin: 0;
}

.app-header .topbar-mode-toggle {
    margin-left: 0;
}

.app-header__context {
    display: none;
}

.app-header__menu-toggle {
    display: none;
}

.app-header__mobile-menu {
    display: none;
}

@media (max-width: 960px) {
    .app-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        z-index: 2000;
        padding: 10px 12px 8px;
        column-gap: 10px;
        row-gap: 4px;
    }

    .app-header__brand {
        flex: 1 1 auto;
        min-width: 0;
    }

    .app-header__brand-text h1 {
        font-size: 1.1rem;
    }

    .app-header__context {
        display: block;
        order: 3;
        width: 100%;
        margin: 0;
        padding: 2px 0 6px;
        color: var(--app-header-muted);
        font-size: 0.85rem;
        font-weight: 600;
    }

    .app-header__primary {
        display: none;
    }

    .app-header__actions--session {
        margin-left: auto;
        flex: 0 0 auto;
    }

    .app-header__account {
        display: none;
    }

    .app-header__login-link {
        display: none;
    }

    .app-header__menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: 0;
        min-height: 44px;
        min-width: 44px;
        padding: 8px;
        justify-content: center;
        border: 1px solid var(--app-header-border);
        border-radius: 10px;
        background: #ffffff;
        color: var(--app-header-text);
        font: inherit;
        font-size: 0.9rem;
        cursor: pointer;
    }

    .app-header__menu-toggle:focus-visible {
        outline: 2px solid var(--app-header-focus);
        outline-offset: 2px;
    }

    .app-header__menu-toggle-bars {
        display: inline-block;
        width: 18px;
        height: 2px;
        background: currentColor;
        box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
    }

    .app-header__mobile-menu {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10000;
        background: rgba(17, 24, 39, 0.35);
    }

    .app-header__mobile-menu[hidden] {
        display: none;
    }

    .app-header__mobile-menu-panel {
        position: absolute;
        top: 0;
        right: 0;
        z-index: 10001;
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: min(100%, 360px);
        height: 100%;
        padding: 16px;
        overflow-y: auto;
        background: #ffffff;
        box-shadow: -12px 0 30px rgba(17, 24, 39, 0.12);
    }

    .app-header__mobile-menu-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 8px;
    }

    .app-header__mobile-menu-title {
        margin: 0;
        font-size: 1.05rem;
        font-weight: 700;
    }

    .app-header__mobile-menu-close {
        min-height: 44px;
        padding: 8px 12px;
        border: 1px solid var(--app-header-border);
        border-radius: 10px;
        background: #ffffff;
        color: var(--app-header-text);
        font: inherit;
        cursor: pointer;
    }

    .app-header__mobile-menu-close:focus-visible {
        outline: 2px solid var(--app-header-focus);
        outline-offset: 2px;
    }

    .app-header__mobile-group {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 8px 0 12px;
        border-bottom: 1px solid var(--app-header-border);
    }

    .app-header__mobile-group:last-child {
        border-bottom: 0;
    }

    .app-header__mobile-account-meta {
        padding: 4px 10px 8px;
    }

    .app-header__mobile-account-name {
        margin: 0;
        font-weight: 600;
    }

    .app-header__mobile-account-role {
        margin: 2px 0 0;
        color: var(--app-header-muted);
        font-size: 0.85rem;
    }

    .app-header__mobile-link {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 10px 12px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--app-header-text);
        text-align: left;
        text-decoration: none;
        font: inherit;
        font-size: 1rem;
        cursor: pointer;
        width: 100%;
    }

    .app-header__mobile-link:hover,
    .app-header__mobile-link.is-active {
        background: var(--app-header-hover);
        color: var(--app-header-accent);
    }

    .app-header__mobile-link.is-active {
        font-weight: 600;
    }

    .app-header__mobile-link:focus-visible {
        outline: 2px solid var(--app-header-focus);
        outline-offset: 1px;
    }

    .app-header__mobile-logout-form {
        margin: 0;
    }

    body.app-header-mobile-open {
        overflow: hidden;
    }
}
