/**
 * Shared, reusable component vocabulary -- see dfusionfw/docs/css-conventions.md
 * §3/§4. A class with no page/feature prefix is shared vocabulary and
 * belongs here, not in a page-specific stylesheet.
 */
@layer components {
    /* --- Card --- */
    .card {
        background-color: var(--surface-colour);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-l);
        padding: var(--spacing-s5);
    }

    /* Stacked cards need air between them, and nothing owned that gap: the
       card owns its PADDING (and the /dev note rightly says not to wrap one in
       a spacing utility), while .page-body is a plain block, so two cards in a
       row touched.

       Adjacent-sibling rather than a blanket margin or a flex gap on the
       container, because several things that sit beside a card already space
       themselves -- .result-count carries margin-bottom, .page-flash carries
       its own margins -- and a container gap would add to theirs rather than
       replace it. This way a lone card, and a card following something that
       already spaces itself, are both left exactly as they were.

       s5 matches the card's own padding, so the rhythm inside and between
       cards is the same measure. */
    .card + .card {
        margin-block-start: var(--spacing-s5);
    }

    /* A second form after a first one's toolbar -- the settings below the
       feature grid on /admin/features -- is in another parent, so the rule
       above cannot see the two cards. */
    .form-after {
        margin-block-start: var(--spacing-s8);
    }

    /* --- Card pair ---
       Two cards side by side on a desktop, stacked on anything narrower.
       /enquiry/N was the first page to want it (4.6.1): what arrived and what
       we know about them are both evidence for the same decision, and stacked
       one above the other at 1440px the second was a scroll away from the
       first while half the screen sat empty beside them.

       Two equal columns. It was 3fr/2fr, the wider card first as the one
       being read, until /deal took the grid for two columns of several cards
       each and neither side was reference to the other; the enquiry page
       followed. Equal height by default (the grid stretches),
       which is what makes two cards read as a pair rather than as two cards
       that happen to be near each other.

       It takes over the spacing `.card + .card` would have given: inside the
       pair the gap owns it, and outside it the pair is spaced like a card. */
    .card-pair {
        display: grid;
        gap: var(--spacing-s5);
        grid-template-columns: minmax(0, 1fr);
    }

    .card-pair > .card + .card {
        margin-block-start: 0;
    }

    .card + .card-pair,
    .card-pair + .card,
    .card-pair + .card-pair {
        margin-block-start: var(--spacing-s5);
    }

    @media (min-width: 1024px) {
        .card-pair {
            grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        }
    }

    /* --- Card section ---
       One of several like things inside a single card, divided by a rule: the
       enquiries on /deal, each with its own yachts, message and journey.
       `.card + .card`'s idiom -- adjacent-sibling, so a lone section gets no
       stray rule and the card needs no :first-child exception. A card holding
       ONE thing needs none of this. */
    .card-section + .card-section {
        margin-block-start: var(--spacing-s5);
        padding-block-start: var(--spacing-s5);
        border-block-start: 1px solid var(--border-colour);
    }

    /* A journey inside a section follows the message; give it the air a
       heading would have. */
    .card-section > .field-group-title {
        margin-block-start: var(--spacing-s5);
    }

    .card-heading {
        font-size: var(--font-size-m);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-regular);
        margin-bottom: var(--spacing-s2);
    }

    /* A card's heading with an action at its trailing edge -- "The brief"
       and its Edit button. The same shape `.page-band-row` gives a page title
       and `+ Lead`, one level down. The heading keeps its own margin, so the
       row carries none. */
    .card-heading-row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--spacing-s3);
    }

    /* --- Portal mark ---
       YachtCharterFleet's favicon before its name, sized to the text it sits
       in (includes/portal-name.twig). Its colours are the portal's own. */
    .portal-mark {
        display: inline-block;
        width: 1em;
        height: 1em;
        margin-inline-end: 0.25em;
        border-radius: 2px;
        vertical-align: -0.125em;
    }

    /* --- Badge ---
       Variants are named for their TONE, never for what they mean: a
       template decides that "Primary" or "Owner" is `brand`, and
       /dev/components.htm keeps the table of which meaning takes which tone,
       so the next screen does not pick a different green for the same idea.
       (They were charterhub's proposal states -- draft, sent, viewed... --
       until 2026-09-30, which is how WhatsApp came to be `badge-viewed`.)
       The bare `.badge` is the soft neutral chip; `neutral` is its solid. */
    .badge {
        display: inline-flex;
        align-items: center;
        padding: 2px var(--spacing-s2);
        border-radius: var(--radius-s);
        background-color: var(--status-neutral-surface);
        color: var(--status-neutral-text);
        font-size: var(--font-size-2xs);
        font-weight: var(--font-weight-semibold);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        line-height: 1.45;
        white-space: nowrap;
    }

    .badge-neutral {
        background-color: var(--status-neutral-solid);
        color: var(--status-neutral-on-solid);
    }

    .badge-brand {
        background-color: var(--surface-colour-brand);
        color: var(--text-colour-white);
    }

    .badge-warning {
        background-color: var(--status-warning-solid);
        color: var(--status-warning-on-solid);
    }

    .badge-success {
        background-color: var(--status-success-solid);
        color: var(--status-success-on-solid);
    }

    .badge-muted {
        background-color: var(--status-neutral-solid-muted);
        color: var(--status-neutral-on-solid);
    }

    /* The error solid rather than a new token: an overdue or high-priority
       task IS the product telling the broker something went wrong, and the
       two should look like one voice. */
    .badge-danger {
        background-color: var(--status-error-solid);
        color: var(--status-error-on-solid);
    }

    /* --- Button --- */
    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-s2);
        border-radius: var(--radius-m);
        border: 1px solid transparent;
        font-weight: var(--font-weight-medium);
        white-space: nowrap;
        text-decoration: none;
        cursor: pointer;
        transition: background-color var(--transition-duration) var(--transition-timing),
                    border-color var(--transition-duration) var(--transition-timing),
                    color var(--transition-duration) var(--transition-timing);
    }

    /* The prototype forced every icon inside a button to 16px
       (`[&_svg]:size-4`); worth keeping, so a caller cannot get it wrong. */
    .btn svg {
        flex: none;
        width: 16px;
        height: 16px;
    }

    .btn:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    /* A visually-disabled button must always be paired with the real
       `disabled` attribute on the element -- a click handler still fires
       on a class-only fake, so the guard belongs in markup, not here. */
    .btn.disabled,
    .btn[disabled] {
        cursor: not-allowed;
        opacity: 0.5;
    }

    /* Sizes */
    .btn-m {
        height: 36px;
        padding-inline: var(--spacing-s4);
        font-size: var(--font-size-r);
    }

    .btn-s {
        height: 32px;
        padding-inline: var(--spacing-s3);
        font-size: var(--font-size-xs);
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    /* Variants */
    /* Three variants, not the prototype's eight -- `primary` was an exact
       duplicate of `default` and `ghost` of `outline` (C-03). */
    .btn-solid {
        background-color: var(--surface-colour-brand);
        border-color: var(--border-colour-brand);
        color: var(--text-colour-white);
    }

    .btn-solid:hover {
        background-color: var(--surface-colour-brand-hover);
        border-color: var(--border-colour-brand-hover);
    }

    .btn-solid[disabled] {
        background-color: var(--surface-colour-brand-disabled);
        border-color: var(--border-colour-brand-disabled);
        opacity: 1;
    }

    .btn-outline {
        background-color: var(--surface-colour);
        border-color: var(--border-colour);
        color: var(--text-colour-control);
    }

    .btn-outline:hover {
        background-color: var(--surface-colour-sunken);
    }

    /* Filled, not the prototype's white-on-white outline. Both buttons in its
       delete dialog were outlines differing only in border and text colour, so
       the destructive one read no heavier than Cancel -- focus defaulting to
       Cancel mitigated it but did not fix it (E-10). White on error-600 is
       4.8:1, which clears AA for body text. */

    .btn-danger {
        background-color: var(--status-error-solid);
        border-color: var(--status-error-solid);
        color: var(--status-error-on-solid);
    }

    .btn-danger:hover {
        background-color: var(--status-error-solid-hover);
        border-color: var(--status-error-solid-hover);
    }

    /* The quiet destructive: a row-level action that should be findable but
       not shout. `btn-danger` is for the deliberate confirm at the end of a
       flow -- eight filled red buttons down a page of day cards is the same
       mistake as E-10 made, pointing the other way. */

    .btn-danger-soft {
        background-color: var(--status-error-surface);
        border-color: transparent;
        color: var(--status-error-text);
    }

    .btn-danger-soft:hover {
        background-color: var(--status-error-surface-strong);
    }

    /* --- Field (plain, non-form-library requests) --- */
    .field {
        display: block;
        margin-bottom: var(--spacing-s3);
    }

    .field-label {
        display: block;
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-light);
        margin-bottom: var(--spacing-s1);
    }

    /* ONE input, not the prototype's two. It shipped a shadcn `<Input>` and a
       bespoke `.field` side by side in the same form card, differing in height,
       radius, border colour, placeholder colour, focus treatment and transition
       duration (C-02, C-07). This is the shadcn geometry, which won on merit. */
    .field-input {
        display: block;
        width: 100%;
        height: 40px;
        padding: 0 var(--spacing-s3);
        font-size: var(--font-size-r);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        color: var(--text-colour-regular);
        transition: border-color var(--transition-duration) var(--transition-timing),
                    box-shadow var(--transition-duration) var(--transition-timing);
    }

    .field-input::placeholder {
        color: var(--text-colour-faint);
    }

    /* :focus-visible throughout, so a mouse click does not draw a ring --
       the prototype used :focus here and :focus-visible on its other input
       system, giving two different behaviours (C-07). */
    .field-input:focus-visible {
        outline: none;
        border-color: var(--border-colour-brand);
        box-shadow: var(--focus-ring);
    }

    select.field-input {
        padding-inline-end: var(--spacing-s8);
        appearance: none;
        background-image: var(--field-select-arrow);
        background-repeat: no-repeat;
        background-position: right var(--spacing-s3) center;
        background-size: 16px;
        cursor: pointer;
    }

    .field-control {
        position: relative;
    }

    /* A short chip inside the field's trailing edge -- the country code on a
       resolved port, for instance. The prototype used an emoji flag, which
       renders as a flag on macOS/Windows and as the bare letters on Linux
       (F1-07); the letters are the reliable half, so that is what this shows. */
    .field-adornment {
        position: absolute;
        inset-inline-end: var(--spacing-s2);
        top: 50%;
        transform: translateY(-50%);
        padding: 2px var(--spacing-s1);
        border-radius: var(--radius-s);
        background-color: var(--surface-colour-raised);
        color: var(--text-colour-light);
        font-size: var(--font-size-2xs);
        font-weight: var(--font-weight-semibold);
        letter-spacing: 0.04em;
        pointer-events: none;
    }

    .field-control:has(.field-adornment) .field-input {
        padding-inline-end: var(--spacing-s8);
    }

    .field-hint {
        display: block;
        margin-bottom: var(--spacing-s1);
        color: var(--text-colour-faint);
        font-size: var(--font-size-xs);
    }

    .field-label-note {
        margin-inline-start: var(--spacing-s1);
        color: var(--text-colour-faint);
        font-weight: var(--font-weight-regular);
    }

    .field-error-list {
        margin: var(--spacing-s1) 0 0;
        padding: 0;
        list-style: none;
    }

    .field-has-error .field-input {
        border-color: var(--status-error-accent);
    }

    .field-preview {
        color: var(--text-colour-regular);
    }

    .field-textarea {
        height: auto;
        min-height: 90px;
        padding-block: var(--spacing-s2);
        line-height: var(--line-height-regular);
        resize: vertical;
    }

    .field-error {
        color: var(--status-error-accent);
        font-size: var(--font-size-s);
        margin-bottom: var(--spacing-s3);
    }

    .field-checkbox {
        display: flex;
        align-items: center;
        gap: var(--spacing-s2);
        font-size: var(--font-size-r);
        color: var(--text-colour-regular);
        margin-bottom: var(--spacing-s3);
        cursor: pointer;
    }

    /*
        Two fixed columns rather than auto-fit. Auto-fit collapses to one
        column whenever the container is narrow -- a detail pane, a modal --
        which is exactly where a two-column form was asked for, so the
        breakpoint keys off the viewport instead.

        Shared vocabulary, so it lives here: a class used by more than one
        page and defined in one page's own stylesheet silently does nothing
        on all the others (css-conventions.md §3).
    */
    .field-grid {
        display: grid;
        gap: var(--spacing-s5);
        grid-template-columns: 1fr;
    }

    @media (min-width: 641px) {
        .field-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    /* A heading inside a form card, dividing one long form into named parts. */
    .field-group-title {
        margin: var(--spacing-s6) 0 var(--spacing-s4);
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-semibold);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-colour-light);
    }


    /* `.field-checkbox` above got its first real user in 4.1.3
       (includes/form/checkbox.twig). Two additions it needed:

       `accent-color` tints the native box, so the tick stays the platform's
       own -- a hand-drawn checkbox is a well-known way to lose the
       indeterminate state, the focus ring and Windows high-contrast mode all
       at once.

       `.field-checkbox-grid` lays a SET of them out, which is the only reason
       this project has checkboxes at all. `auto-fill` rather than a fixed
       column count, so five labels are two columns on a desktop and one on a
       phone with no media query. */
    .field-checkbox input[type="checkbox"] {
        flex: none;
        width: 16px;
        height: 16px;
        margin: 0;
        accent-color: var(--surface-colour-brand);
    }

    .field-checkbox-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 0 var(--spacing-s3);
    }

    /* The wrapper's bottom margin is what separates one field from the next in
       a stacked form, and it is wrong inside a grid that already has a gap. */
    .field-checkbox-grid .field {
        margin: 0;
    }

    .field-checkbox-grid .field-checkbox {
        margin-bottom: var(--spacing-s2);
    }

    /* --- Data table --- */
    .table-scroll {
        overflow-x: auto;
    }

    .data-table {
        width: 100%;
        border-collapse: collapse;
        font-size: var(--font-size-r);
    }

    .data-table th {
        text-align: left;
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-light);
        padding: var(--spacing-s2) var(--spacing-s3);
        border-bottom: 1px solid var(--border-colour);
        white-space: nowrap;
    }

    .data-table td {
        padding: var(--spacing-s2) var(--spacing-s3);
        border-bottom: 1px solid var(--border-colour);
        color: var(--text-colour-regular);
        vertical-align: middle;
    }

    .data-table tbody tr:last-child td {
        border-bottom: none;
    }

    /* A table of facts about ONE record -- `<th scope="row">` down the side,
       the value beside it -- is not a list, and must not scroll like one. An
       unbreakable value (an email address, a URL) would otherwise widen the
       table past a phone's viewport and put EVERY value on the card behind
       `.table-scroll`'s horizontal scroll, which the 390px render of the
       inbox showed. `anywhere` breaks only when the alternative is overflow,
       so prose is untouched. Scoped by shape rather than by a class so the
       five facts tables (enquiry, enquiries, deal, contact, company) agree
       without each remembering to opt in; list tables have no row headers
       and keep their scroll. */
    .data-table th[scope="row"] + td {
        overflow-wrap: anywhere;
    }


    /* --- Label chip ---
       Roadmap 4.1.3. The house's own vocabulary (`public.label`) and the fixed
       lead temperature (`public.lead_temperature`) render through one class,
       because they sit side by side on a row and two chip styles would imply a
       distinction the reader does not need to make.

       NOT a `.badge`. A badge in this system is a STATE the product computed --
       Lost, Closed, Private -- and is upper-cased and abbreviated to say so. A
       label is something a person wrote, so it keeps its own capitalisation and
       its own words: a house that names a label `Awaiting client` must not see
       it shouted back as `AWAITING CLIENT`.

       The colour is chosen per label and stored as a NAME (`grey`, `blue`,
       `green`, `amber`, `red`) in the database -- never a hex. Everything
       resolves from tokens.css here, so re-theming the app re-themes the
       labels, and docs/theming.md's register of literal colours does not grow.
       The five are the ramps tokens.css already has; a sixth means a new
       primitive, a new swatch on /dev/tokens.htm and a line in that register.

       A dot rather than a filled chip: five saturated fills on one table row is
       a fruit salad, and it puts coloured text on coloured ground five ways
       when only one of the five was contrast-checked. The dot carries the
       colour, the text stays on the surface, and the chip still reads at a
       glance. */
    .label-chip {
        display: inline-flex;
        align-items: center;
        gap: var(--spacing-s1);
        max-width: 14em;
        padding: 1px var(--spacing-s2);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-s);
        background-color: var(--surface-colour);
        color: var(--text-colour-regular);
        font-size: var(--font-size-2xs);
        font-weight: var(--font-weight-medium);
        line-height: 1.6;
        white-space: nowrap;
    }

    /* The name is what overflows, not the dot. */
    .label-chip-name {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .label-chip::before {
        content: "";
        flex: none;
        width: 8px;
        height: 8px;
        border-radius: var(--radius-pill);
        /* Overridden by every variant below. A label whose colour is somehow
           not one of the five still renders as a chip with a neutral dot,
           rather than as a chip with a hole in it. */
        background-color: var(--status-neutral-solid-muted);
    }

    .label-chip--grey::before  { background-color: var(--status-neutral-solid-muted); }
    .label-chip--blue::before  { background-color: var(--surface-colour-brand); }
    .label-chip--green::before { background-color: var(--status-success-solid); }
    .label-chip--amber::before { background-color: var(--status-warning-solid); }
    .label-chip--red::before   { background-color: var(--status-error-solid); }

    /* The secondary line in a table cell -- the client under the lead's title.
       One cell rather than two columns, because they are one answer to one
       question (whose lead is this) and a second column made the leads table
       wide enough to scroll on a phone for no gain. */
    .row-sub {
        margin-top: 2px;
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    /* Several chips in a table cell. `flex-wrap` rather than a nowrap row,
       because a lead with four labels in a narrow column should get taller
       rather than push the columns beside it off a phone. */
    .label-chip-list {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-s1);
    }

    /* --- Clickable row ---
       THE RULE, not one screen's style: any table row that stands for a record
       the product has a page for links the WHOLE ROW rather than the title, and
       carries a kebab whose first item is View. /leads (4.1.4), the
       pipeline screens (4.1.8), /contacts, /companies and the People
       and Deals cards on /contact and /company (4.1.9).
       /dev/components.htm states it in full, including the two shapes it
       deliberately does not cover -- a table of facts about one record, and a
       row naming something with no page to link to.

       It is a real `<a>` with a stretched ::after, NOT a click handler on the
       `<tr>`. The anchor keeps the row keyboard-reachable, keeps the URL in the
       status bar on hover, keeps middle-click and ctrl-click opening a tab, and
       keeps the row announced as one link -- none of which a JS row handler
       gives you, and all of which a broker on a laptop will notice missing.

       `position: relative` on the cell, not on the row: a `<tr>` is not a
       reliable containing block for absolute positioning, which is the trap
       this pattern usually falls into.

       The overlay sits at z-index 0 so anything in the row that raises itself
       above it -- the kebab menu below -- stays clickable. */
    .row-link-cell {
        position: static;
    }

    .row-link {
        color: inherit;
        text-decoration: none;
    }

    .row-link::after {
        content: "";
        position: absolute;
        inset: 0;
        z-index: 0;
    }

    /* The containing block for the overlay above. Every cell of the row is
       covered because the row itself establishes it. */
    .data-table tbody tr:has(.row-link) {
        position: relative;
    }

    .data-table tbody tr:has(.row-link):hover {
        background-color: var(--surface-colour-sunken);
    }

    /* The row is a link, so it gets the focus ring the link would have had.
       `:focus-within` and not `:focus`, because the focus is on the anchor
       inside the cell. */
    .data-table tbody tr:has(.row-link:focus-visible) {
        box-shadow: var(--focus-ring);
        border-radius: var(--radius-s);
    }

    /* Anything interactive inside a linked row has to out-rank the overlay, or
       the row swallows it. The menu also needs its own stacking context so the
       open list is not clipped under the next row. */
    .data-table tbody tr:has(.row-link) .menu {
        position: relative;
        z-index: 1;
    }

    /* --- Pinned row actions ---
       The kebab column is STICKY to the trailing edge, and that is not polish.
       `deal-rows.twig` has warned since 3.7 that a trailing column on a phone
       sits behind `.table-scroll`'s horizontal scroll -- which is why the state
       badges were moved inline with the title. A row's actions cannot be moved
       inline, so they are pinned instead: at 390px the leads table scrolls and
       the menu stays where it is.

       It needs its own background, or the scrolling cells pass underneath it,
       and the hover colour has to be repeated here for the same reason. The
       `z-index` puts it above the stretched link overlay as well as above the
       cells it covers -- without it the row swallows the click it exists to
       receive. */
    .data-table .row-actions-cell {
        position: sticky;
        inset-inline-end: 0;
        z-index: 2;
        width: 1%;
        background-color: var(--surface-colour);
    }

    .data-table tbody tr:hover .row-actions-cell {
        background-color: var(--surface-colour-sunken);
    }

    /* The header cell is empty, so it needs the same treatment or the column
       heading beside it scrolls into the gap above the pinned kebabs. */
    .data-table thead .row-actions-cell {
        background-color: var(--surface-colour);
    }

    /* --- Search field (input with a leading icon and a clear button) --- */
    .search-field {
        position: relative;
        display: flex;
        align-items: center;
        flex: 1 1 220px;
        min-width: 0;
        max-width: 420px;
    }

    .search-field .field-input {
        padding-inline: var(--spacing-s8);
    }

    .search-field-icon {
        position: absolute;
        inset-inline-start: var(--spacing-s3);
        display: grid;
        place-items: center;
        color: var(--text-colour-faint);
        pointer-events: none;
    }

    .search-field-clear {
        position: absolute;
        inset-inline-end: var(--spacing-s2);
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px;
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-faint);
        cursor: pointer;
    }

    .search-field-clear:hover {
        background-color: var(--surface-colour-raised);
        color: var(--text-colour-regular);
    }

    .search-field-spinner {
        position: absolute;
        inset-inline-end: var(--spacing-s3);
        width: 16px;
        height: 16px;
        border: 2px solid var(--border-colour-strong);
        border-top-color: var(--border-colour-brand);
        border-radius: var(--radius-pill);
        animation: spin 0.6s linear infinite;
    }

    @keyframes spin {
        to { transform: rotate(360deg); }
    }

    @media (prefers-reduced-motion: reduce) {
        .search-field-spinner {
            animation-duration: 2s;
        }
    }

    /* --- Toolbar --- */
    .toolbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--spacing-s3);
    }

    .toolbar-end {
        margin-inline-start: auto;
    }

    /* --- Segmented control --- */
    .segmented {
        display: inline-flex;
        gap: 2px;
        padding: 2px;
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour-sunken);
    }

    .segmented-option {
        display: grid;
        place-items: center;
        width: 32px;
        height: 30px;
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-faint);
        cursor: pointer;
    }

    .segmented-option:hover {
        color: var(--text-colour-regular);
    }

    .segmented-option.is-active {
        background-color: var(--surface-colour);
        color: var(--text-colour-brand);
        box-shadow: var(--elevation-1);
    }

    /* --- Owner, and the transfer flyout ---
       The owning broker at the top right of /deal's page band, copied from
       Pipedrive -- docs/research/pipedrive/screenshots/02-deal-detail-top.jpg.
       Name over the word Owner, and on a deal that can still be transferred it
       is the control that opens the flyout.

       The panel itself is `.flyout` / `.flyout-popover` above -- shared with
       /deal's label picker. What is left here is the FACE: the name over
       the word Owner, and the surface it sits on. */
    .owner {
        flex: none;
        /* .page-band-row wraps, and a wrapped line puts its one item at the
           start -- so the owner would slide under the title and sit on the
           left. `auto` keeps it against the right edge on its own line as well
           as beside the title. */
        margin-inline-start: auto;
    }

    .owner-face {
        display: flex;
        align-items: center;
        gap: var(--spacing-s2);
        padding: var(--spacing-s1) var(--spacing-s2);
        border: 1px solid transparent;
        border-radius: var(--radius-m);
        background: transparent;
        text-align: end;
    }

    /* The name over the word Owner; the chevron sits beside the pair rather
       than beside either line. */
    .owner-identity {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 1px;
    }

    /* Only the version that opens something gets a surface of its own. The
       page band is white, so a transparent control on it is indistinguishable
       from a label -- which is exactly what the non-interactive version IS,
       and why it keeps the transparent background. An affordance on a control
       that cannot be opened is the same lie as a class-only disabled button. */
    .owner-actionable .owner-face {
        border-color: var(--border-colour);
        background-color: var(--surface-colour-raised);
        cursor: pointer;
        transition: background-color var(--transition-duration) var(--transition-timing),
                    border-color var(--transition-duration) var(--transition-timing);
    }

    .owner-actionable .owner-face:hover,
    /* Open reads as pressed, so the control does not appear to have sprung
       back while its panel is still on screen. */
    .owner-actionable .owner-face[aria-expanded="true"] {
        border-color: var(--border-colour-strong);
        background-color: var(--color-ui-200);
    }

    .owner-face:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    .owner-face svg {
        flex: none;
        color: var(--text-colour-faint);
        transition: transform var(--transition-duration) var(--transition-timing);
    }

    .owner-face[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }

    .owner-name {
        color: var(--text-colour-regular);
        font-size: var(--font-size-r);
        font-weight: var(--font-weight-semibold);
        white-space: nowrap;
    }

    /* The label under the name, not the person's job title. It stays even when
       nobody owns the deal, because "Unassigned" on its own does not say what
       the empty slot is for. */
    .owner-role {
        color: var(--text-colour-light);
        font-size: var(--font-size-xs);
    }

    /* --- Flyout ---
       A small panel holding a FORM, hung off the control that opens it. The
       owner transfer above is one; /deal's label picker is the other, and
       the second one is why this is shared vocabulary rather than two copies.

       Not a .menu, and the distinction is behavioural rather than visual.
       `.menu` portals its list to <body> and positions it in viewport
       coordinates because a row menu lives inside .table-scroll and would
       otherwise be clipped -- and RecordMenus closes on any click that is not
       a trigger, which a form containing a select, a filter box and two
       buttons could never survive. A flyout hangs off a control with nothing
       scrolling between it and the viewport, so an ordinary
       absolutely-positioned child is both correct and simpler, and it closes
       only on a click OUTSIDE itself. Two idioms because there are genuinely
       two cases; `Flyout` in common.js is the JavaScript half.

       In the FLOW by default, and floating only once JavaScript has taken over
       -- `.flyout-enhanced` is added by Flyout on construction. That is the
       no-JS story and it is why the rule is split: the page ships the panel
       open and the module closes it, so with JavaScript off the form is still
       there and still works. A permanently-open ABSOLUTE panel would sit over
       whatever is under it forever and read as a broken page rather than a
       deliberate fallback; in the flow it simply makes its container taller,
       which is what an open form should do. */
    .flyout {
        position: relative;
    }

    /* Capped rather than fixed, so it cannot hang off the side of a narrow
       phone: it is aligned to one page gutter, so the other is all it has to
       spare. */
    .flyout-popover {
        width: min(var(--flyout-width, 280px), calc(100vw - 2 * var(--gutter-page)));
        margin-block-start: var(--spacing-s1);
        padding: var(--spacing-s4);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        box-shadow: var(--elevation-3);
    }

    .flyout-enhanced .flyout-popover {
        position: absolute;
        /* Above the sidebar (40) and the header (50), below the toasts (60) --
           the values .menu-list reasons out, copied rather than re-picked. */
        z-index: 55;
        inset-block-start: calc(100% + var(--spacing-s1));
        inset-inline-start: 0;
        margin-block-start: 0;
    }

    /* Anchored to the trigger's trailing edge instead, for a trigger that sits
       against the page's own trailing gutter -- the owner, top right. Aligned
       to the start there, it would open off the side of the page. */
    .flyout-enhanced .flyout-popover--end {
        inset-inline-start: auto;
        inset-inline-end: 0;
    }

    .flyout-popover-title {
        margin-bottom: var(--spacing-s3);
        color: var(--text-colour-regular);
        font-size: var(--font-size-r);
        font-weight: var(--font-weight-semibold);
    }

    /* Cancel then Save, reading order matching .confirm-actions: the
       destructive-or-committing button is last and is not the one focus lands
       on. */
    .flyout-popover-actions {
        display: flex;
        justify-content: flex-end;
        gap: var(--spacing-s2);
    }

    /* --- Filter flyout ---
       The two filters across the top of a pipeline screen -- roadmap 4.1.8.
       Status (Open · Lost · Closed · All) and Broker (Everyone · Mine).

       They were two rows of `.btn btn-s` -- four for the status and one toggle
       for the owner -- which made five controls, all the same size and shape,
       none of them saying which question it answered. A flyout says the
       question on the trigger and the answer beside it, and costs one line
       when closed.

       The trigger is a real `.btn btn-s btn-outline` with nothing repainted;
       what is added is the pair of spans inside it and the chevron. A filter
       whose value is part of its label is not a new kind of control, and a
       toolbar of buttons that are not quite buttons is how a vocabulary
       drifts. */
    /* The two of them, side by side. `.toolbar-end` is only
       `margin-inline-start: auto` -- it pushes a group to the trailing edge and
       says nothing about how the group is laid out, which is right for the
       inline anchors every other toolbar puts in it and not enough for two
       block-level flyout roots. A row of its own rather than making
       `.toolbar-end` a flex container, because that class is also worn by
       `.segmented` and `.menu`, neither of which asked for one. */
    .filter-set {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--spacing-s3);
    }

    .filter-trigger {
        gap: var(--spacing-s2);
    }

    /* The question, in the row's furniture weight -- the same relationship
       `.record-summary-term` has to its value, and the reason both filters can
       sit side by side without a legend above them. */
    .filter-trigger-name {
        color: var(--text-colour-light);
        font-weight: var(--font-weight-regular);
    }

    .filter-trigger-value {
        font-weight: var(--font-weight-semibold);
    }

    .filter-trigger svg {
        flex: none;
        color: var(--text-colour-faint);
        transition: transform var(--transition-duration) var(--transition-timing);
    }

    /* Open reads as pressed, the same way `.owner-face` does, so the control
       does not appear to have sprung back while its panel is still on screen. */
    .filter-trigger[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }

    /* --- Choice list ---
       A list of options inside a flyout, one of which is the current answer.

       Not `.menu-list` / `.menu-item`, and the difference is structural rather
       than visual: that list is `position: fixed` because RecordMenus PORTALS
       it to <body> to escape `.table-scroll`'s clipping. Nothing clips a
       flyout, so its options stay where they are written -- and reusing a
       class whose positioning is owned by another module's JavaScript is how
       two components come to share a bug.

       The options are anchors, because picking one is a navigation. That is
       what makes the filters work with JavaScript off, where the panel is
       simply a list of links sitting under its trigger. */
    .choice-list {
        display: flex;
        flex-direction: column;
        /* reset.css zeroes margins and nothing else, so a <ul> keeps the UA's
           disc marker and 40px of inline padding -- the same reset
           `.menu-list` needed in 4.1.4, and for the same reason. */
        padding-inline: 0;
        list-style: none;
    }

    .choice {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--spacing-s2);
        padding: var(--spacing-s2) var(--spacing-s3);
        margin-inline: calc(var(--spacing-s2) * -1);
        border-radius: var(--radius-s);
        color: var(--text-colour-control);
        font-size: var(--font-size-r);
        text-decoration: none;
    }

    .choice:hover {
        background-color: var(--surface-colour-sunken);
    }

    /* The current answer, marked by weight and a tick rather than by colour
       alone -- `aria-current` carries it for anything not looking at the
       screen, and `::after` is what carries it for anything that is. A
       selected option distinguished only by a background is the one a
       colour-blind reader cannot find. */
    .choice-current {
        color: var(--text-colour-brand);
        font-weight: var(--font-weight-semibold);
    }

    .choice-current::after {
        content: '✓';
        flex: none;
    }

    /* --- Record summary ---
       The block at the top of /deal: one line per fact, each led by an
       icon. Copied from Pipedrive's Summary panel --
       docs/research/pipedrive/screenshots/02-deal-detail-top.jpg.

       It replaced a `.data-table` of label/value pairs, and the reason is the
       reason that table was wrong rather than a preference for icons. A
       two-column table gives half its width to five words that never change,
       and on a phone `.table-scroll` then put the VALUES behind a horizontal
       scroll -- the trap this project has hit twice before. A `<dl>` with a
       16px term column gives the whole line to the answer at every width.

       The icon is the only visible term, so every item carries an `.sr-only`
       name beside it and a `title` for a mouse. An icon nobody can name is a
       decoration; these have to be readable by everything. */
    .record-summary {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s3);
        /* Capped, although the card is not. Pipedrive's summary is a narrow
           left column and ours is a full-width card, so without this a
           three-word answer sits alone on a 1500px line -- and the Labels row
           is a CONTROL, whose hit area would then be the whole page wide for
           the sake of three chips. A measure, in other words, for the same
           reason prose gets one. */
        max-width: 36rem;
    }

    .record-summary-item {
        display: flex;
        align-items: baseline;
        gap: var(--spacing-s3);
        font-size: var(--font-size-r);
        /* The quick-edit band, on every item whether or not it is editable, so
           the icon column and the values stay on the same two vertical lines.
           The negative margin puts the content box back exactly where it was,
           so this changed nothing on screen; only `.quick-edit` below ever
           paints the background it makes room for. */
        padding: 2px var(--spacing-s2);
        margin-inline: calc(var(--spacing-s2) * -1);
        border-radius: var(--radius-s);
    }

    /* Faint, because it is the row's furniture and not its content -- the
       same weight relationship a table header has to its cell. `flex: none` so
       every value starts on the same vertical line however long it is. */
    .record-summary-term {
        flex: none;
        width: 16px;
        color: var(--text-colour-faint);
    }

    /* The icon is vertically centred against the first line of the value
       rather than sitting on its baseline, where a 16px box hangs low. */
    .record-summary-term svg {
        display: block;
        transform: translateY(2px);
    }

    /* Takes the rest of the row, rather than shrinking to its own content.
       That is what lets the Labels row's chips wrap at the measure above
       instead of at whatever width a nested wrapping flex container reports as
       its max-content -- which is the largest single chip, not the row of
       them. `min-width: 0` so a long client name wraps inside the row instead
       of widening it; `<dd>` carries a browser default margin. */
    .record-summary-value {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        color: var(--text-colour-regular);
    }

    /* A second, faint line under a value: the raw evidence behind a readable
       one. The enquiry's Network row reads `spectrum.com` and this line keeps
       the IP and the full host beneath it, because the rewritten value is for
       reading and the original is for checking. Wraps anywhere, because a
       reverse-DNS name is one unbreakable word otherwise. */
    .record-summary-detail {
        display: block;
        font-size: var(--font-size-s);
        color: var(--text-colour-light);
        overflow-wrap: anywhere;
    }

    /* The one value that is a control. It is a button rather than a link
       because it opens a panel on this page, and it is styled as text rather
       than as a .btn because it sits in a column of plain facts -- a button
       shape here would say the labels are a different KIND of thing from the
       value above them, which is exactly what Pipedrive gets right. */
    .record-summary-action {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--spacing-s2);
        max-width: 100%;
        padding: 2px var(--spacing-s2);
        margin-inline-start: calc(var(--spacing-s2) * -1);
        border: 1px solid transparent;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-brand);
        font-size: var(--font-size-r);
        text-align: start;
        cursor: pointer;
        transition: background-color var(--transition-duration) var(--transition-timing);
    }

    .record-summary-action:hover,
    .record-summary-action[aria-expanded="true"] {
        background-color: var(--color-ui-100);
    }

    .record-summary-action:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    /* --- Quick edit ---
       A row of facts about one record where each fact can be changed where it
       is read, without leaving the page -- Pipedrive's detail panel, and the
       reason a broker there never opens an "Edit deal" form. /deal's
       Summary block is the first, and `.record-summary` is deliberately not
       the only shape it has to fit: the same mechanism belongs on
       /contact's and /company's fact blocks next.

       NOT "inline edit", and the name is doing work. Nothing is edited in
       line: the row stays a row and a `.flyout` opens beside it holding the
       one field. Calling it inline edit would promise a textbox appearing
       where the value was, which is a different mechanism with a different
       failure mode -- a row that changes height under the pointer, and a value
       that is a control on a page of facts.

       Three parts, and they sit on three elements because the HTML says so:

         .record-summary-item.quick-edit      the band that greys on hover
           dt.record-summary-term             the icon
           dd.record-summary-value            ALSO the flyout root
             .quick-edit-pencil               the trigger, trailing edge
             .flyout-popover                  the panel

       The panel has to live inside the `<dd>`, because a `<div>` inside a
       `<dl>` may hold `<dt>`s and `<dd>`s and nothing else -- so the flyout
       root is the value, while the hover band is the row above it. That split
       is why the reveal rules below are written from `.quick-edit` and not
       from the pencil's own parent. */

    /* The same grey `.record-summary-action` already uses for the Labels row,
       and deliberately so: one "you may change this" colour, whether the
       affordance is the value itself or a pencil at the end of the line.

       `:focus-within` and not only `:hover`, so the band is painted while the
       panel it opened is being used -- a flyout hanging off a row that has
       gone back to looking like plain text reads as belonging to nothing. */
    .quick-edit:hover,
    .quick-edit:focus-within {
        background-color: var(--color-ui-100);
    }

    /* The value takes the rest of the row already; making it a flex row is
       what puts the pencil at the row's trailing edge rather than at the end
       of the text. Scoped to `.quick-edit` -- the Labels row's `<dd>` holds a
       wrapping button and its picker, and has no use for this. */
    .quick-edit .record-summary-value {
        display: flex;
        align-items: baseline;
        gap: var(--spacing-s2);
    }

    .quick-edit-fact {
        min-width: 0;
    }

    .quick-edit-pencil {
        flex: none;
        display: flex;
        align-items: center;
        padding: 2px;
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-faint);
        cursor: pointer;
        /* Nudged the same 2px `.record-summary-term svg` is, so the pencil and
           the fact's own icon sit on one line across the block. */
        transform: translateY(2px);
        transition: opacity var(--transition-duration) var(--transition-timing),
                    color var(--transition-duration) var(--transition-timing);
    }

    .quick-edit-pencil:hover,
    .quick-edit-pencil[aria-expanded="true"] {
        color: var(--text-colour-regular);
    }

    .quick-edit-pencil:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    /* Hidden until the pointer is on the row -- and ONLY where there is a
       pointer. A phone has no hover, so a pencil revealed by it is a pencil
       nobody can reach; there it is simply always on, which is what
       `hover: hover` buys and what a `:hover` rule alone would get wrong on
       every screen the brokers in doc 03 §7 are actually holding.

       `opacity` rather than `display` or `visibility`: both of those take the
       button out of the tab order, and the keyboard route to this mechanism is
       the pencil. It is revealed by `:focus-within` on the row for the same
       reason -- tabbing to an invisible control is how a page appears to have
       swallowed the focus ring. */
    @media (hover: hover) {
        .quick-edit-pencil {
            opacity: 0;
        }

        .quick-edit:hover .quick-edit-pencil,
        .quick-edit:focus-within .quick-edit-pencil {
            opacity: 1;
        }
    }

    /* Every control at the row's trailing edge, in one box: the pencil, and on
       the Client row "+ Participant" before it. `auto` on the start margin
       rather than `space-between` on the row, which would also push a wrapped
       second line of the fact about. */
    .quick-edit-actions {
        flex: none;
        display: flex;
        align-items: center;
        gap: var(--spacing-s2);
        margin-inline-start: auto;
    }

    /* `.flyout` is `position: relative`, which on an inline element gives the
       absolutely-positioned panel an inline box for a containing block -- and
       an inline box that wraps has more than one, so the panel lands
       wherever the first fragment ended. These are flyout roots wrapping one
       control each, so they are made into boxes. */
    .quick-edit-actions > .flyout {
        display: inline-flex;
    }

    /* A named action on a fact row -- "+ Participant" beside the client.
       Styled as text rather than as a `.btn`, for the reason
       `.record-summary-action` is: it sits in a column of plain facts, and a
       button shape here would say the client is a different KIND of thing from
       the value above it.

       It is NOT hidden until hover, unlike the pencil beside it, and that is
       the decision rather than an oversight. A pencil is the generic "change
       this" gesture and one hover teaches it everywhere; this is a named thing
       a broker goes looking for, and since 4.1.13 folded the "Add a contact"
       card away it is the only route to putting somebody on a deal. An
       affordance that is both the only route and invisible is not an
       affordance. */
    .quick-edit-add {
        flex: none;
        padding: 2px var(--spacing-s2);
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-brand);
        font-size: var(--font-size-s);
        white-space: nowrap;
        cursor: pointer;
        transition: background-color var(--transition-duration) var(--transition-timing);
    }

    .quick-edit-add:hover,
    .quick-edit-add[aria-expanded="true"] {
        background-color: var(--color-ui-100);
    }

    .quick-edit-add:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    /* An amount and its currency on one line inside a quick-edit panel.
       Deliberately not `.field-grid`, whose two columns key off the VIEWPORT
       rather than the container -- inside a 300px panel on a 1440px screen it
       would give the amount 140px and the currency the same, which is generous
       to three letters and mean to a number. */
    .quick-edit-pair {
        display: grid;
        grid-template-columns: 1fr 6.5rem;
        gap: var(--spacing-s3);
    }

    /* Anchored to the pencil's own edge, which is the row's trailing edge --
       the same `--end` the owner's transfer panel uses, and for the same
       reason: a panel that opened from the far right of a line and appeared at
       the far left has no visible relationship with the control that opened
       it. */
    .quick-edit-popover {
        --flyout-width: 300px;
    }

    /* --- Label picker ---
       The flyout behind /deal's Labels row. Roadmap 4.1.6.

       Each option is an ordinary `.field-checkbox` whose visible content is
       the `.label-chip` the deal will then show, rather than the field's plain
       text -- so the broker ticks the thing they are about to see, which is
       what Pipedrive's own picker does and what a colourless list of names
       cannot. `includes/form/checkbox.twig` is therefore not used here; the
       field data still comes from the WooForm field, only the presentation
       differs. */
    /* Wider than the owner's 280px: a chip plus a checkbox needs the room, and
       this one is anchored to the page's leading gutter so it has the whole
       card to open into. */
    .label-picker {
        --flyout-width: 320px;
    }

    /* On a phone it goes back INTO the flow. It is anchored to its row's
       leading edge, which is indented by the icon column, so a 320px panel
       floating there runs off the side of a 390px screen -- and capping it
       against the viewport cannot see that indent. In the flow it simply makes
       the card taller, which is exactly what the no-JS fallback already does:
       one behaviour rather than two.

       The owner's panel is not in here, and does not want to be. It is
       `--end`-anchored against the page's own trailing gutter, so its 280px
       already fits at 390px -- and `.owner` is only as wide as the broker's
       name, so putting THAT one in the flow would give it a panel the width of
       a name. The breakpoint is the one .field-grid uses.

       After `.flyout-enhanced .flyout-popover` above, and equal to it in
       specificity: source order is what decides, so this block stays below. */
    @media (max-width: 640px) {
        .flyout-enhanced .label-picker {
            position: static;
            width: auto;
        }
    }

    .label-picker-list {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s1);
        /* Capped and scrolled: a house's set has no editor and no ceiling, and
           a picker taller than the viewport puts Save somewhere unreachable.
           Nothing inside escapes this box, so clipping the other axis -- which
           `overflow-y` forces -- costs nothing here. */
        max-height: 240px;
        overflow-y: auto;
    }

    /* The filter sits ABOVE the form, not in it: an <input> inside a form
       submits it on Enter, and Enter in a box labelled "Filter" must not save
       the deal's labels. It is hidden until JavaScript unhides it, because a
       filter box that filters nothing is a lie rather than a fallback. */
    .label-picker-filter {
        margin-bottom: var(--spacing-s3);
    }

    /* Said out loud rather than shown as an empty box: a filter that matches
       nothing looks identical to a house with no labels. */
    .label-picker-empty {
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    /* --- Stage tabs ---
       The pipeline across the top of /charter and /sales -- roadmap
       4.1.10. They were `.btn btn-s`, solid for the selected one and outline
       for the rest, which made nine buttons of equal weight sitting above a
       card they had no visible relationship with: the strip read as a row of
       actions rather than as "which of these am I looking at".

       FOLDER TABS, attached to the card below. EVERY tab has the tab shape --
       a border and two rounded top corners -- and an unselected one is simply
       a grey one; drawn borderless they were a row of text labels with one box
       among them, which is not a tab bar. The strip overlaps the card's top
       border by 1px and paints above it, so the selected tab -- filled in the
       card's own surface colour, and painting its bottom 1px in that colour
       too -- cuts through the line while the grey ones carry it. That is the
       whole of the effect: the selected tab and the table are one surface, and
       the rest are behind it.

       Not an ARIA tablist, and that is deliberate rather than an omission.
       Each tab is a LINK to `?stage=…` and the page reloads; `role="tab"`
       promises a panel this page swaps in without navigating, and a screen
       reader told to expect that gets something else. `aria-current="page"` in
       a `<nav>` is what a set of links to pages actually is. */
    .stage-tabs {
        display: flex;
        /* NOWRAP is the point, and it is a fix rather than a preference. The
           old strip was a `.toolbar` (which wraps) inside a `.table-scroll`
           (which scrolls), so at 390px it wrapped onto three lines and the
           scroll container never scrolled -- the opposite of what its own
           comment claimed. Nine stages are a SEQUENCE, and a sequence broken
           across three lines stops reading as one; attached to a card, a
           wrapped row also leaves two rows of tabs floating above it. */
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: var(--spacing-s1);
        /* Clear of the card's rounded corner, so the first tab does not sit
           over the curve. */
        padding-inline: var(--spacing-s3);
        /* Over the card's top border, and above it in paint order -- this and
           `position: relative` are what let the selected tab cut the line. */
        margin-block-end: -1px;
        position: relative;
        z-index: 1;

        /* Hidden, not absent: the strip still scrolls by swipe, by keyboard
           (each tab is a link, so Tab scrolls it into view) and by trackpad. A
           classic scrollbar would sit in the 1px seam between the tabs and the
           card and break the join, which is the one thing this component is
           for. The affordance that there is more is the ← / → stage links
           below the card, which pipeline-screen.twig has always carried and
           which App\Deal\PipelineView calls the screen's primary movement. */
        scrollbar-width: none;
    }

    .stage-tabs::-webkit-scrollbar {
        display: none;
    }

    /* Every tab has the tab SHAPE -- a border and two rounded top corners --
       and an unselected one is simply a grey one. They read as a row of tabs
       sitting behind the card with one of them pulled forward, which is the
       thing a tab bar is; drawn borderless they were a row of text labels that
       happened to have one box among them.

       The bottom border is what CONTINUES THE LINE. The strip paints over the
       card's top border along its whole width, so a tab with a background of
       its own would hide that line for its own width -- each one therefore
       carries the 1px itself, and the 4px gaps between them let the card's own
       border show through. The selected tab paints that same 1px in the card's
       surface colour instead, which is how it cuts the line. */
    .stage-tab {
        flex: none;
        display: inline-flex;
        align-items: center;
        gap: var(--spacing-s2);
        padding: var(--spacing-s2) var(--spacing-s3);
        border: 1px solid var(--border-colour);
        border-start-start-radius: var(--radius-m);
        border-start-end-radius: var(--radius-m);
        background-color: var(--surface-colour-sunken);
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
        text-decoration: none;
        white-space: nowrap;
    }

    /* Lifted towards the card's surface, but the bottom border stays grey:
       hover must not be mistakable for selected, and the line cutting through
       is the one thing that only the selected tab does. */
    .stage-tab:hover {
        background-color: var(--surface-colour);
        color: var(--text-colour-regular);
    }

    /* An INSET ring, unlike every other focusable thing here, and the strip is
       why: `overflow-x: auto` clips on both axes -- CSS forces the other axis
       away from `visible` -- so a 3px ring drawn outside a tab is cut off at
       the top and bottom of the scroll container. Drawn inside, it is never
       clipped, and it cannot be fixed with padding either: the strip's bottom
       edge has to stay flush with the card's top border for the join. Solid
       rather than `--focus-ring`'s 25% blue, because a translucent ring over
       the tab's own background reads as a tint rather than as focus. */
    .stage-tab:focus-visible {
        outline: none;
        box-shadow: inset 0 0 0 2px var(--border-colour-brand);
    }

    .stage-tab-current {
        background-color: var(--surface-colour);
        /* The cut. This 1px sits exactly over the card's top border -- the
           strip overlaps it and paints above it -- so painting it in the card's
           own surface colour is what joins the two into one shape. Colour
           rather than `border-block-end: 0`, which would make this tab a pixel
           shorter than its neighbours. */
        border-block-end-color: var(--surface-colour);
        color: var(--text-colour-brand);
        font-weight: var(--font-weight-semibold);
    }

    /* The count as a pill rather than as `· 1`, which is what makes a tab read
       as a tab. It sits immediately after the name and NOTHING may come
       between them -- 3.7 shipped the Won badge in that gap and "Booked WON ·
       0" is a stage name split from its own count. The badge goes last. */
    .stage-tab-count {
        flex: none;
        min-width: 20px;
        padding: 1px var(--spacing-s1);
        border-radius: var(--radius-s);
        background-color: var(--surface-colour-sunken);
        color: var(--text-colour-light);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-regular);
        text-align: center;
    }

    .stage-tab-current .stage-tab-count {
        background-color: var(--surface-colour-brand-soft);
        color: var(--text-colour-brand);
    }

    /* A stage with nothing in it is not the same kind of nothing as a stage
       with deals: the number is still shown, because a broker reads the strip
       to find out where the work is and a blank tab answers nothing, but it
       stops competing with the ones that have something. */
    .stage-tab-count-empty {
        background-color: transparent;
        color: var(--text-colour-faint);
    }

    /* --- Stage strip ---
       The pipeline drawn across the top of /deal, copied from Pipedrive --
       docs/research/pipedrive/screenshots/02-deal-detail-top.jpg. A chevron per
       stage, everything up to and including where the deal is filled in, the
       current one carrying how long it has sat there.

       It is NOT .segmented and it is not the pipeline screens' row of .btns.
       Those two are pickers -- a set of peers, one of which is chosen. This is
       a SEQUENCE with a position in it, and the arrow is the whole point: it
       says which way the work runs, which a row of equal pills cannot.

       Two things about the way it is drawn:

       - **The chevron is a pseudo-element, not clip-path on the step itself.**
         A clip-path takes the focus ring with it, so a keyboard user tabbing
         along the strip would see a ring sliced off at both notches. The
         background sits on ::before and the step keeps an unclipped box to
         draw a ring on.
       - **The steps overlap by slightly less than the notch is deep**, which
         is where the hairline between them comes from. One variable pair, so
         the gap stays even if the notch changes.

       Colour carries the state, so the current step is also the semibold one
       and the only one with a figure on it -- a reader who cannot separate the
       green from the grey still has two other cues. */
    .stage-strip {
        --stage-strip-notch: 12px;
        --stage-strip-overlap: 10px;

        display: flex;
        align-items: stretch;
        /* Nine charter stages do not fit on a phone, and wrapping them would
           break the sense of a sequence -- the same call the pipeline screens'
           stage tabs make. Nothing inside pops out of this box, so the
           vertical clipping overflow-x brings with it costs nothing here. */
        overflow-x: auto;
        background-color: var(--surface-colour);
        border-bottom: 1px solid var(--border-colour);
        padding: 0 var(--gutter-page) var(--gutter-s4);
    }

    /* The strip is the last thing IN /deal's page band, so it is sticky with
       the band from 641px and the stage stays in view down a long page. The
       band's rule is the strip's, which carries the bottom border for both.

       `flow-root` because .page-band has no bottom padding, so its last
       child's margin collapses straight out of it -- with a white strip under
       it that margin became a grey stripe between two white bands. A block
       formatting context keeps the gap inside the band, where it was always
       meant to be.

       The negative margin undoes the band's own gutter: the strip keeps its
       padding so a scrolled strip runs to the band's edges rather than being
       cut off a gutter short of them. */
    .page-band:has(> .stage-strip) {
        border-bottom: 0;
        display: flow-root;
    }

    .page-band > .stage-strip {
        margin-inline: calc(var(--gutter-page) * -1);
    }

    .stage-strip-step {
        position: relative;
        /* Equal shares of the width, down to a floor -- below that the strip
           scrolls rather than squeezing stage names into two characters. */
        flex: 1 1 0;
        min-width: 104px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 30px;
        padding: var(--spacing-s1) var(--spacing-s3);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-medium);
        line-height: 1.3;
        text-align: center;
        text-decoration: none;
        color: var(--text-colour-light);
    }

    .stage-strip-step + .stage-strip-step {
        margin-inline-start: calc(var(--stage-strip-overlap) * -1);
    }

    .stage-strip-step::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: 0;
        background-color: var(--surface-colour-raised);
        clip-path: polygon(
            0 0,
            calc(100% - var(--stage-strip-notch)) 0,
            100% 50%,
            calc(100% - var(--stage-strip-notch)) 100%,
            0 100%,
            var(--stage-strip-notch) 50%
        );
    }

    /* The ends are flat: a notch on the outside edge of the strip points at
       nothing and reads as a rendering fault. */
    .stage-strip-step:first-child::before {
        clip-path: polygon(
            0 0,
            calc(100% - var(--stage-strip-notch)) 0,
            100% 50%,
            calc(100% - var(--stage-strip-notch)) 100%,
            0 100%
        );
    }

    .stage-strip-step:last-child::before {
        clip-path: polygon(
            0 0,
            100% 0,
            100% 100%,
            0 100%,
            var(--stage-strip-notch) 50%
        );
    }

    .stage-strip-step:first-child:last-child::before {
        clip-path: none;
    }

    /* Above its own chevron. Without this the background covers the words. */
    .stage-strip-label {
        position: relative;
        z-index: 1;
    }

    /* Reached: at or before the deal's current stage in pipeline order. That
       is a POSITION and not a visit -- see App\Deal\StageStrip. */
    .stage-strip-step-reached {
        color: var(--status-success-on-solid);
    }

    .stage-strip-step-reached::before {
        background-color: var(--status-success-solid);
    }

    .stage-strip-step-current {
        font-weight: var(--font-weight-semibold);
    }

    /* How long the deal has sat here. Quieter than the stage name because the
       name is what is being found and the figure is what is being noticed. */
    .stage-strip-age {
        opacity: 0.85;
        font-weight: var(--font-weight-medium);
    }

    .stage-strip-note {
        font-weight: var(--font-weight-regular);
        opacity: 0.8;
    }

    /* A LOST deal keeps the stage it died in -- losing is not a stage -- so
       filling its strip with the same green as a live deal's would report
       progress for a deal that has stopped. Same shape, stopped colour. The
       band above carries the Lost badge; this makes sure the biggest thing on
       the screen agrees with it. */
    .stage-strip-lost .stage-strip-step-reached {
        color: var(--status-neutral-on-solid);
    }

    .stage-strip-lost .stage-strip-step-reached::before {
        background-color: var(--status-neutral-solid);
    }

    /* Only the anchors -- every step on /deal is one -- so the inert spans
       /dev/components.htm draws the strip with do not offer a hover state for
       something that cannot be clicked. */
    a.stage-strip-step:hover::before {
        background-color: var(--border-colour-strong);
    }

    a.stage-strip-step-reached:hover::before {
        background-color: var(--color-success-500);
    }

    .stage-strip-lost a.stage-strip-step-reached:hover::before {
        background-color: var(--color-ui-600);
    }

    a.stage-strip-step:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
        /* Over its neighbours' chevrons, or the ring is painted under the
           overlapping step beside it. */
        z-index: 2;
    }

    /* The stage the page is SHOWING, when that is not where the deal is: a
       bar under the chevron, in the strip's own bottom padding -- inside the
       scroll box, so `overflow-x` does not clip it. A bar rather than a fill
       because the fill already says where the deal IS, and the two are
       different facts that must not read as one. */
    .stage-strip-step-viewed::after {
        content: '';
        position: absolute;
        inset-inline: var(--stage-strip-notch);
        inset-block-end: calc(var(--spacing-s2) * -1 - 1px);
        block-size: 3px;
        border-radius: var(--radius-s);
        background-color: var(--border-colour-brand);
    }

    /* --- Stage move ---
       The block at the top of /deal's page body when it is viewing a stage
       the deal is not in: "Move deal to Proposal", or "Revert the stage to
       Qualified". Forward is the brand-tinted card, because it is the thing
       the page is for while it is looking ahead; a revert is a plain card
       with an outline button, because going back is occasional and must not
       look like the next step. */
    .stage-move {
        border-color: var(--border-colour-brand);
        background-color: var(--surface-colour-brand-soft);
    }

    .stage-move-revert {
        border-color: var(--border-colour);
        background-color: var(--surface-colour);
    }

    /* The heading and "Start move" at its trailing edge. Folded, this row is
       the whole card, so the heading gives up its bottom margin and the body
       takes it back as a top one -- otherwise the folded card is taller
       under the words than above them. Centred rather than baseline-aligned,
       because the button is taller than the line. */
    .stage-move-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--spacing-s3);
    }

    .stage-move-head > .card-heading {
        margin-bottom: 0;
    }

    /* `.btn` sets a display, which beats the `hidden` attribute, and the
       button ships hidden until StageMoveStart has folded the block. */
    .stage-move-head > .btn[hidden] {
        display: none;
    }

    .stage-move-body {
        margin-block-start: var(--spacing-s2);
    }

    /* What the stage asks for -- its guidance today, its requirements once
       `stage_requirement` has rows. The title's own top margin is sized for a
       group in a long form, not the first thing under a sentence. */
    .stage-move-needs {
        margin-block-end: var(--spacing-s4);
    }

    .stage-move-needs > .field-group-title {
        margin-block: 0 var(--spacing-s1);
    }

    /* --- Menu (the card kebab) ---
       A real menu, unlike the prototype's, which was a bare positioned div of
       buttons with no roles, no arrow-key handling and no Escape (E-06). */
    .menu {
        position: relative;
    }

    .menu-trigger {
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-faint);
        cursor: pointer;
    }

    .menu-trigger:hover {
        background-color: var(--surface-colour-raised);
        color: var(--text-colour-regular);
    }

    /* The open list is MOVED TO <body> by RecordMenus and positioned in
       viewport coordinates, which is why there is no `top`/`inset` here -- the
       script owns both. Same idiom as Mint Calendar's popover, deliberately:
       one story for "a thing that hangs off a control and must not be clipped".

       It is a portal rather than an absolutely-positioned child because an
       absolutely-positioned child is clipped by ANY scrolling ancestor, and
       `.table-scroll` is one. Note that `overflow-x: auto` there computes
       `overflow-y` to `auto` as well -- CSS says a non-`visible` value on one
       axis forces the other away from `visible` -- so the menu was cut off at
       the bottom of the table even at desktop width, where nothing scrolls
       sideways at all. Moving it out also escapes the sticky actions cell's
       stacking context, which would otherwise let the NEXT row's cell paint
       over an open menu.

       z-index 55 puts it above the sidebar (40) and the header (50), because a
       menu the user just opened should not slide under either, and below the
       toasts (60), which announce things that outrank it. Mint's popover is 30
       and predates the fixed header; this is the value to copy, not that one. */
    .menu-list {
        position: fixed;
        z-index: 55;
        min-width: 160px;

        /* The list reset, which this class went without until 4.1.4.
           reset.css zeroes margins and nothing else, so a <ul> keeps the UA's
           disc marker and 40px of inline padding. It was latent rather than
           wrong: every .menu-list before this was a <div>, including the one on
           /dev/components.htm. The leads row menu is a <ul role="menu"> with
           <li role="none"> children -- which is the better semantics, and is
           what put bullets down the side of a menu. The reset belongs on the
           component either way, so the markup can be whichever is right. */
        padding-inline: 0;
        list-style: none;

        padding-block: var(--spacing-s1);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        box-shadow: var(--elevation-3);
    }

    .menu-item {
        display: flex;
        align-items: center;
        gap: var(--spacing-s2);
        width: 100%;
        padding: var(--spacing-s2) var(--spacing-s3);
        border: 0;
        background: transparent;
        color: var(--text-colour-control);
        font-size: var(--font-size-r);
        text-align: start;
        text-decoration: none;
        cursor: pointer;
    }

    .menu-item svg {
        flex: none;
        width: 16px;
        height: 16px;
    }

    .menu-item:hover {
        background-color: var(--surface-colour-sunken);
    }

    .menu-item-danger {
        color: var(--status-error-text);
    }

    .menu-item-danger:hover {
        background-color: var(--status-error-surface);
    }

    /* --- Empty state ---
       The prototype defined one of these and never wired it to the
       filtered-to-zero case, which rendered as blank space (E-05). */
    /* /notifications: each row is a button in one form, pressed to open it.
       Unread says so twice, by weight and by a dot, since weight alone is a
       difference a glance on a phone in the sun can miss. */
    .notification-list {
        display: grid;
        padding: 0;
        overflow: hidden;
    }

    .notification-row {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 2px var(--spacing-s3);
        padding: var(--spacing-s3) var(--spacing-s4) var(--spacing-s3) var(--spacing-s6);
        border: 0;
        border-top: 1px solid var(--border-colour-soft);
        background: none;
        color: var(--text-colour-regular);
        font: inherit;
        text-align: start;
        cursor: pointer;
        position: relative;
    }

    .notification-row:first-of-type {
        border-top: 0;
    }

    .notification-row:hover {
        background-color: var(--surface-colour-sunken);
    }

    .notification-row.is-unread .notification-row-title {
        font-weight: var(--font-weight-semibold);
    }

    .notification-row.is-unread::before {
        content: "";
        position: absolute;
        top: calc(var(--spacing-s3) + 7px);
        left: var(--spacing-s3);
        width: 8px;
        height: 8px;
        border-radius: var(--radius-pill);
        background-color: var(--surface-colour-brand);
    }

    .notification-row-body {
        grid-column: 1;
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    .notification-row-when {
        grid-column: 2;
        grid-row: 1;
        color: var(--text-colour-faint);
        font-size: var(--font-size-xs);
        white-space: nowrap;
    }

    /* The devices card on /notifications/settings: one row per browser or
       phone, its Remove at the trailing edge. */
    .device-list {
        display: grid;
        margin-bottom: var(--spacing-s4);
    }

    .device-row {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 2px var(--spacing-s3);
        padding: var(--spacing-s3) 0;
        border-top: 1px solid var(--border-colour-soft);
    }

    .device-row-label {
        font-weight: var(--font-weight-semibold);
    }

    .device-row-meta {
        grid-column: 1;
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    .device-row .btn {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .empty-state {
        display: grid;
        justify-items: center;
        gap: var(--spacing-s2);
        padding: var(--spacing-s10) var(--spacing-s5);
        border: 1px dashed var(--border-colour-strong);
        border-radius: var(--radius-l);
        background-color: var(--surface-colour);
        text-align: center;
    }

    .empty-state-title {
        color: var(--text-colour-regular);
        font-size: var(--font-size-m);
        font-weight: var(--font-weight-semibold);
    }

    .empty-state-body {
        color: var(--text-colour-light);
        max-width: 46ch;
    }

    /* --- Timeline ---
       A list of things that happened, newest first: roadmap 4.1's activity
       timeline on /deal and /contact.

       It is a list rather than a .data-table on purpose, and the reason is
       legibility rather than taste. The entry's body is PROSE -- doc 03 §1's
       whole complaint about BrokerFinder is that it kept THAT a call happened
       and never what was said -- and a three-column table gave that prose
       about twenty characters a line at 390px. Everything else on these pages
       is a short value in a cell, which is what a table is for.

       The separator follows .card + .card's idiom: adjacent-sibling, so a lone
       entry gets no stray rule above or below it and the container needs no
       :first-child exception. */
    .timeline-entry + .timeline-entry {
        margin-block-start: var(--spacing-s4);
        padding-block-start: var(--spacing-s4);
        border-block-start: 1px solid var(--border-colour);
    }

    /* When, what kind, who, and who else was on it -- the line that lets
       someone skim the timeline without reading it. Same muted treatment as
       .result-count, but it sits directly above its own body rather than above
       a table, so it carries a much smaller gap. */
    .timeline-meta {
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
        margin-bottom: var(--spacing-s1);
    }

    .timeline-subject {
        font-weight: var(--font-weight-semibold);
        margin-bottom: var(--spacing-s1);
    }

    /* The part worth reading in three months. `pre-wrap` because a broker
       types paragraphs into a textarea and collapsing their line breaks turns
       a set of notes into a wall. */
    .timeline-body {
        white-space: pre-wrap;
    }

    /* --- Change history ---
       A record's revisions on /contact/N and /company/N, as .timeline-entry
       items: the summary is the subject, and under it one line per field,
       "Label: was → now". The old value is muted, because the eye is looking
       for what the record says now. `pre-wrap` on the values only, for the
       same reason as .timeline-body -- a changed note is paragraphs -- and
       not on the line, which would keep the template's indentation. */
    .change-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .change-list li + li {
        margin-block-start: var(--spacing-s1);
    }

    .change-value {
        white-space: pre-wrap;
    }

    .change-was {
        color: var(--text-colour-light);
    }

    /* --- Tasks ---
       Roadmap 4.2. A task row is a quick-edit row (see above) inside a
       `.record-summary`, so nearly everything is inherited; what is here is
       the fact's own three lines and the two badges no other screen had.

       The fact stacks: what needs doing, then the meta line (when, how
       urgent, whose, and on /tasks what it is about), then the detail. It is
       a column rather than one run of text because the meta line is the
       thing a broker scans a list of tasks BY, and it wants its own line to
       be scanned on. */
    .task-list .quick-edit-fact {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .task-subject {
        font-weight: var(--font-weight-semibold);
    }

    .task-meta {
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    .task-meta .badge {
        vertical-align: text-bottom;
        margin-inline-end: var(--spacing-s1);
    }

    /* The detail keeps its line breaks, as .timeline-body does, and for the
       same reason: it was typed into a textarea. */
    .task-detail {
        white-space: pre-wrap;
        font-size: var(--font-size-s);
    }

    /* The Done form sits in the row's actions box as a named action, styled
       by `.quick-edit-add`; the form element itself must not add a box. */
    .task-done {
        display: inline-flex;
    }

    /* A date and a time on one line inside a task panel. The pair is
       `.quick-edit-pair`'s shape with the narrow column sized for HH:MM. */
    .quick-edit-pair--time {
        grid-template-columns: 1fr 7.5rem;
    }

    /* The four quick-sets under the due date. Hidden in the markup and
       revealed by DueQuickSet, because a button that does nothing is the lie
       the disabled-button note on /dev/components.htm warns about. */
    .due-quickset {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-s2);
        margin-block: var(--spacing-s2) var(--spacing-s3);
    }

    /* The length bands above a brief's two length boxes -- LengthBands.
       Hidden in the markup for the same reason as the due quick-sets. A band
       inside the range is pressed, drawn as the brand's soft selection. */
    .length-bands {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-s2);
        margin-block-end: var(--spacing-s3);
    }

    .length-bands .btn[aria-pressed="true"] {
        background-color: var(--surface-colour-brand-soft);
        border-color: var(--border-colour-brand);
        color: var(--text-colour-brand);
    }

    /* --- Documents ---
       Roadmap 4.3. A document row is a quick-edit row whose fact is the
       filename -- the download link -- over a meta line. The same stack the
       task row has, for the same reason: the meta line is what a list of
       files is scanned by. A preview, when there is one (roadmap 4.3.1),
       sits to the left of the stack. */
    .document-list .quick-edit-fact {
        --document-preview-width: 3rem;

        display: flex;
        align-items: flex-start;
        gap: var(--spacing-s2);
        min-width: 0;
    }

    /* `align-self: baseline` is what keeps the row's icon beside the
       filename: `.record-summary-item` aligns on the baseline, and without a
       baseline-aligned item here this flex box takes its baseline from its
       first item -- the preview, whose baseline is its bottom edge. */
    .document-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        align-self: baseline;
    }

    /* A page, so portrait, cropped from the top: the first lines of a
       contract are what tells one from another. An image document is cropped
       into the same box so a list of rows stays one height. */
    .document-preview {
        flex: none;
    }

    .document-preview img {
        display: block;
        width: var(--document-preview-width);
        aspect-ratio: 3 / 4;
        object-fit: cover;
        object-position: top;
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-s);
        background: var(--surface-colour);
    }

    /* A filename can be one unbroken token forty characters long. */
    .document-name {
        font-weight: var(--font-weight-semibold);
        overflow-wrap: anywhere;
    }

    .document-meta {
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    /* What was read off a passport, under its meta line. */
    .document-reading {
        font-size: var(--font-size-s);
        overflow-wrap: anywhere;
    }

    .document-reading .badge {
        margin-inline-end: var(--spacing-s1);
        vertical-align: text-bottom;
    }

    /* The native file control inside a `.field`. It is not restyled: a
       browser's own file button is the one control a person knows means
       "choose a file", and it carries the chosen name itself. Only the
       padding is eased, because `.field-input`'s is sized for typed text. */
    .field-file {
        padding-block: var(--spacing-s1);
        cursor: pointer;
    }

    /* --- Message quote ---
       Roadmap 4.1.16. Somebody else's words -- an enquiry's message -- set
       off from the card by an inset and a rule, with their line breaks kept.
       `pre-line` rather than `.timeline-body`'s `pre-wrap`: a web form leaves
       runs of trailing spaces that a broker's own textarea does not, and
       nobody indents an enquiry.

       Collapsed by `data-collapsed`, which only ExpandableText sets, so with
       JavaScript off the whole message shows. `-webkit-line-clamp` is the
       one prefixed property in this file and is supported everywhere that
       matters; the fallback for a browser without it is simply the full
       text, which is the no-JavaScript state and is fine. */
    .message-quote {
        margin: var(--spacing-s3) 0;
        padding: var(--spacing-s3) var(--spacing-s4);
        border-left: 3px solid var(--border-colour-strong);
        border-radius: 0 var(--radius-m) var(--radius-m) 0;
        background-color: var(--surface-colour-sunken);
    }

    .message-quote-body {
        margin: 0;
        white-space: pre-line;
        overflow-wrap: anywhere;
        color: var(--text-colour-regular);
    }

    /* The quote's own body, not the original inside its <details>. */
    .message-quote[data-collapsed] > .message-quote-body {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        overflow: hidden;
    }

    .message-quote-toggle {
        margin-top: var(--spacing-s2);
    }

    /* "Written in Italian", above the text so it is read first. */
    .message-quote-caption {
        margin-bottom: var(--spacing-s2);
    }

    /* A translated message's original, closed beneath the English. */
    .message-quote-original {
        margin-top: var(--spacing-s2);
    }

    .message-quote-original summary {
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
        cursor: pointer;
    }

    .message-quote-original .message-quote-body {
        margin-top: var(--spacing-s2);
    }

    /* --- Count line --- */
    .result-count {
        margin-bottom: var(--spacing-s4);
        color: var(--text-colour-light);
        font-size: var(--font-size-r);
        font-weight: var(--font-weight-medium);
    }

    /* --- Flash -----------------------------------------------------------
       The server's one-line message after a redirect: created, saved, deleted,
       or refused. The toast layer adopts it on load and removes it, so what is
       styled here is what someone with JavaScript off sees -- which is the
       reason it is still styled properly. */

    .page-flash {
        margin: var(--spacing-s4) var(--gutter-page) 0;
        padding: var(--spacing-s2) var(--spacing-s3);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        color: var(--text-colour-regular);
        font-weight: var(--font-weight-medium);
    }

    .page-flash-success {
        border-color: var(--status-success-border);
        background-color: var(--status-success-surface);
        color: var(--status-success-text);
    }

    .page-flash-error {
        border-color: var(--status-error-border);
        background-color: var(--status-error-surface);
        color: var(--status-error-text);
    }

    /* --- Confirmation ----------------------------------------------------
       One vocabulary for both ways of asking: a confirmation rendered as its
       own page (no JavaScript) and the modal a list opens instead (with it).
       If the two drifted apart, the no-JS path would be the one nobody
       noticed had gone ugly. */

    .confirm-card {
        display: grid;
        gap: var(--spacing-s3);
        margin-top: var(--spacing-s4);
    }

    .confirm-title {
        font-size: var(--font-size-l);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-regular);
    }

    .confirm-body {
        color: var(--text-colour-light);
        line-height: var(--line-height-regular);
    }

    .confirm-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: var(--spacing-s2);
        margin-top: var(--spacing-s2);
    }

    /* --- Modal -----------------------------------------------------------
       A native <dialog>, so the top layer, the backdrop, Escape, focus
       containment and inerting the rest of the page are the browser's job
       rather than ours -- the prototype hand-rolled all of it and got the
       focus half wrong.

       Centred with auto margins, NOT translate(-50%). A transformed dialog
       breaks any viewport-positioned popover inside it, which is exactly what
       Mint Calendar parks on <body> -- see docs/architecture/ui-patterns.md, "Date picking". There is
       no date field in this one; the first dialog that has one should not have
       to rediscover why. */

    .modal {
        width: min(440px, calc(100vw - 2 * var(--spacing-s4)));
        margin: auto;
        padding: var(--spacing-s5);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-l);
        background-color: var(--surface-colour);
        box-shadow: var(--elevation-6);
        color: var(--text-colour-regular);
    }

    .modal::backdrop {
        background-color: var(--overlay-colour);
    }

    /* --- Modal, for a form -----------------------------------------------
       Roadmap 4.1.17. The confirmation above is 440px of sentence and two
       buttons. An EDIT -- the brief, first -- wants a page's worth of fields
       and a textarea, so it gets a wider box whose body scrolls while the
       heading and the actions stay put: on a phone the dialog is the viewport
       less a gutter, and a form that grew past it would put Save below the
       fold. `100dvh`, not `100vh`, so a phone's collapsing browser chrome
       does not hide the actions.

       ## Inline when not modal

       includes/modal.twig ships the dialog `open` inside its card; `Modal` in
       common.js closes it on load. So a visitor without JavaScript sees the
       open, NON-modal state -- and the UA style for that is an absolutely
       positioned box laid over the card. `:not(:modal)` puts it back in the
       flow as a plain section, so the no-JavaScript page reads as a card with
       a form under its facts, which is what the quick-edit panels are without
       JavaScript too. Everything below the overlay styles is that fallback. */
    .modal-l {
        width: min(680px, calc(100vw - 2 * var(--spacing-s4)));
        max-height: calc(100dvh - 2 * var(--spacing-s4));
        padding: 0;
        /* The form is the flex column, so the body can be the part that
           scrolls; the dialog itself is just the box. */
        display: flex;
        flex-direction: column;
    }

    .modal-l:not([open]) {
        display: none;
    }

    /* Two fields sharing one cell of a `.field-grid`: a currency and its
       amount, which are one answer. The amount takes the room; the currency
       only what three letters and a caret need. `.field-pair-lead` puts the
       small one first. */
    .field-pair {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 6.5rem;
        gap: var(--spacing-s3);
        align-items: start;
    }

    /* The small field first -- a currency before its amount. */
    .field-pair-lead {
        grid-template-columns: 6.5rem minmax(0, 1fr);
    }

    /* Wider, for a form with two columns of fields and a step of prose
       beside them -- /enquiry/N's Convert to deal. */
    .modal-xl {
        width: min(880px, calc(100vw - 2 * var(--spacing-s4)));
    }

    /* "Step 2 of 3 · Background", under the title. Written by Wizard, so it
       is hidden until JavaScript has made there be steps. */
    .modal-steps {
        margin-top: var(--spacing-s2);
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-semibold);
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-colour-brand);
    }

    /* Without JavaScript every step shows, stacked; the rule between them is
       what a reader of the whole form sees as the step boundary. */
    .modal-step + .modal-step {
        margin-top: var(--spacing-s5);
        padding-top: var(--spacing-s4);
        border-top: 1px solid var(--border-colour-soft);
    }

    /* One step at a time, the title is in the progress line already --
       in a dialog or on a page (`/lead-new`). */
    .is-wizard .modal-step > .field-group-title {
        display: none;
    }

    .is-wizard .modal-step + .modal-step {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    /* The new-lead wizard (includes/lead-wizard-steps.twig): a step holds
       parts with their own headings -- find somebody, or add somebody new. */
    .lead-wizard-part + .lead-wizard-part,
    .modal-step-warning + .lead-wizard-part {
        margin-top: var(--spacing-s5);
    }

    .lead-new-person {
        min-width: 0;
        margin-inline: 0;
        padding: 0;
        border: 0;
    }

    .lead-new-person > legend {
        padding: 0;
    }

    /* Picked an existing client: the new person's fields are not the ones
       being used, and say so without vanishing. */
    .lead-new-person:disabled {
        opacity: 0.5;
    }

    .lead-duplicate-list li + li {
        margin-top: var(--spacing-s2);
    }

    .lead-duplicate-list .btn {
        margin-inline-start: var(--spacing-s2);
    }

    /* The page's wizard: the progress line opens the card, and the buttons
       close it, as a modal's header and actions do. */
    .lead-wizard {
        max-width: 880px;
    }

    .lead-wizard-progress {
        margin: 0 0 var(--spacing-s4);
    }

    .lead-wizard-actions {
        margin-top: var(--spacing-s5);
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .lead-wizard-actions > :first-child {
        margin-inline-end: auto;
    }

    .modal-step-note {
        margin: 0 0 var(--spacing-s3);
        font-size: var(--font-size-s);
        color: var(--text-colour-light);
    }

    /* A possible duplicate, on the step that would create one. A warning
       rather than an error: going ahead is allowed, and sometimes right. */
    .modal-step-warning {
        margin: 0 0 var(--spacing-s4);
        padding: var(--spacing-s3) var(--spacing-s4);
        border-inline-start: 3px solid var(--status-warning-solid);
        border-radius: var(--radius-s);
        /* The scale has a warning SOLID and no warning surface, so the colour
           is carried by the edge and the panel is neutral. */
        background: var(--status-neutral-surface);
        color: var(--text-colour-regular);
        font-size: var(--font-size-s);
    }

    .modal-step-warning ul {
        margin: var(--spacing-s2) 0 0;
        padding-inline-start: var(--spacing-s5);
    }

    .modal-form {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .modal-header {
        padding: var(--spacing-s5) var(--spacing-s5) var(--spacing-s3);
    }

    .modal-title {
        font-size: var(--font-size-l);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-regular);
    }

    .modal-intro {
        margin-top: var(--spacing-s1);
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    .modal-body {
        padding: 0 var(--spacing-s5) var(--spacing-s3);
        overflow-y: auto;
        min-height: 0;
    }

    /* The first group title sits directly under the heading, so its top
       margin is the heading's business. */
    .modal-body > .field-group-title:first-child {
        margin-top: 0;
    }

    .modal-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: var(--spacing-s2);
        padding: var(--spacing-s3) var(--spacing-s5) var(--spacing-s5);
        border-top: 1px solid var(--border-colour-soft);
    }

    /* The no-JavaScript state: an inline section, not an overlay. */
    .modal-l[open]:not(:modal) {
        position: static;
        width: auto;
        max-width: none;
        max-height: none;
        margin: var(--spacing-s4) 0 0;
        border: none;
        border-top: 1px solid var(--border-colour);
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        color: inherit;
    }

    .modal-l[open]:not(:modal) .modal-header,
    .modal-l[open]:not(:modal) .modal-body,
    .modal-l[open]:not(:modal) .modal-actions {
        padding-inline: 0;
    }

    .modal-l[open]:not(:modal) .modal-body {
        overflow: visible;
    }

    /* --- Toasts ----------------------------------------------------------
       The feedback layer (research T9, `T-01`). The prototype had no toast
       system, no role="alert" and no live region anywhere, so duplicate,
       delete, save and AI generation all completed in silence -- and a failure
       had nowhere at all to appear.

       Two regions, not one. A live region's politeness cannot be changed
       reliably once it exists, so "saved" goes to a polite region and a failure
       to an assertive one, and each keeps the urgency it was given.

       Fixed to the bottom-right, above the dock's reopen pill (z-index 30) and
       below a modal, which is in the top layer and outranks all of this. */

    .toast-region {
        position: fixed;
        inset-block-end: var(--spacing-s5);
        inset-inline-end: var(--spacing-s5);
        z-index: 60;
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s2);
        width: min(380px, calc(100vw - 2 * var(--spacing-s4)));
        /* The regions themselves must never intercept a click -- they cover a
           corner of every page whether or not anything is in them. Each toast
           takes pointer events back. */
        pointer-events: none;
    }

    /* Each politeness is its own live region, stacked inside the one fixed
       wrapper. `display: contents` would flatten them into a single column and
       is the obvious thing to reach for -- but it has a history of dropping
       elements out of the accessibility tree, which for a live region is the
       whole point of the element. Two real boxes instead, and an empty one is
       removed so it cannot contribute a stray gap. */

    .toast-stack {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s2);
    }

    .toast-stack:empty {
        display: none;
    }

    .toast {
        display: flex;
        align-items: flex-start;
        gap: var(--spacing-s3);
        padding: var(--spacing-s3) var(--spacing-s4);
        border: 1px solid var(--border-colour);
        border-inline-start: 3px solid var(--border-colour-strong);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        box-shadow: var(--elevation-4);
        color: var(--text-colour-regular);
        font-size: var(--font-size-r);
        pointer-events: auto;
    }

    .toast-success {
        border-inline-start-color: var(--status-success-solid);
    }

    .toast-error {
        border-inline-start-color: var(--status-error-solid);
    }

    .toast-message {
        flex: 1;
        min-width: 0;
        line-height: var(--line-height-regular);
    }

    .toast-dismiss {
        flex: none;
        width: 24px;
        height: 24px;
        margin: -2px calc(-1 * var(--spacing-s2)) 0 0;
        padding: 0;
        border: 0;
        border-radius: var(--radius-s);
        background: transparent;
        color: var(--text-colour-faint);
        cursor: pointer;
    }

    .toast-dismiss:hover {
        color: var(--text-colour-regular);
    }

    .toast-dismiss:focus-visible {
        outline: none;
        box-shadow: var(--focus-ring);
    }

    .toast-dismiss svg {
        width: 14px;
        height: 14px;
    }

    .toast-enter {
        animation: toast-enter var(--transition-duration) var(--transition-timing);
    }

    @keyframes toast-enter {
        from { opacity: 0; transform: translateY(6px); }
        to   { opacity: 1; transform: none; }
    }

    /* Movement is the decoration here; the toast still appears, and still
       announces, with none of it. */

    @media (prefers-reduced-motion: reduce) {
        .toast-enter {
            animation: none;
        }
    }

    /* --- Journey ---
       What a client did on the portals before they wrote in: /enquiry/N's
       "What they looked at" card, roadmap 4.6.1. Two parts, in the order a
       broker needs them -- the yachts first, then the visits as the evidence.
       docs/product/17-enquiry-intelligence.md is the argument for the order.

       The yachts are a ranked list, most time first across every visit. Name
       and its particulars on the left, the time on the right, and the one
       they enquired about carrying a badge rather than a different colour --
       a colour nobody explains is decoration, a word is a fact. */
    .journey-yachts {
        list-style: none;
        margin: 0 0 var(--spacing-s4);
        padding: 0;
    }

    .journey-yacht {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--spacing-s1) var(--spacing-s3);
        align-items: baseline;
        padding-block: var(--spacing-s2);
    }

    .journey-yacht + .journey-yacht {
        border-block-start: 1px solid var(--border-colour-soft);
    }

    .journey-yacht-name {
        font-weight: var(--font-weight-medium);
        color: var(--text-colour-regular);
    }

    .journey-yacht-detail {
        grid-column: 1;
        font-size: var(--font-size-s);
        color: var(--text-colour-light);
    }

    /* Tabular figures, so a column of times lines up by digit. Spans both
       rows, so the detail sits straight under the name rather than under the
       taller time-and-views block beside it. */
    .journey-yacht-time {
        grid-row: 1 / span 2;
        grid-column: 2;
        font-variant-numeric: tabular-nums;
        color: var(--text-colour-regular);
        white-space: nowrap;
    }

    .journey-yacht-time small {
        display: block;
        text-align: end;
        font-size: var(--font-size-xs);
        color: var(--text-colour-light);
    }

    /* A yacht they opened on YCF: the listing, and with Intelligence the
       yacht there, on a line under its particulars. */
    .journey-yacht-links {
        grid-column: 1;
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-s1) var(--spacing-s3);
        font-size: var(--font-size-s);
    }

    /* And its photo, down the row's left edge, the rest moving one column
       across. The box keeps its size and background while the image loads,
       and when there is none. */
    .journey-yacht-thumb {
        grid-column: 1;
        grid-row: 1 / span 3;
        align-self: start;
        display: block;
        width: 72px;
        height: 50px;
        overflow: hidden;
        border-radius: var(--radius-s);
        background: var(--surface-colour-sunken);
    }

    .journey-yacht-thumb img {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* A yacht with no photo is a 404, and with a width and height set Chrome
       draws a broken-image frame even for alt="". Only a BROKEN image renders
       its ::before (Chrome, Firefox), so this paints the empty box over the
       frame and never over a photo. */
    :is(.journey-yacht-thumb, .band-fact-thumb) img::before {
        content: '';
        position: absolute;
        inset: 0;
        background: var(--surface-colour-sunken);
    }

    .journey-yacht:has(.journey-yacht-thumb) {
        grid-template-columns: 72px minmax(0, 1fr) auto;
    }

    .journey-yacht:has(.journey-yacht-thumb) > :is(.journey-yacht-name, .journey-yacht-detail, .journey-yacht-links) {
        grid-column: 2;
    }

    .journey-yacht:has(.journey-yacht-thumb) > .journey-yacht-time {
        grid-column: 3;
    }

    /* The visits. A native <details> each, so opening one works with
       JavaScript off -- the enhancement rule every other disclosure here keeps
       -- and the visit they enquired in ships `open`, because it is the one
       that explains the enquiry and the others are background. */
    .journey-visit {
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-s);
    }

    .journey-visit + .journey-visit {
        margin-block-start: var(--spacing-s2);
    }

    .journey-visit-summary {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: var(--spacing-s1) var(--spacing-s3);
        padding: var(--spacing-s2) var(--spacing-s3);
        cursor: pointer;
        list-style: none;
    }

    /* Our own marker rather than the browser's triangle, which differs per
       engine and sits on a different baseline in each. */
    .journey-visit-summary::-webkit-details-marker {
        display: none;
    }

    .journey-visit-summary::before {
        content: '';
        flex: none;
        width: 0.5em;
        height: 0.5em;
        border-inline-end: 1.5px solid currentColor;
        border-block-end: 1.5px solid currentColor;
        transform: rotate(-45deg);
        color: var(--text-colour-light);
        transition: transform 120ms ease;
        align-self: center;
    }

    .journey-visit[open] > .journey-visit-summary::before {
        transform: rotate(45deg);
    }

    .journey-visit-summary:focus-visible {
        outline: 2px solid var(--border-colour-brand);
        outline-offset: -2px;
        border-radius: var(--radius-s);
    }

    .journey-visit-when {
        font-weight: var(--font-weight-medium);
        color: var(--text-colour-regular);
    }

    .journey-visit-facts {
        font-size: var(--font-size-s);
        color: var(--text-colour-light);
    }

    .journey-visit--enquiry {
        border-color: var(--border-colour-brand);
    }

    /* One line per page: time, what kind of page, what it was, how long they
       stayed. Four columns on a desktop; on a phone the kind goes, because
       the title already says it -- "Croatia Yacht Charter" is plainly a
       destination -- and three columns at 390px leave the title room to be
       read. */
    .journey-pages {
        list-style: none;
        margin: 0;
        padding: 0 var(--spacing-s3) var(--spacing-s2);
        font-size: var(--font-size-s);
    }

    .journey-page {
        display: grid;
        grid-template-columns: 4.25rem minmax(0, 1fr) auto;
        gap: var(--spacing-s3);
        align-items: baseline;
        padding-block: 3px;
    }

    .journey-page-time,
    .journey-page-dwell {
        font-variant-numeric: tabular-nums;
        color: var(--text-colour-light);
        white-space: nowrap;
    }

    .journey-page-category {
        display: none;
        color: var(--text-colour-faint);
    }

    .journey-page-title {
        color: var(--text-colour-regular);
        overflow-wrap: anywhere;
    }

    /* The form stands out as the moment they asked, which is the event the
       whole visit leads to -- and the only non-yacht line worth finding at a
       glance. */
    .journey-page--form .journey-page-title {
        font-weight: var(--font-weight-semibold);
    }

    .journey-page--form {
        background: var(--surface-colour-brand-soft);
        margin-inline: calc(var(--spacing-s2) * -1);
        padding-inline: var(--spacing-s2);
        border-radius: var(--radius-s);
    }

    @media (min-width: 641px) {
        .journey-page {
            grid-template-columns: 4.25rem 6.5rem minmax(0, 1fr) auto;
        }

        .journey-page-category {
            display: block;
        }
    }

    /* --- Yacht panel ---
       What the house's Intelligence knows about one yacht, opened in the flow
       under the yacht's name by YachtPanel (common.js) and rendered by
       includes/yacht-panel.twig. In the FLOW rather than floating: the inbox
       card's rows sit inside `.table-scroll`, whose overflow clips a popover
       on both axes -- the trap `.stage-strip` and the row menus both hit.

       A picture beside the facts from 641px; stacked below it, because a
       390px screen has room for one column and a thumbnail squeezed into
       half of it shows nothing. */
    .yacht-panel-slot {
        margin-block: var(--spacing-s2) var(--spacing-s3);
    }

    /* --- A Yacht Selection's yachts ---
       Under the selection's name on /deal, filled by SelectionYachts in
       common.js. A plain list, one yacht a line with its builder and year
       beside it -- the line a broker scans -- and each name opens the
       yacht panel above in the flow under it. */
    .selection-yachts-slot {
        margin-block-start: var(--spacing-s2);
    }

    .selection-yacht-list {
        list-style: none;
        margin: 0;
        padding: 0;
        display: grid;
        gap: var(--spacing-s1);
    }

    /* Beside the name rather than under it: `.record-summary-detail` is a
       block, and a two-line entry per yacht doubles the card's height. */
    .selection-yacht-particulars {
        display: inline;
    }

    /* The invitation to connect, under a colleague's selections: without a
       gap it reads as one more line of the list above it. */
    .record-summary + .selection-invite {
        margin-block-start: var(--spacing-s4);
    }

    .yacht-panel {
        display: grid;
        gap: var(--spacing-s3);
        max-width: 36rem;
        padding: var(--spacing-s3);
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background: var(--surface-colour-sunken);
        /* The cell it sits in may be `nowrap` somewhere up the tree; a panel
           of facts wraps like prose. */
        white-space: normal;
    }

    .yacht-panel-image {
        display: block;
        width: 100%;
        aspect-ratio: 3 / 2;
        object-fit: cover;
        border-radius: var(--radius-s);
        background: var(--surface-colour);
    }

    /* The photo and, under it, the yacht as a charter is quoted -- one
       column, so on a wide screen the specs sit under the picture rather
       than among the facts. */
    .yacht-panel-media {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s3);
        min-width: 0;
    }

    /* Guests, cabins, crew: an icon and a number over its word, three to a
       row -- the 12rem column is too narrow for "12 Guests" three abreast. */
    .yacht-panel-specs {
        list-style: none;
        margin: 0;
        padding: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: var(--spacing-s2);
    }

    .yacht-panel-spec {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        min-width: 0;
    }

    .yacht-panel-spec-count {
        display: inline-flex;
        align-items: center;
        gap: var(--spacing-s1);
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-regular);
    }

    .yacht-panel-spec-count svg {
        color: var(--text-colour-light);
    }

    .yacht-panel-spec-label {
        font-size: var(--font-size-xs);
        color: var(--text-colour-faint);
    }

    .yacht-panel-cabins {
        margin: 0;
        font-size: var(--font-size-s);
        color: var(--text-colour-regular);
    }

    .yacht-panel-cabins-term {
        display: block;
        font-size: var(--font-size-xs);
        color: var(--text-colour-faint);
    }

    .yacht-panel-body {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-s2);
        min-width: 0;
    }

    .yacht-panel-name {
        margin: 0;
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-regular);
    }

    .yacht-panel-aside {
        margin: 0;
        font-size: var(--font-size-s);
        color: var(--text-colour-light);
    }

    /* Term and value on one line, the term a fixed faint column, so a list of
       seven facts reads down two edges rather than as seven sentences. */
    .yacht-panel-facts {
        display: flex;
        flex-direction: column;
        gap: var(--spacing-s1);
        margin: 0;
        font-size: var(--font-size-s);
    }

    .yacht-panel-fact {
        display: flex;
        gap: var(--spacing-s3);
    }

    .yacht-panel-fact dt {
        flex: none;
        width: 5.5rem;
        color: var(--text-colour-faint);
    }

    .yacht-panel-fact dd {
        margin: 0;
        min-width: 0;
        color: var(--text-colour-regular);
    }

    /* On a phone the panel sits in the value column of a two-column table,
       about 150px wide, and a fixed term column left the values ~50px --
       "Custom" broke as "Custo m". So there the term takes only its own width
       and the value follows it, wrapping under it only when it has to. */
    @media (max-width: 640px) {
        .yacht-panel-fact {
            flex-wrap: wrap;
            column-gap: var(--spacing-s2);
            row-gap: 0;
        }

        .yacht-panel-fact dt {
            width: auto;
        }
    }

    @media (min-width: 641px) {
        .yacht-panel:has(.yacht-panel-media) {
            grid-template-columns: 12rem minmax(0, 1fr);
            align-items: start;
        }
    }

    /* --- Band facts ---
       The row of facts under a record's title in its page band: Received,
       Source and the yacht on /enquiry/N. A term above its answer, each fact
       a block beside the next, wrapping onto further lines on a phone. A
       `<dl>` of `<div>`s, as `.record-summary` is.

       Separated by a rule rather than boxed: a box per fact reads as a row of
       cards, and these are one line of reading. */
    .band-facts {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-s3) var(--spacing-s6);
        margin: var(--spacing-s4) 0 var(--spacing-s4);
    }

    .band-fact {
        min-width: 0;
    }

    .band-fact + .band-fact {
        padding-inline-start: var(--spacing-s5);
        border-inline-start: 1px solid var(--border-colour-soft);
    }

    .band-fact-label {
        margin-block-end: 2px;
        font-size: var(--font-size-2xs);
        font-weight: var(--font-weight-semibold);
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-colour-faint);
    }

    .band-fact-value {
        margin: 0;
        font-size: var(--font-size-r);
        font-weight: var(--font-weight-medium);
        color: var(--text-colour-regular);
    }

    .band-fact-detail {
        display: block;
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-regular);
        color: var(--text-colour-light);
    }

    /* The yacht: a thumbnail beside the name and its particulars. The box
       keeps its size and background when the photo 404s -- an alt="" image
       draws nothing -- so a missing picture is a quiet grey tile, not a hole
       that reflows the band. */
    .band-fact-yacht .band-fact-value {
        display: flex;
        align-items: center;
        gap: var(--spacing-s3);
    }

    .band-fact-thumb {
        display: block;
        flex: none;
        width: 96px;
        height: 64px;
        overflow: hidden;
        border-radius: var(--radius-s);
        background: var(--surface-colour-sunken);
    }

    .band-fact-thumb img {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Whether the headline yacht is free for the dates above it --
       includes/yacht-availability.twig, swapped into /enquiry/N's Dates.
       The badge first, then a line per calendar entry that overlaps, each a
       line of its own because a broker reads them against the dates. */
    .yacht-availability {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        margin-block-start: var(--spacing-s1);
    }

    .yacht-availability-note,
    .yacht-availability-period {
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-regular);
        color: var(--text-colour-light);
    }

    /* On a phone the rule between facts would start each wrapped line with a
       stray border, so it goes; the gap carries the separation. */
    @media (max-width: 640px) {
        .band-fact + .band-fact {
            padding-inline-start: 0;
            border-inline-start: 0;
        }

        .band-facts {
            flex-direction: column;
        }
    }

    /* --- Enquiry map ---
       Roughly where a client wrote from, in the intelligence card on
       /enquiry/N. Drawn by EnquiryMap (resources/js/enquiry-map.js) with
       Leaflet, whose own stylesheet is leaflet-vendor.css -- which loads
       AFTER this file, so every rule here that touches Leaflet's classes is
       scoped under `.enquiry-map` to win on specificity, not on order.

       An area, never a pin: the point is GeoIP rounded to about 10km. With
       JavaScript off the canvas is empty and hidden, and the caption is the
       whole of it. */
    .enquiry-map {
        margin: var(--spacing-s4) 0 0;
    }

    .enquiry-map-canvas {
        /* Leaflet stacks its panes and controls at z-index 400-1000, which
           beat the sticky band (30) and the header (50) as the page scrolled
           under them. `isolation` makes the canvas its own stacking context,
           so all of that is ordered INSIDE the map and the map as a whole is
           just part of the card. */
        position: relative;
        isolation: isolate;
        height: 220px;
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        overflow: hidden;
        background: var(--surface-colour-sunken);
    }

    /* Hidden until EnquiryMap has something to draw, and shown BEFORE Leaflet
       starts: Leaflet measures its container on construction, and a hidden
       one is 0 x 0 -- the map would draw one grey tile in the corner. */
    .enquiry-map-canvas:not(.is-ready) {
        display: none;
    }

    .enquiry-map .leaflet-container {
        font: inherit;
        font-size: var(--font-size-xs);
        background: var(--surface-colour-sunken);
    }

    /* The zoom buttons: Leaflet's are white on black whatever the theme. */
    .enquiry-map .leaflet-bar {
        border: 1px solid var(--border-colour-strong);
        border-radius: var(--radius-s);
        box-shadow: var(--shadow-card);
        background-clip: padding-box;
    }

    .enquiry-map .leaflet-bar a {
        background-color: var(--surface-colour-raised);
        border-bottom-color: var(--border-colour);
        color: var(--text-colour-regular);
    }

    .enquiry-map .leaflet-bar a:hover,
    .enquiry-map .leaflet-bar a:focus-visible {
        background-color: var(--surface-colour-sunken);
    }

    .enquiry-map .leaflet-bar a.leaflet-disabled {
        background-color: var(--surface-colour-raised);
        color: var(--text-colour-disabled);
    }

    .enquiry-map figcaption {
        margin-block-start: var(--spacing-s2);
    }

    /* --- Site search ---
       The header's box (includes/app-search.twig) and the result it lists,
       which /search lists too (includes/search-result.twig). Here and not
       in layout.css although the box sits in the shell: it is built from
       `.search-field`, and a layout-layer rule cannot override a component's. */

    .app-search {
        position: relative;
        flex: 1 1 auto;
        min-width: 0;
        max-width: 520px;
    }

    .app-search .search-field {
        max-width: none;
    }

    /* On the brand bar, so the box is the one light thing in it -- the
       affordance a broker reaches for. 36px, the account button's height. */
    .app-search .field-input {
        height: 36px;
        border-color: transparent;
    }

    .app-search-popover {
        position: absolute;
        /* The header is a fixed stacking context at 50, so this is above the
           page and the sidebar however it is numbered; 55 matches the
           flyouts for anyone reading the scale. */
        z-index: 55;
        inset-block-start: calc(100% + var(--spacing-s1));
        inset-inline: 0;
        max-height: min(70vh, 520px);
        overflow-y: auto;
        border: 1px solid var(--border-colour);
        border-radius: var(--radius-m);
        background-color: var(--surface-colour);
        box-shadow: var(--elevation-4);
        color: var(--text-colour-regular);
    }

    .app-search-status {
        padding: var(--spacing-s3) var(--spacing-s4);
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
    }

    .app-search-status:empty {
        display: none;
    }

    .app-search-all {
        display: block;
        padding: var(--spacing-s3) var(--spacing-s4);
        border-block-start: 1px solid var(--border-colour);
        color: var(--text-colour-brand);
        font-size: var(--font-size-s);
        font-weight: var(--font-weight-semibold);
        text-decoration: none;
    }

    .app-search-all[hidden] {
        display: none;
    }

    .app-search-all:hover,
    .app-search-all:focus-visible {
        background-color: var(--surface-colour-sunken);
    }

    /* A phone's header has the room for a box and nothing beside it, so the
       results take the width of the screen under the bar rather than of the
       box -- a 150px-wide list of names is a column of ellipses. */
    @media (max-width: 640px) {
        .app-search-popover {
            position: fixed;
            inset-block-start: calc(var(--shell-header-height) + var(--spacing-s1));
            inset-inline: var(--spacing-s2);
        }
    }

    .search-result-list {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .search-result + .search-result {
        border-block-start: 1px solid var(--border-colour-soft);
    }

    .search-result-link {
        display: block;
        padding: var(--spacing-s3) var(--spacing-s4);
        color: inherit;
        text-decoration: none;
    }

    .search-result-link:hover,
    .search-result-link:focus-visible {
        background-color: var(--surface-colour-sunken);
    }

    .search-result-link:focus-visible {
        outline: none;
        box-shadow: inset var(--focus-ring);
    }

    /* The card pads itself; a result list inside one runs to its edges so
       the hover band does too. */
    .card > .search-result-list {
        margin: calc(-1 * var(--spacing-s5));
    }

    .card > .search-result-list .search-result-link {
        padding-inline: var(--spacing-s5);
    }

    .search-result-head {
        display: flex;
        align-items: baseline;
        gap: var(--spacing-s2);
        min-width: 0;
    }

    .search-result-title {
        min-width: 0;
        overflow: hidden;
        font-weight: var(--font-weight-semibold);
        color: var(--text-colour-dark);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* The type after the name, never before it: the name is what is being
       scanned for, and a column of PERSON / DEAL tags down the left edge
       would be the first thing read on every line. */
    .search-result-type {
        flex: none;
    }

    .search-result-sub,
    .search-result-preview {
        display: block;
        margin-block-start: 2px;
        overflow: hidden;
        color: var(--text-colour-light);
        font-size: var(--font-size-s);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .search-result-sub[hidden],
    .search-result-preview[hidden] {
        display: none;
    }

    .search-result-preview {
        color: var(--text-colour-faint);
    }

    .search-pager {
        margin-block-start: var(--spacing-s4);
    }

    /* /admin/features: a switch per feature per column. In a table the
       selects shrink with their column, and at 390 read "I" and "Inh"; each
       keeps room for its longest word and the table scrolls instead. */
    .feature-grid .field-input {
        min-inline-size: 8rem;
    }

    /* ── Completeness: a bar, a count, and what is missing ───────────────
       /deal's Required for close card (roadmap 4.6.8 D), TJB's Compliance
       bar. A native <progress>, so the value is the element's own and a
       screen reader hears it; its two halves are styled per engine, since
       neither engine reads the other's pseudo-element. Amber while
       incomplete, green when every check is in -- the badge beside the
       heading says the same in words. */
    .completeness {
        display: flex;
        align-items: center;
        gap: var(--spacing-s3);
        margin-bottom: var(--spacing-s4);
    }

    .completeness-bar {
        flex: 1;
        block-size: var(--spacing-s2);
        border: 0;
        border-radius: var(--radius-pill);
        background: var(--status-neutral-surface);
        overflow: hidden;
        appearance: none;
    }

    .completeness-bar::-webkit-progress-bar {
        background: var(--status-neutral-surface);
        border-radius: var(--radius-pill);
    }

    .completeness-bar::-webkit-progress-value {
        background: var(--status-warning-solid);
        border-radius: var(--radius-pill);
    }

    .completeness-bar::-moz-progress-bar {
        background: var(--status-warning-solid);
        border-radius: var(--radius-pill);
    }

    .completeness-bar.is-complete::-webkit-progress-value {
        background: var(--status-success-solid);
    }

    .completeness-bar.is-complete::-moz-progress-bar {
        background: var(--status-success-solid);
    }

    .completeness-count {
        color: var(--text-colour-light);
        font-size: var(--font-size-r);
        font-weight: var(--font-weight-medium);
        white-space: nowrap;
    }

    .completeness-list {
        margin: 0 0 var(--spacing-s3);
        padding-inline-start: var(--spacing-s5);
        list-style: disc;
        font-size: var(--font-size-r);
    }
}
