header {
    position: sticky;
    top: 0;
    left: 0;
    height: 65px;
    z-index: 100;
    background: var(--header-background-color);
    padding: 15px 0;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

    header .nav-menu-icon {
        font: 400 1.5rem/1.5rem var(--font-icon);
        padding: 8px;
        color: var(--nav-menu-icon-color);
        cursor: pointer;
    }

        header .nav-menu-icon::before {
            content: "\f0c9";
        }

    /*
		Collapsed by default: only the magnifying glass shows. Clicking it expands the field.
		The input is always in the DOM (so its value survives the transition) and is animated
		via width/opacity rather than display, which cannot be transitioned.
	*/
    header .search {
        background: var(--background-color);
        border-radius: 20px;
        position: relative;
        margin-left: 2vw;
        padding: 8px 12px;
        display: flex;
        align-content: space-between;
        align-items: center;
        gap: 0;
        cursor: pointer;
        transition: background 200ms ease-in-out;
    }

        header .search:not(.active):hover {
            background: var(--color-4);
        }

        header .search input[type='text'] {
            background: none;
            border: none;
            color: var(--color-dark);
            padding: 0;
            font-size: 1rem;
            height: 1.4rem;
            line-height: 1.4rem;
            width: 0;
            opacity: 0;
            min-width: 0;
            transition: width 250ms ease-in-out, opacity 200ms ease-in-out, margin-left 250ms ease-in-out;
        }

        header .search.active {
            cursor: default;
        }

            header .search.active input[type='text'] {
                width: 220px;
                opacity: 1;
                margin-left: 10px;
            }

        header .search input[type='text']:focus {
            outline: none;
        }

        header .search a {
            text-decoration: none;
            display: flex;
            align-items: center;
            position: relative;
        }

            /*
				The glyph itself is only ~1rem, which makes the collapsed pill fiddly to hit.
				A transparent overlay enlarges the clickable zone (and covers the pill padding)
				without affecting layout or the rendered icon size.
			*/
            header .search a::after {
                content: "";
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                width: 40px;
                height: 40px;
            }

        /* Once open, the overlay must not sit on top of the input/typing area. */
        header .search.active a::after {
            display: none;
        }

        header .search a::before {
            font: 400 1rem/1rem var(--font-icon);
            content: "\f002";
            color: var(--color-gray);
            transition: color 200ms ease-in-out;
        }

        header .search:hover a::before,
        header .search.active a::before {
            color: var(--color-dark);
        }

    header .dash-filter {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 10px;
    }

        header .dash-filter .site-select select {
            padding: 8px 12px;
            background: var(--background-color);
            border-radius: 20px;
            border: none;
            cursor: pointer;
            font-size: 1.1rem;
            line-height: 1.1rem;
            font-weight: 500;
        }

        header .dash-filter .date-input {
            padding: 8px 12px;
            background: var(--background-color);
            border-radius: 20px;
            cursor: pointer;
            display: flex;
            align-items: center;
        }

            header .dash-filter .date-input i {
                margin: 0 8px;
                font-size: 1.2rem;
            }

            header .dash-filter .date-input input {
                background: none;
                border: none;
                padding: 0 !important;
                margin: 0 !important;
                cursor: pointer;
                font-size: 1.1rem;
                line-height: 1.1rem;
                font-weight: 500;
            }

    /*
		Sits at the end of the header flex row rather than being absolutely positioned, so the
		cluster can grow without overlapping the search box.
		.dash-filter stays absolute because it must centre on the header, not on free space.
	*/
    header .user {
        margin-left: auto;
        margin-right: 2vw;
        display: flex;
        align-items: center;
        gap: 8px;
        height: 33px;
    }

        /*
			The avatar is the whole trigger now that the name is gone; the identity is conveyed
			by the picture, with the name moved to the tooltip.
		*/
        header .user .user-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 33px;
            height: 33px;
            flex: 0 0 33px;
            text-decoration: none;
            cursor: pointer;
            background: var(--background-color);
            border-radius: 50%;
        }

            /*
				.tooltip::after appends a question-mark glyph, which is right for help text but
				not for an icon button. These toggles only borrow .tooltip for its hover bubble.
			*/
            header .user .user-toggle::after,
            header .user .recent-menu-toggle::after {
                content: none;
                color: var(--color-darker);
            }

            header .user .user-toggle img {
                /* Explicit box: the source image is 100x100, so percentage height let it render full size. */
                width: 33px;
                height: 33px;
                border-radius: 50%;
                object-fit: cover;
                display: block;
            }

            /*
                Fallback icon state (no uploaded picture): the .thumb div is the same class used by the
                guest/contact and staff list rows, sized to fill the fixed 33px toggle button.
            */
            header .user .user-toggle .thumb {
                width: 100%;
                height: 100%;
                background: none;
            }

                header .user .user-toggle .thumb i {
                    font-size: 1rem !important;
                    line-height: 1rem !important;
                    color: var(--color-darker);
                }

        header .user .menu {
            position: relative;
            display: flex;
            align-items: center;
            cursor: pointer;
        }

        header .user ul {
            list-style: none;
            margin: 0;
            position: absolute;
            top: 41px;
            /* Anchored to the right edge so the panel never overflows the viewport. */
            right: 0;
            min-width: 150px;
            white-space: nowrap;
            background: var(--color-lightest);
            border-radius: 10px;
            box-shadow: var(--shadow-very-far);
            opacity: 0;
            visibility: hidden;
            z-index: 10;
            padding: 6px 0 6px 0;
        }

            header .user ul li {
            }

                header .user ul li a {
                    display: block;
                    padding: 6px 14px;
                    font-size: 1rem;
                    line-height: 1rem;
                    text-decoration: none;
                    color: var(--sub-text-color);
                    transition: background 150ms ease-in-out, color 150ms ease-in-out;
                }

                    header .user ul li a:hover {
                        background: var(--color-4);
                        color: var(--text-color);
                    }

        header .user .menu.active ul {
            visibility: visible;
            opacity: 1;
            transition: all 200ms;
        }
