/*
 * The Quality workspace (qms/templates/qms/): the sidebar, the grouped lists, the item panel and its trace, the trace
 * matrix and the heatmaps. The visual language is in docs/superpowers/plans/2026-10-21-qms-m3-workspace.md: mvui's
 * tokens in both themes, Poppins for text and Roboto Mono for item keys only, colour for risk acceptance and test results,
 * and the labels' hues (components, sections, tags, as ClickUp colours its tags), one bold element (the trace spine). Raw colours live in the :root block alone; sizes, radii and shadows come
 * from mvui's scales (--mv-fs-*, --mv-radius, --mv-shadow-float).
 * It is the QMS's only stylesheet beside mvui's (qms/shell.html, qms/external/base.html): no stylesheet of the hosting project's is loaded on a QMS
 * page; the base rules every page wants (cards, card titles, code, tables, Select2, phones, workstations) are mvui's (0.8.0),
 * and the QMS's own utilities are at the end.
 */

:root {
    /* Initials avatars: opaque fills, the same in both themes, white initials at 6.2:1 or more on each. No pure green
       or red: an avatar must never read as a test result. Measured in tests/unit/test_workspace_style.py. */
    --qms-avatar-0: #00616e;
    --qms-avatar-1: #2f5d8a;
    --qms-avatar-2: #6a4c93;
    --qms-avatar-3: #8a3b52;
    --qms-avatar-4: #7a5c1e;
    --qms-avatar-5: #4a5a6a;
    --qms-avatar-text: var(--mv-on-primary);

    /* Heatmap cells: mvui's status surfaces by the level's acceptance, its emphasis text, and the ring of a filled cell.
       The ring is the emphasis colour too: the plain status colour is only 2.7:1 on the warning tint in the light theme,
       and a ring is a graphical object (3:1). Measured in tests/unit/test_workspace_style.py. */
    --qms-heat-acceptable-bg: var(--bs-success-bg-subtle);
    --qms-heat-acceptable-text: var(--bs-success-text-emphasis);
    --qms-heat-acceptable-ring: var(--bs-success-text-emphasis);
    --qms-heat-benefit_risk-bg: var(--bs-warning-bg-subtle);
    --qms-heat-benefit_risk-text: var(--bs-warning-text-emphasis);
    --qms-heat-benefit_risk-ring: var(--bs-warning-text-emphasis);
    --qms-heat-reduce-bg: var(--bs-warning-bg-subtle);
    --qms-heat-reduce-text: var(--bs-warning-text-emphasis);
    --qms-heat-reduce-ring: var(--bs-warning-text-emphasis);
    --qms-heat-not_acceptable-bg: var(--bs-danger-bg-subtle);
    --qms-heat-not_acceptable-text: var(--bs-danger-text-emphasis);
    --qms-heat-not_acceptable-ring: var(--bs-danger-text-emphasis);

    /* The trace spine and its nodes: a test's node is filled with its result, anything else hollow. */
    --qms-spine: var(--mv-border);
    --qms-node-passed: var(--mv-success);
    --qms-node-failed: var(--mv-danger);
    --qms-node-blocked: var(--mv-warning);
    --qms-node-open: var(--mv-text-secondary);

    /* Text that steps back from its row's own: a UR or SR repeated in the matrix, a retired item's key and title. mvui's light
       secondary text (#383838) sits beside its primary (#2c2c2c) and does not read as muted, so it is mixed toward the surface:
       still 4.5:1 on the surface, a hovered row and the selected row in both themes (test_workspace_style.py). */
    --qms-muted-text: color-mix(in srgb, var(--mv-text-secondary) 80%, var(--mv-surface));

    /* A value under the pointer, a picker's highlighted option: a faint wash of the text colour, in both themes. */
    --qms-field-hover: color-mix(in srgb, var(--mv-text) 7%, var(--mv-surface));

    /* A matched word in a search hit (<mark>, qms.services.search.snippet): mvui's warning surface and its emphasis text, which
       carry 4.5:1 in both themes (measured in tests/unit/test_workspace_style.py). */
    --qms-mark-bg: var(--bs-warning-bg-subtle);
    --qms-mark-text: var(--bs-warning-text-emphasis);

    /* Labels (qms/workspace/labels.py, .qms-label): a component, section or tag takes one of these hues from its name, drawn as
       ClickUp draws its tags, a tint of the hue behind its text in a deeper shade of it: the tint mixed into the surface and the
       text into mvui's text colour, so one hue serves both themes. No pure green or red: a label must not read as a result.
       Contrast measured in tests/unit/test_workspace_style.py (QMS_LABEL_TONES of them). */
    --qms-label-0: #3d7fe0;
    --qms-label-1: #1fa2d4;
    --qms-label-2: #14a89a;
    --qms-label-3: #6366f1;
    --qms-label-4: #9d5ce6;
    --qms-label-5: #e0559a;
    --qms-label-6: #ec7a2c;
    --qms-label-7: #d9a514;
    --qms-label-8: #8a9a2e;
    --qms-label-9: #a0703c;
    --qms-label-10: #6b7d93;
    --qms-label-11: #c04fd0;

    --qms-sidebar-width: 232px; /* not wider: at 1366px the open item panel would cover the list's keys (a nested entry's long name is clipped) */
    --qms-panel-width: min(960px, 92vw);

    /* The button after a clipped text (qms_fulltext.js): its box, and the room a clipped text leaves for it (the button and the widest
       gap of the flex lines it sits in: a text that took the whole line would push the button onto a line of its own). */
    --qms-clip-btn: 1.5rem;
    --qms-clip-room: 2.25rem;
}

/* ---- Keys: the handle of every item ---- */
.qms-key {
    font-family: var(--mv-font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* A key link is told by its colour and its typeface; the underline comes with the pointer or the focus, so a column of keys reads as
   keys, not as a wall of underlines. */
a.qms-key {
    text-decoration: none;
}

a.qms-key:hover,
a.qms-key:focus-visible {
    text-decoration: underline;
}

/* One rule for a link inside a QMS table (a list's key lists, a run set's or a release's name, a document): its colour says it is a link,
   the underline comes with the pointer or the focus, as on the keys. A button styled as a link keeps its own look. */
.qms-shell .table a:not(.btn, .dropdown-item) {
    text-decoration: none;
}

.qms-shell .table a:not(.btn, .dropdown-item):hover,
.qms-shell .table a:not(.btn, .dropdown-item):focus-visible {
    text-decoration: underline;
}

/* The open item's row is tinted with the accent (--mv-selected), so the accent of its links falls under 4.5:1 there: they take the row's text
   colour, and the tint already says which row it is. */
.qms-table > tbody > tr.table-active a:not(.btn, .dropdown-item) {
    color: var(--bs-table-active-color);
}

/* ---- The shell: the sidebar beside the page from lg, an offcanvas below ---- */
.qms-shell {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.qms-main {
    flex: 1 1 auto;
    min-width: 0;
}

.qms-sidebar {
    --bs-offcanvas-width: min(300px, 85vw);
    --bs-offcanvas-bg: var(--mv-surface);
    --bs-offcanvas-color: var(--mv-text);
}

@media (min-width: 992px) {
    .qms-sidebar {
        flex: 0 0 var(--qms-sidebar-width);
        width: var(--qms-sidebar-width);
        position: sticky;
        top: var(--mv-sticky-top);
        max-height: calc(100dvh - var(--mv-sticky-top) - 16px);
        overflow-y: auto;
    }

    /* Bootstrap makes .offcanvas-lg and its .offcanvas-body transparent with !important from lg, so the tree inside is
       what is drawn on the surface, like the list beside it. */
    .qms-tree {
        flex: 1 1 auto;
        min-width: 0;
        padding: 8px;
        background-color: var(--mv-surface);
        border: 1px solid var(--mv-border);
        border-radius: var(--mv-radius);
    }
}

.qms-sidebar__title {
    font-weight: 500;
}

.qms-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--mv-fs-sm);
}

.qms-tree__link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 2px 8px;
    border-radius: var(--mv-radius);
    color: var(--mv-text-secondary);
    text-decoration: none;
}

.qms-tree__link:hover {
    color: var(--mv-text);
    background-color: var(--mv-hover-tint);
}

.qms-tree__link[aria-current="page"] {
    color: var(--mv-text);
    background-color: var(--mv-selected);
    box-shadow: inset 3px 0 0 var(--mv-accent);
}

.qms-tree__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-tree__count {
    margin-inline-start: auto;
    color: var(--mv-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* The attention badges (qms_sidebar_attention): pushed to the row's end like a count, and taking no room while empty. */
.qms-tree__attention {
    margin-inline-start: auto;
    padding-inline-start: 0.25rem;
}

.qms-tree__attention:empty {
    display: none;
}

.qms-tree__note {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-tree__list {
    margin: 0;
    padding: 0 0 4px 16px;
    list-style: none;
}

.qms-tree__list--product {
    padding-inline-start: 8px;
}

.qms-tree__nested {
    margin-inline-start: 12px;
    padding-inline-start: 4px;
    border-inline-start: 1px solid var(--mv-border);
}

/* ---- The area bar (includes/_area_bar.html): mvui's sticky sub-header bar holding the area's name (the quality system or a product, which
   the header's Quality menu switches between), then that area's sections. One row that scrolls sideways where it does not fit; below lg it scrolls away with the page, and on a phone it
   folds into the Browse drawer. ---- */
/* relative: the badges' visually-hidden text is absolutely placed, and with the sticky bar as its box it stuck out past the page's edge
   wherever the row scrolled (a tablet's browser then zoomed the whole page out); in the row it scrolls with the rest */
.qms-areas__row {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 6px 16px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

/* The area's name: a label, not a control (the header's Quality menu switches areas). */
.qms-areas__name {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 0 12px 6px 0;
    border-inline-end: 1px solid var(--mv-border);
    color: var(--mv-text);
    font-size: var(--mv-fs-md);
    font-weight: 600;
    white-space: nowrap;
}

.qms-areas__sections {
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A section is a tab on the bar's bottom edge: the open one is underlined in the accent. */
.qms-areas__section {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 100%;
    min-height: 32px;
    padding: 4px 10px 8px;
    border-bottom: 2px solid transparent;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-md);
    text-decoration: none;
    white-space: nowrap;
}

.qms-areas__section:hover {
    color: var(--mv-text);
    border-bottom-color: var(--mv-border);
}

.qms-areas__section[aria-current="true"] {
    color: var(--mv-text);
    border-bottom-color: var(--mv-accent);
}

@media (max-width: 991.98px) {
    .qms-areas {
        position: static;
    }
}

/* A phone: the sections move into the Browse drawer (_sidebar.html's .qms-tree__areas), which opens on them. */
@media (max-width: 575.98px) {
    .qms-areas {
        display: none;
    }
}

.qms-tree__areas {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mv-border);
}

/* the section shown: marked, not as the page itself (aria-current="page", the accent bar) */
.qms-tree__areas .qms-tree__link[aria-current="true"] {
    color: var(--mv-text);
    font-weight: 600;
}

@media (pointer: coarse) {
    .qms-areas__section {
        min-height: 44px;
    }
}

/* The side bar's open section: a quiet heading over its pages; the person's own pages and the data pages under a divider. */
.qms-tree__heading {
    margin: 12px 0 4px;
    padding: 0 8px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-weight: 600;
}

.qms-tree__more {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--mv-border);
}

/* ---- The attention line (includes/_attention.html): the counts that need a look, in one line, in place of a row of mostly-zero tiles ---- */
.qms-attention {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    padding: 8px 12px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-surface);
    font-size: var(--mv-fs-sm);
}

.qms-attention--open {
    border-inline-start: 3px solid var(--bs-warning);
}

.qms-attention__title,
.qms-attention__ok {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.qms-attention__title {
    font-weight: 600;
}

.qms-attention__ok {
    color: var(--mv-text-secondary);
}

.qms-attention__items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qms-attention__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* A row of number tiles (.qms-kpis) on a phone: two to a row, with the compact card's icon left out so a number and its label fit. */
@media (max-width: 575.98px) {
    .qms-kpis > [class*="col-"] {
        flex: 0 0 auto;
        width: 50%;
    }

    .qms-kpis .mv-kpi-card .mv-kpi-icon-sm,
    .qms-kpis .mv-kpi-card .mv-kpi-icon {
        display: none;
    }
}

/* ---- The list page ---- */
.qms-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

/* The less used chips' own row (_toolbar.html, More filters), and Save view at the end of the controls. */
.qms-toolbar__more {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.qms-toolbar__more[hidden] {
    display: none;
}

/* View options (_toolbar.html): the controls between the search chip and the kinds sit in the toolbar's own row from 576px (the
   wrapper is display: contents), and fold behind the toggle on a phone, where they took four rows above the first item. */
.qms-toolbar__options-toggle {
    display: none;
}

.qms-toolbar__options {
    display: contents;
}

@media (max-width: 575.98px) {
    .qms-toolbar__options-toggle {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .qms-toolbar__options {
        display: none;
    }

    .qms-toolbar__options.is-open {
        display: flex;
        flex: 1 1 100%;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }
}

.qms-toolbar > .qms-save-view {
    margin-inline-start: auto;
}

.qms-filter-note {
    margin: 0 0 12px;
    color: var(--mv-text-secondary);
}

.qms-views .mv-segmented__option {
    text-decoration: none;
}

.qms-views .mv-segmented__option[aria-current="page"] {
    color: var(--mv-text);
    background-color: var(--mv-selected);
}

.qms-list {
    background-color: var(--mv-surface);
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-col-key {
    width: 1%;
    white-space: nowrap;
}

.qms-col-title {
    width: 100%;
    min-width: 14rem;
    max-width: 0;
}

.qms-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A test whose title is only its method ("Automated test:"): the method as a small quiet tag before its first Then (values.title_parts). */
.qms-method {
    display: inline-block;
    margin-inline-end: 4px;
    padding: 0 6px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-xs);
    line-height: 1.5;
    vertical-align: 1px;
    white-space: nowrap;
}

/* A title beside a badge in a wrapping flex line: it asks for room first and the badge wraps under it when the cell is narrow. */
.qms-title--row {
    flex: 1 1 10rem;
    min-width: 0;
}

/* ---- Clipped text (M6c, qms_fulltext.js): the button that opens the whole text, and the room it needs ----
   The script puts one button after each [data-qms-clip] element while its text is really cut, and sets data-qms-clipped on the element.
   A title is a block in its cell, which would put the button on a line of its own: it becomes an inline block that leaves the
   button's room (a trace title is a flex item and only leaves the room). */
.qms-title[data-qms-clipped],
.qms-trace__title[data-qms-clipped] {
    max-width: calc(100% - var(--qms-clip-room));
}

.qms-title[data-qms-clipped] {
    display: inline-block;
    vertical-align: middle;
}

.qms-clip-btn {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: var(--qms-clip-btn);
    height: var(--qms-clip-btn);
    padding: 0;
    border: 0;
    border-radius: var(--mv-radius);
    background: none;
    color: var(--mv-text-secondary);
    line-height: 1;
    vertical-align: middle;
}

.qms-clip-btn:hover,
.qms-clip-btn:focus-visible {
    color: var(--mv-text);
    background-color: var(--mv-hover-tint);
}

/* A sidebar label sits inside its link, so its button follows the link: the item lays the link and the button in a row (the saved
   views under a list keep a line of their own). */
.qms-tree li:has(> .qms-clip-btn) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.qms-tree li:has(> .qms-clip-btn) > .qms-tree__link {
    flex: 1 1 0;
    min-width: 0;
}

.qms-tree li:has(> .qms-clip-btn) > ul {
    flex: 0 0 100%;
}

/* The dialog's text is the whole text as it was written: its line breaks kept, a long word broken rather than scrolled. */
.qms-fulltext__text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (pointer: coarse) {
    /* A 44px target in the 24px the button takes in the line: the box reaches 10px into the cut text's end and past the button,
       and above and below the line (the sidebar's rows are 44px already). */
    .qms-clip-btn {
        width: 44px;
        height: 44px;
        margin: -10px;
    }

    .qms-tree .qms-clip-btn {
        margin: 0;
    }
}

/* The badge's words wrap inside a narrow cell instead of running past it (specificity over mvui's .badge nowrap and fixed 20px
   height, no !important); two wrapped lines need room inside the pill. */
.badge.qms-review-badge {
    height: auto;
    min-height: 20px;
    padding-block: 2px;
    line-height: 1.25;
    text-align: start;
    white-space: normal;
}

/* An item drawn under several component groups: "Also in N", a button that shows the other components after it (_shared_mark.html),
   each as its label; the labels wrap (the group's own is hidden). */
.qms-shared {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-xs);
}

.qms-shared__toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    border: 0;
    border-radius: var(--mv-radius);
    background: none;
    color: inherit;
    font-size: inherit;
    white-space: nowrap;
}

.qms-shared__toggle:hover,
.qms-shared__toggle:focus-visible,
.qms-shared__toggle[aria-expanded="true"] {
    color: var(--mv-text);
    background-color: var(--mv-hover-tint);
}

.qms-shared__names {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}

.qms-shared__names[hidden] {
    display: none;
}

@media (pointer: coarse) {
    /* a 44px target in the line's 20px, as the clipped text's button */
    .qms-shared__toggle {
        min-height: 44px;
        margin-block: -12px;
    }
}

/* At the 320px reflow width the key column and a 14rem title cell are wider than the list's own scroll box, which would cut a badge
   under its title; the title column takes what is left and cuts its text to it. This is not a guarantee that a badge is in view:
   on a phone the table is wider than its scroll box anyway (its other columns, and a wider key column on a list of longer keys),
   so as with every title, the tail of a badge can sit past the visible edge until the box is scrolled. */
@media (max-width: 359.98px) {
    .qms-col-title {
        min-width: 10rem;
    }
}

/* Beats mvui's .table-sm cell padding on specificity, never with !important. */
.qms-table > tbody > tr > .qms-depth-1 {
    padding-inline-start: 24px;
}

.qms-table > tbody > tr > .qms-depth-2 {
    padding-inline-start: 40px;
}

.qms-table .mv-values a {
    font-family: var(--mv-font-mono);
    white-space: nowrap; /* a key is one word: never broken at its hyphens */
}

/* Room for what the column holds: the title takes the rest and cuts its text, so a column of wrapping content (labels, a list of keys)
   would otherwise shrink to its one widest word, a label or a key a line. Tags: three short labels side by side, in an editor's cell too (three long ones take two lines); keys: two short keys a
   line (families.COLUMNS gives the classes). */
.qms-col-tags {
    min-width: 14rem;
}

.qms-col-keys {
    min-width: 10rem;
}

/* A document's link: the kind of file it opens ("Google Doc", "GitHub"), never wrapped. */
.qms-col-link {
    white-space: nowrap;
}

/* Status from sm up and Owner from md up (as Bootstrap's d-*-table-cell did, without its !important), and neither while every row of
   the list says the same in it (views/workspace._quiet_columns, qms_workspace.js): the line above the table says so instead. */
.qms-col-status,
.qms-col-owner {
    display: none;
}

@media (min-width: 576px) {
    .qms-col-status {
        display: table-cell;
    }
}

@media (min-width: 768px) {
    .qms-col-owner {
        display: table-cell;
    }
}

.qms-table--quiet-status .qms-col-status,
.qms-table--quiet-owner .qms-col-owner {
    display: none;
}

.qms-list__quiet {
    margin: 0;
    padding: 6px 12px;
    border-bottom: 1px solid var(--mv-border);
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-list__quiet[hidden] {
    display: none;
}

/* The values nearly every row has are drawn without a pill, so the ones that need someone stand out: Active is plain text (the other
   statuses keep their badge), a low risk an outline, and the tags one neutral chip with a dot of their hue. */
.qms-status-quiet {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-table .qms-risk .badge.bg-success {
    background-color: transparent;
    outline: 1px solid var(--mv-border);
    outline-offset: -1px;
    color: var(--bs-success-text-emphasis);
}

/* Phones: a row is a card of two lines, its key with the status and result and its menu, then the whole title under them; the column
   heads go (the tick box of the whole list stays), and a cell of the default value is left out. */
@media (max-width: 767.98px) {
    .qms-table,
    .qms-table > thead,
    .qms-table > tbody {
        display: block;
    }

    .qms-table > thead > tr,
    .qms-table > tbody > tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 8px;
        padding: 4px 8px;
        border-bottom: 1px solid var(--mv-border);
    }

    .qms-table > tbody > tr[hidden] {
        display: none;
    }

    /* The open item's row is painted as one card: Bootstrap paints table-active on each cell (a box-shadow), which left the row's
       padding and the gaps between the stacked cells unpainted. */
    .qms-table > tbody > tr.table-active {
        background-color: var(--bs-table-active-bg);
    }

    .qms-table > tbody > tr.table-active > * {
        box-shadow: none;
    }

    .qms-table > thead > tr > *,
    .qms-table > tbody > tr > * {
        display: block;
        width: auto; /* a cell's 1% (the tick box, the key, the menu) was 1% of the row: its content spilled over the next cell */
        padding: 2px 0;
        border-bottom: 0;
    }

    .qms-table > thead > tr > :not(.qms-col-select),
    .qms-table > tbody > tr > [data-qms-default] {
        display: none;
    }

    .qms-table > tbody > tr > .qms-col-key {
        flex: 1 1 auto;
        order: 1;
    }

    .qms-table > tbody > tr > td {
        order: 2;
    }

    .qms-table > tbody > tr > .qms-col-select {
        order: 0;
    }

    .qms-table > tbody > tr > .qms-col-actions {
        order: 3;
    }

    .qms-table > tbody > tr > .qms-col-title {
        flex: 1 1 100%;
        order: 4;
        width: auto;
        min-width: 0;
        max-width: none;
    }

    .qms-table > tbody > tr > .qms-col-title .qms-title {
        white-space: normal;
        overflow-wrap: break-word;
    }

    .qms-table > tbody > tr > .qms-col-select ~ .qms-col-title {
        padding-inline-start: 44px;
    }

    .qms-table > tbody > tr > .qms-depth-1 ~ .qms-col-title {
        padding-inline-start: 16px;
    }

    .qms-table > tbody > tr > .qms-depth-2 ~ .qms-col-title {
        padding-inline-start: 32px;
    }

    .qms-table > tbody > tr > .qms-col-select ~ .qms-depth-1 ~ .qms-col-title {
        padding-inline-start: 60px;
    }

    .qms-table > tbody > tr > .qms-col-select ~ .qms-depth-2 ~ .qms-col-title {
        padding-inline-start: 76px;
    }

    .qms-table > tbody > tr > [colspan] {
        flex: 1 1 100%;
    }

    .qms-table > tbody > tr.qms-group__head {
        padding: 0;
    }
}

.qms-group__head > th {
    padding: 0;
    background-color: var(--mv-ground);
}

.qms-group__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 32px;
    padding: 4px 8px;
    border: 0;
    background: transparent;
    color: var(--mv-text);
    font-size: var(--mv-fs-sm);
    font-weight: 500;
    text-align: start;
}

.qms-group__toggle:hover {
    background-color: var(--mv-hover-tint);
}

/* A group's head is plain text in the heading weight (component › section): colour in a list belongs to risk levels and states. */
.qms-group__label {
    font-weight: 600;
}

.qms-group__sep {
    margin-inline: 4px;
    color: var(--mv-text-secondary);
    font-weight: 400;
}

.qms-group__count {
    color: var(--mv-text-secondary);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.qms-group__chevron {
    transition: transform 150ms;
}

.qms-group--collapsed .qms-group__chevron {
    transform: rotate(-90deg);
}

.qms-group--collapsed > tr:not(.qms-group__head) {
    display: none;
}

.qms-row--retired .qms-key,
.qms-row--retired .qms-title {
    color: var(--qms-muted-text);
}

.qms-risk,
.qms-progress,
.qms-person {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.qms-person {
    gap: 6px;
}

.qms-risk__arrow,
.qms-progress--open {
    color: var(--mv-text-secondary);
}

.qms-risk__same {
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-xs);
}

.qms-progress {
    font-variant-numeric: tabular-nums;
}

.qms-progress--not-impacted {
    color: var(--qms-muted-text);
}

.qms-progress--complete {
    color: var(--bs-success-text-emphasis);
}

.qms-progress--failed {
    color: var(--bs-danger-text-emphasis);
}

.qms-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--mv-radius);
    color: var(--qms-avatar-text);
    font-size: var(--mv-fs-2xs);
    font-weight: 500;
}

.qms-avatar--0 { background-color: var(--qms-avatar-0); }
.qms-avatar--1 { background-color: var(--qms-avatar-1); }
.qms-avatar--2 { background-color: var(--qms-avatar-2); }
.qms-avatar--3 { background-color: var(--qms-avatar-3); }
.qms-avatar--4 { background-color: var(--qms-avatar-4); }
.qms-avatar--5 { background-color: var(--qms-avatar-5); }

/* ---- The item panel: slides over the list, the list stays usable; full width on phones ---- */
.qms-panel {
    /* --qms-panel-width is the :root default, or the width the person dragged to (qms_layout.js sets it on the panel); the page
       always shows a strip on the left, so the list stays in reach */
    --bs-offcanvas-width: min(var(--qms-panel-width), calc(100vw - 48px));
    --bs-offcanvas-bg: var(--mv-surface);
    container: qms-panel / inline-size;
    --bs-offcanvas-color: var(--mv-text);
    box-shadow: var(--mv-shadow-float);
}

@media (max-width: 767.98px) {
    .qms-panel {
        --bs-offcanvas-width: 100vw;
    }
}

/* The panel's own wrappers pass the offcanvas's height down, so .offcanvas-body (overflow-y: auto) is the scroll
   container again: as plain blocks they grew past the viewport, and the fixed panel cannot be scrolled by the page. */
.qms-panel__content,
.qms-panel__inner {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.qms-panel__header {
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--mv-border);
}

.qms-panel__title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0;
}

.qms-panel__title .qms-key {
    font-size: var(--mv-fs-lg);
}

.qms-panel__kind,
.qms-panel__meta,
.qms-panel__subhead {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-weight: 400;
}

/* The title, drawn once (panel.html): its field under the key, its label for screen readers only. */
.qms-panel__title-field {
    margin: 4px 0 0;
}

.qms-panel__title-field dt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.qms-panel__title-field dd {
    margin: 0;
}

.qms-panel__title-field .qms-field__display {
    font-size: var(--mv-fs-md);
    font-weight: 500;
}

/* The title's pencil right after its text, not at the far end of the header's column. */
.qms-panel__title-field .qms-field__display {
    flex: 0 1 auto;
}

/* A narrow panel (a phone's, or one dragged narrow): the copy, activity, expand and close buttons take a row of their own above the key, so
   the title has the panel's whole width instead of half of it. */
@container qms-panel (max-width: 575.98px) {
    .qms-panel__header {
        flex-wrap: wrap;
        row-gap: 4px;
    }

    .qms-panel__actions {
        order: -1;
        flex: 1 1 100%;
        justify-content: flex-end;
    }

    .qms-panel__heading {
        flex: 1 1 100%;
        min-width: 0;
    }
}

/* Delete and whatever joins it, in a menu at the end of the meta line (_panel_header.html). */
.qms-panel__more {
    display: inline-block;
    margin-inline-start: auto;
}

/* The section bar between the header and the body (panel.html, qms_layout.js): one line, scrolled sideways where it does not fit. */
.qms-panel__nav {
    display: flex;
    flex: 0 0 auto; /* a flex child of the panel's column: with overflow-x it could shrink to half its line */
    gap: 4px;
    padding: 4px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--mv-border);
    scrollbar-width: thin;
}

.qms-panel__nav > button {
    flex: 0 0 auto;
    padding: 2px 8px;
    border: 0;
    border-radius: var(--mv-radius);
    background: none;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-panel__nav > button:hover,
.qms-panel__nav > button:focus-visible {
    color: var(--mv-text);
    background-color: var(--mv-hover-tint);
}

@media (pointer: coarse) {
    .qms-panel__nav > button {
        min-width: 44px;
        min-height: 44px;
    }
}

.qms-panel__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* The meta line and the "..." menu on one line, centred on each other (the menu sat at the top of the line and read as wrapped). */
#qms-panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    margin-top: 8px;
}

#qms-panel-header > .qms-panel__meta {
    flex: 1 1 0;
    min-width: 0;
    margin-top: 0;
}

#qms-panel-header > .qms-panel__deleted {
    flex: 1 1 100%;
}

.qms-panel__actions {
    display: flex;
    gap: 4px;
    margin-inline-start: auto;
}

.qms-panel__body {
    display: grid;
    /* One column the panel's width: the implicit auto column grew to its widest line (872px in a 393px panel) and the body
       scrolled sideways, which mv_check does not see (the page itself never scrolls). */
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.qms-panel__section + .qms-panel__section {
    margin-top: 20px;
}

.qms-panel__side {
    padding-top: 16px;
    border-top: 1px solid var(--mv-border);
}

/* Two columns once the PANEL is wide enough (a container query: its width is the person's now, not the window's); 960px is the
   default panel's width from a 1200px window up, where the two columns started before. */
@container qms-panel (min-width: 960px) {
    .qms-panel__body {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }

    .qms-panel__side {
        padding-top: 0;
        padding-inline-start: 20px;
        border-top: 0;
        border-inline-start: 1px solid var(--mv-border);
    }
}

/* Item text rendered from Markdown (qms.services.markdown.render_text) in a <div>: paragraphs, lists, code. A line break is a
   <br> already, so no white-space rule; the last block gives its margin back. */
.qms-prose {
    margin: 0;
    overflow-wrap: anywhere;
}

.qms-prose > :last-child {
    margin-bottom: 0;
}

.qms-prose p,
.qms-prose ul,
.qms-prose ol,
.qms-prose pre {
    margin: 0 0 8px;
}

.qms-prose ul,
.qms-prose ol {
    padding-inline-start: 20px;
}

.qms-prose li > ul,
.qms-prose li > ol {
    margin-bottom: 0;
}

.qms-prose code {
    font-family: var(--mv-font-mono);
    font-size: var(--mv-fs-sm);
}

.qms-prose pre {
    padding: 8px 12px;
    overflow-x: auto;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-ground);
    color: var(--mv-text);
}

.qms-prose pre code {
    font-size: var(--mv-fs-xs);
}

/* A value shown as written, not rendered: the sheet's comments and the other person's side of a conflict. */
.qms-prose--raw {
    white-space: pre-line;
}

/* ---- The trace spine: the one bold element ---- */
.qms-trace {
    position: relative;
    margin: 0 0 12px;
    padding: 0 0 0 20px;
    list-style: none;
}

.qms-trace::before {
    content: "";
    position: absolute;
    inset-block: 6px;
    inset-inline-start: 6px;
    width: 2px;
    background-color: var(--qms-spine);
}

.qms-trace__step {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 4px 0;
}

.qms-trace__step::before {
    content: "";
    position: absolute;
    top: 9px;
    inset-inline-start: -18px;
    width: 10px;
    height: 10px;
    border: 2px solid var(--qms-node-open);
    border-radius: 50%;
    background-color: var(--mv-surface);
}

.qms-trace__step--depth-2 {
    margin-inline-start: 16px;
}

.qms-trace__step--depth-2::after {
    content: "";
    position: absolute;
    top: 13px;
    inset-inline-start: -30px;
    width: 12px;
    height: 2px;
    background-color: var(--qms-spine);
}

.qms-trace__step--passed::before { background-color: var(--qms-node-passed); border-color: var(--qms-node-passed); }
.qms-trace__step--failed::before { background-color: var(--qms-node-failed); border-color: var(--qms-node-failed); }
.qms-trace__step--blocked::before { background-color: var(--qms-node-blocked); border-color: var(--qms-node-blocked); }

.qms-trace__relation {
    min-width: 6.5rem;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-trace__title {
    flex: 1 1 12rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-trace__result {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.qms-trace__release,
.qms-activity__head {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-variant-numeric: tabular-nums;
}

/* ---- Activity ---- */
.qms-activity__entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--mv-border);
}

.qms-activity__head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qms-activity__version {
    color: var(--mv-text);
    font-weight: 500;
}

.qms-activity__what {
    margin: 2px 0 0;
}

/* ---- Changes in a history (qms/workspace/diff.py, the qms_diff filter): removed red and struck, added green ---- */
.qms-diff {
    overflow-wrap: anywhere;
}

.qms-diff--text {
    white-space: pre-wrap;
}

.qms-diff__del,
.qms-diff__ins {
    padding: 0 2px;
    border-radius: var(--mv-radius);
    box-decoration-break: clone;
}

.qms-diff__del {
    background-color: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

.qms-diff__ins {
    background-color: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
    text-decoration: none;
}

.qms-diff__chip {
    display: inline-block;
    margin: 0 4px 2px 0;
    padding: 0 6px;
}

.qms-diff__ins.qms-diff__chip::before {
    content: "+ ";
}

.qms-diff__del.qms-diff__chip::before {
    content: "− ";
}

.qms-diff__arrow {
    margin: 0 6px;
    color: var(--qms-muted-text);
}

.qms-diff__gap,
.qms-diff__kept,
.qms-diff__note,
.qms-diff__same {
    color: var(--qms-muted-text);
}

.qms-diff__kept,
.qms-diff__note {
    font-size: var(--mv-fs-xs);
}

/* ---- The trace matrix: a UR or SR repeated from the row above is muted, not merged ---- */
.qms-repeat .qms-key {
    color: var(--qms-muted-text);
    font-weight: 400;
    text-decoration: none;
}

.qms-repeat .qms-key:hover,
.qms-repeat .qms-key:focus-visible {
    text-decoration: underline;
}

/* ---- Heatmaps: every cell tinted by its acceptance, a filled one ringed in its tone ---- */
.qms-heatmap th,
.qms-heatmap td {
    text-align: center;
}

.qms-heatmap .qms-heat {
    min-width: 3.5rem;
    height: 3rem;
    font-variant-numeric: tabular-nums;
}

.qms-heatmap .qms-heat--acceptable { --qms-heat-ring: var(--qms-heat-acceptable-ring); background-color: var(--qms-heat-acceptable-bg); color: var(--qms-heat-acceptable-text); }
.qms-heatmap .qms-heat--benefit_risk { --qms-heat-ring: var(--qms-heat-benefit_risk-ring); background-color: var(--qms-heat-benefit_risk-bg); color: var(--qms-heat-benefit_risk-text); }
.qms-heatmap .qms-heat--reduce { --qms-heat-ring: var(--qms-heat-reduce-ring); background-color: var(--qms-heat-reduce-bg); color: var(--qms-heat-reduce-text); }
.qms-heatmap .qms-heat--not_acceptable { --qms-heat-ring: var(--qms-heat-not_acceptable-ring); background-color: var(--qms-heat-not_acceptable-bg); color: var(--qms-heat-not_acceptable-text); }

/* mvui paints a hovered row as an inset shadow over its cells; here the tint is the cell's meaning, so no hover paint. */
.qms-heatmap > tbody > tr > .qms-heat {
    box-shadow: none;
}

.qms-heatmap > tbody > tr > .qms-heat--filled {
    box-shadow: inset 0 0 0 2px var(--qms-heat-ring);
    font-size: var(--mv-fs-lg);
    font-weight: 500;
}

.qms-heat a {
    display: block;
    color: inherit;
}

/* The axes' names, above the columns and over the rows' levels (the heatmap's own header rows). */
.qms-heatmap .qms-heatmap__axis {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-weight: 500;
    white-space: nowrap;
}

/* Pointing at a cell (qms_heatmap.js): the cell in the focus colour, and the other phase's cells that hold its items in the same ring,
   the rest faded, so the move from before to after mitigation reads at a glance. */
.qms-heatmap > tbody > tr > .qms-heat--source,
.qms-heatmap > tbody > tr > .qms-heat--linked {
    box-shadow: inset 0 0 0 3px var(--mv-focus);
}

[data-qms-heatmaps]:has(.qms-heat--source) .qms-heat--filled:not(.qms-heat--source, .qms-heat--linked) {
    opacity: 0.45;
}

.qms-heatmap__where {
    min-height: 1.5em;
    margin: 12px 0 0;
}

.qms-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

/* ---- Training (eQMS iteration 5): the matrix of people against courses ---- */
/* The course names stand on their side, so seventeen columns of badges fit a laptop; the person's name stays put while it scrolls. */
.qms-training__matrix th.qms-training__course {
    vertical-align: bottom;
    text-align: center;
}

.qms-training__course-name {
    display: inline-block;
    max-height: 13rem;
    overflow: hidden;
    font-size: var(--mv-fs-xs);
    font-weight: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.qms-training__person {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 11rem;
    background-color: var(--mv-surface);
}

.qms-training__cell {
    text-align: center;
}

.qms-training__group th {
    background-color: var(--mv-surface);
}

/* A plan's schedule and its words: a table of many role columns squeezed them to a few characters. */
.qms-training__schedule {
    min-width: 12rem;
}

.qms-training__note {
    min-width: 14rem;
}

@media (pointer: coarse) {
    /* A matrix column's course link holds only its vertical name: 18px wide otherwise. */
    .qms-training__course > a {
        display: inline-flex;
        align-items: flex-end;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- Touch and motion ---- */
@media (pointer: coarse) {
    /* A Drive file's library file, alone in its <dd>, a register entry's title link and a training page's person or course link: a 20px
       line otherwise. */
    .qms-drive__match,
    .qms-register__entry,
    .qms-training__link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .qms-tree__link,
    .qms-attention__item,
    .qms-group__toggle {
        min-height: 44px;
    }

    /* The panel's trace steps: a key link is 21px high otherwise. */
    .qms-trace__step .qms-key {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        margin-block: -12px; /* a 44px target in 20px of layout, so the node stays on the text line */
    }
}

@media (prefers-reduced-motion: reduce) {
    .qms-group__chevron,
    .qms-check__chevron {
        transition: none;
    }
}

/* ---- Click-to-edit (M4): a field group, its editor, the conflict box, the risk matrix picker, the change reason ---- */
/* A field group wraps its dt/dd pair (the element a save swaps): the pair stays in .mv-kv's grid, with mvui's own dt/dd
   look, which its child selectors no longer reach. */
.qms-kv > .qms-field {
    display: contents;
}

.qms-kv > .qms-field > dt {
    font-weight: 400;
    color: var(--mv-text-secondary);
}

.qms-kv > .qms-field > dd {
    min-width: 0;
    margin: 0 0 8px;
    overflow-wrap: anywhere;
}

@media (min-width: 576px) {
    .qms-kv > .qms-field > dd {
        margin: 0;
    }
}

.qms-field__value {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.qms-field__display {
    flex: 1 1 auto;
    min-width: 0;
}

.qms-field__edit {
    flex: 0 0 auto;
    line-height: 1;
}

.qms-field--editing > dd > .qms-field__value {
    display: none;
}

.qms-field__editor {
    display: grid;
    gap: 8px;
}

.qms-field__actions,
.qms-conflict__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qms-field__flash {
    display: inline-block;
    margin-top: 4px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-field__legend {
    margin: 4px 0 0;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-conflict {
    border: 1px solid var(--bs-warning-text-emphasis);
    border-radius: var(--mv-radius);
    background-color: var(--bs-warning-bg-subtle);
    padding: 8px 12px;
}

.qms-conflict__title {
    margin-bottom: 4px;
    font-weight: 500;
}

.qms-conflict__legend {
    margin-bottom: 4px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-conflict__diff {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.qms-conflict__diff del {
    background-color: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.qms-conflict__diff ins {
    background-color: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
    text-decoration: none;
}

.qms-conflict__theirs {
    display: none;
}

.qms-conflict--merging .qms-conflict__theirs {
    display: block;
}

.qms-matrix-picker__grid th,
.qms-matrix-picker__grid td {
    text-align: center;
    font-size: var(--mv-fs-xs);
    /* The field's <dd> breaks a long value anywhere, which cut "Medium" and "Frequent" in two; the grid keeps its words whole and
       scrolls inside its own .table-responsive where the panel is too narrow for them. */
    overflow-wrap: normal;
}

.qms-matrix-picker__cell {
    display: block;
    cursor: pointer;
}

/* The picker's six columns need more than the value column of a 960px panel: with its editor open the field's value goes under
   its label, across the whole row. */
.qms-field--editing > dd:has(.qms-matrix-picker) {
    grid-column: 1 / -1;
}

.qms-reason {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

@media (pointer: coarse) {
    .qms-field__edit,
    .qms-matrix-picker__cell {
        min-width: 44px;
        min-height: 44px;
    }

    /* A link that is a field's whole value (a dataset's) was mvui's `.mv-kv > dd > a:only-child` until the display wrapper; a baseline
       page's facts (`dl.row.qms-facts`, Bootstrap's grid, not .mv-kv's) give its release link the same box. */
    .qms-field__display > a:only-child,
    .qms-facts > dd > a:only-child {
        display: inline-flex;
        align-items: flex-start;
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- Links and + Add in the panel (M4): × on the item's own links, the picker, a child's title ---- */
.qms-trace__unlink {
    flex: 0 0 auto;
    line-height: 1;
}

.qms-add-form,
.qms-link-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.qms-add-form > .form-control {
    flex: 1 1 240px;
    width: auto;
}

.qms-link-form {
    margin: 8px 0 16px;
}

.qms-link-form__kind {
    flex: 0 0 auto;
    width: auto;
}

.qms-link-form .select2-container {
    flex: 1 1 240px;
}

@media (pointer: coarse) {
    .qms-trace__unlink {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- Editing a list in place (M4): a cell's button and its dropdown form, + Add at the end of a group ---- */
.qms-cell__button {
    border: 0;
    border-radius: var(--mv-radius);
    background: none;
    color: inherit;
    padding: 2px 4px;
    text-align: start;
}

.qms-cell__button:hover,
.qms-cell__button:focus-visible {
    background-color: var(--mv-hover-tint);
}

.qms-cell__menu {
    min-width: 220px;
    padding: 8px 12px;
}

.qms-cell__tags {
    max-height: 240px;
    overflow-y: auto;
}

.qms-add-row > td {
    border-bottom: 0;
}

/* + Add's components and section (Part 3 "Keys"): the components on a line of their own under the title */
.qms-add-form__components {
    flex: 1 1 100%;
    margin: 0;
}

.qms-add-form__section {
    flex: 0 1 280px;
    width: auto;
}

/* A document's + Add (M5): its typed key and its type, each a labelled field of its own */
.qms-add-form__field {
    flex: 1 1 240px;
}

@media (pointer: coarse) {
    .qms-cell__button {
        min-width: 44px;
        min-height: 44px;
    }

    /* A component's checkbox counts together with its label: the label is the 44px target. */
    .qms-add-form__components .form-check-label {
        display: inline-flex;
        align-items: center;
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- Comments in the activity (M4): the box and its @ menu, threads, "Show history only" ---- */
.qms-activity__filter {
    margin-bottom: 8px;
}

.qms-activity--history-only .qms-activity__entry--comment {
    display: none;
}

.qms-comment-form {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.qms-comment-form__field {
    position: relative;
}

.qms-comment-form__actions,
.qms-comment__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qms-comment__body > :last-child {
    margin-bottom: 0;
}

.qms-comment__replies {
    margin: 8px 0 0 16px;
    padding-left: 12px;
    border-left: 2px solid var(--mv-border);
}

.qms-comment__reply + .qms-comment__reply {
    margin-top: 8px;
}

.qms-comment--resolved .qms-comment__body {
    color: var(--qms-muted-text);
}

.qms-mention {
    color: var(--mv-accent);
    font-weight: 500;
}

.qms-mention-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    min-width: 240px;
    max-width: 100%;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-surface);
    box-shadow: var(--mv-shadow-float);
}

.qms-mention-menu__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    cursor: pointer;
}

.qms-mention-menu__option[aria-selected="true"] {
    background-color: var(--mv-selected);
}

@media (pointer: coarse) {
    .qms-mention-menu__option,
    .qms-comment__actions .btn,
    .qms-comment-form__actions .btn,
    .qms-activity__filter {
        min-height: 44px;
    }
}

/* ---- The formatting editor (qms_markdown.js): a toolbar over a long text's box and the comment box ---- */

.qms-md__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.qms-md__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 32px;
}

.qms-md__mode {
    margin-inline-start: auto;
}

.qms-md__glyph {
    line-height: 1;
}

.qms-md__glyph--bold {
    font-weight: 700;
}

.qms-md__glyph--italic {
    font-style: italic;
}

/* The preview stands where the box was, framed like it. */
.qms-md__preview {
    min-height: 64px;
    padding: 4px 8px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-md__link-fields {
    display: grid;
    gap: 12px;
}

@media (pointer: coarse) {
    .qms-md__button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ---- A test's parts (spec Part 2): Context, Given, When, Then and its numbered checks; the review notice; the editor ---- */
.qms-test__part {
    margin: 12px 0 2px;
    color: var(--mv-text);
    font-size: var(--mv-fs-sm);
    font-weight: 600;
}

.qms-test > .qms-test__part:first-child,
.qms-test__review + .qms-test__part {
    margin-top: 0;
}

/* The checks are the test's acceptance criteria: numbered, so a run's marks and a review can name them. */
.qms-checks {
    padding-inline-start: 24px;
}

.qms-checks > li + li {
    margin-top: 2px;
}

.qms-checks > li > p {
    margin: 0;
}

/* The split from the sheet awaits a person's look: the warning surface the conflict box uses, quieter. */
.qms-test__review {
    margin-bottom: 8px;
    padding: 8px 12px;
    border: 1px solid var(--bs-warning-border-subtle);
    border-radius: var(--mv-radius);
    background-color: var(--bs-warning-bg-subtle);
}

.qms-test__review-title {
    margin-bottom: 2px;
}

.qms-test__confidence {
    margin-bottom: 8px;
    font-size: var(--mv-fs-sm);
}

.qms-test__review-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.qms-test__reason {
    margin: 0;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-test__sheet {
    margin-top: 8px;
}

.qms-test__sheet > summary {
    color: var(--mv-text-secondary);
    cursor: pointer;
}

.qms-test__sheet > .qms-prose {
    margin-top: 4px;
    padding: 4px 8px;
    border-inline-start: 2px solid var(--mv-border);
}

.qms-test-editor {
    display: grid;
    gap: 8px;
}

.qms-test-editor__part > .form-label,
.qms-test-editor__checks > legend {
    margin-bottom: 4px;
    font-size: var(--mv-fs-sm);
}

.qms-check-rows {
    display: grid;
    gap: 4px;
    margin-bottom: 8px;
}

.qms-check-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qms-check-row__number {
    flex: 0 0 auto;
    min-width: 24px;
    color: var(--mv-text-secondary);
    text-align: end;
}

.qms-check-row__text {
    flex: 1 1 auto;
    min-width: 0;
}

.qms-check-row__tools {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
}

.qms-check-row__tools > .btn {
    line-height: 1;
}

@media (pointer: coarse) {
    .qms-check-row__tools > .btn,
    .qms-check-rows__add,
    .qms-test__confirm {
        min-width: 44px;
        min-height: 44px;
    }

    .qms-test__sheet > summary {
        min-height: 44px;
        padding-block: 10px;
    }
}

/* A phone's panel is too narrow for a check's box and its three buttons on one line: the buttons go under the box. */
@media (max-width: 575.98px) {
    .qms-check-row {
        flex-wrap: wrap;
    }

    .qms-check-row__text {
        flex-basis: calc(100% - 28px);
    }

    .qms-check-row__tools {
        margin-inline-start: 28px;
    }
}

/* ---- Live updates (M4): who else is here, a field someone else just changed, a list's new items ---- */
.qms-presence {
    display: flex;
    align-items: center;
}

.qms-presence__list {
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qms-presence__person {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.qms-presence__editing {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-panel__changed {
    margin: 4px 0 0;
    color: var(--mv-accent);
    font-size: var(--mv-fs-xs);
}

.qms-field--changed > dd {
    box-shadow: inset 3px 0 0 var(--mv-accent);
    padding-left: 8px;
}

.qms-new-items {
    margin-bottom: 8px;
    color: var(--mv-text-secondary);
}

/* ---- M5: the filter chips (_toolbar.html) ---- */

.qms-toolbar .qms-filter-note {
    flex-basis: 100%;
    margin: 0;
}

.qms-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
}

/* A chip with several values selected is long ("Review: Needs review: a part missing, Needs review: no structure"): its button
   shrinks to the toolbar and cuts the label with an ellipsis (the icon and the caret stay; the whole text is the button's title and
   its accessible name), so the page never scrolls sideways for it. */
.qms-chip > .dropdown-toggle {
    min-width: 0;
    max-width: 100%;
}

.qms-chip__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-chip__menu {
    min-width: 14rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px 12px;
}

.qms-chip__menu fieldset {
    margin: 0;
}

.qms-chip__heading {
    padding: 8px 0 2px;
}

/* A long menu's find field stays at the top while the options scroll under it, on the menu's own surface (the menu scrolls, not the page). */
.qms-chip__menu > [data-qms-chip-find] {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--mv-float-bg);
}

.qms-chip__remove {
    padding-inline: 4px;
}

@media (pointer: coarse) {
    .qms-chip__remove {
        min-width: 44px;
    }
}

/* ---- M5: the board (_board.html, _card.html, qms_board.js) ---- */

.qms-board {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    overflow-x: auto; /* the columns scroll inside the board, not the page */
    padding-bottom: 8px;
    position: relative; /* and so do the cards' visually-hidden labels: absolute, they would widen the page otherwise */
}

/* The columns share the board's width (from 13rem up to 20rem each) so four fit beside the tree at 1366 px; past that the board
   scrolls inside itself. An empty column is a narrow strip with its name and count: it still takes a drop. */
.qms-board__column {
    flex: 1 1 15rem;
    min-width: 13rem;
    max-width: min(20rem, 85vw);
    background-color: var(--mv-surface);
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    padding: 8px;
}

.qms-board__column:has(> [data-qms-column-empty]) {
    flex: 0 0 8rem;
    min-width: 8rem;
}

.qms-board__column:has(> [data-qms-column-empty]) .qms-board__title {
    flex-wrap: wrap;
}

.qms-board__column--over {
    border-color: var(--mv-accent);
    box-shadow: inset 0 0 0 1px var(--mv-accent);
}

.qms-board__title {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin: 4px 4px 8px;
}

.qms-board__cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 2rem; /* an empty column still takes a drop */
}

.qms-board__empty {
    margin: 0 4px 4px;
    color: var(--qms-muted-text);
}

.qms-card {
    background-color: var(--mv-raised);
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    padding: 8px;
}

.qms-card[draggable="true"] {
    cursor: grab;
}

.qms-card.table-active {
    background-color: var(--mv-selected);
    box-shadow: inset 3px 0 0 var(--mv-accent);
}

/* The keys' focus ring (qms_keys.js): the row or card j and k stopped on. An outline in mvui's focus colour (3:1 or more on the surface in both
   themes) round the whole row, so it reads on a row that is also the open item's (table-active) or hovered; the leading bar is the ticket queue's
   cursor, for a browser that draws no outline on a table row. */
.qms-row--focus {
    outline: 2px solid var(--mv-focus);
    outline-offset: -2px;
}

.qms-card.qms-row--focus {
    outline-offset: 1px;
}

tr.qms-row--focus > :first-child {
    box-shadow: inset 3px 0 0 var(--mv-focus);
}

/* ---- The row's actions menu (M6c, qms_row_menu.js): the last column, a "..." button for every reader ---- */
.qms-col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: end;
}

.qms-row-menu__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border: 0;
    border-radius: var(--mv-radius);
    background: none;
    color: var(--mv-text-secondary);
}

.qms-row-menu__button:hover,
.qms-row-menu__button:focus-visible,
.qms-row-menu__button[aria-expanded="true"] {
    color: var(--mv-text);
    background-color: var(--mv-hover-tint);
}

@media (pointer: coarse) {
    .qms-row-menu__button {
        min-width: 44px;
        min-height: 44px;
    }

    .qms-row-menu .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ---- Bulk edits (M6c, qms_bulk.js): the tick column, the bar that slides up while rows are ticked, and the Undo card ---- */
.qms-col-select {
    width: 1%;
    white-space: nowrap;
}

/* The box sits in a label with no text of its own: on a touch screen the label is the 44px target (the device check counts a box
   together with its label), and the box names itself with its aria-label. */
.qms-select-hit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    vertical-align: middle;
}

.qms-select-hit .form-check-input {
    margin: 0;
}

@media (pointer: coarse) {
    .qms-select-hit {
        min-width: 44px;
        min-height: 44px;
    }
}

/* The keyboard's way from the table's box to the bulk bar (qms_bulk.js): shown on focus where it stands, over the columns after it,
   so the narrow tick column does not widen while it has the focus. */
.qms-bulk-skip:focus {
    position: absolute;
    z-index: 6;
    padding: 4px 8px;
    border-radius: var(--mv-radius);
    background-color: var(--mv-raised);
    color: var(--mv-text);
    box-shadow: var(--mv-shadow-float);
    white-space: nowrap;
}

/* A group's head holds its own box before the toggle; the toggle takes what is left. */
.qms-group__bar {
    display: flex;
    align-items: center;
}

.qms-group__bar > .qms-select-hit {
    padding-inline: 8px 0;
}

.qms-group__bar > .qms-group__toggle {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
}

/* The bar is the last thing in the page's main column and sticks to the bottom of the screen while the list scrolls under it. d-none
   (display: none !important) keeps it out until a row is ticked; it slides up as it is shown. */
.qms-bulk {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-raised);
    color: var(--mv-text);
    box-shadow: var(--mv-shadow-float);
    animation: qms-bulk-in 160ms ease-out;
}

@keyframes qms-bulk-in {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

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

.qms-bulk__controls,
.qms-bulk__result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.qms-bulk__controls {
    flex: 1 1 auto;
}

.qms-bulk__result {
    flex: 1 1 24rem;
    justify-content: space-between;
}

/* Two shown parts (ticked rows again while the last summary is up) are told apart by a rule between them. */
.qms-bulk__controls:not(.d-none) + .qms-bulk__result:not(.d-none) {
    padding-top: 8px;
    border-top: 1px solid var(--mv-border);
}

.qms-bulk__count {
    min-width: 7rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.qms-bulk__summary {
    flex: 1 1 12rem;
    min-width: 0;
}

.qms-bulk__skipped {
    margin-top: 4px;
    padding-inline-start: 1.25rem;
    color: var(--qms-muted-text);
    overflow-wrap: anywhere;
}

/* A menu opens upward from the bar: its form is as wide as its fields need, and never wider than the screen. */
.qms-bulk__menu {
    min-width: 16rem;
    max-width: min(24rem, 92vw);
    padding: 8px 12px;
}

.qms-bulk__menu .qms-bulk__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

@media (pointer: coarse) {
    .qms-bulk .btn,
    .qms-bulk .btn-close {
        min-width: 44px;
        min-height: 44px;
    }

    /* A tag's checkbox counts together with its label: the label is the 44px target. */
    .qms-bulk__menu .form-check-label {
        display: inline-flex;
        align-items: center;
        min-width: 44px;
        min-height: 44px;
    }
}

.qms-card--dragging,
.qms-card--moving {
    opacity: 0.6;
}

.qms-card--retired .qms-key,
.qms-card--retired .qms-card__title {
    color: var(--qms-muted-text);
}

.qms-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.qms-card__title {
    margin: 4px 0;
    overflow-wrap: anywhere;
}

.qms-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.qms-card__move-button {
    padding: 2px 4px;
    line-height: 1;
}

@media (pointer: coarse) {
    .qms-card__move-button {
        min-width: 44px;
        min-height: 44px;
    }

    /* A card's key link is 21px high otherwise. */
    .qms-card__head .qms-key {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- M5: saved views (_sidebar_link.html, the toolbar's Save view) ---- */
.qms-tree__views {
    margin: 0;
    padding: 0 0 0 20px;
    list-style: none;
}

.qms-save-view__menu {
    min-width: 16rem;
    padding: 8px 12px;
}

/* ---- M5: My work (my_work.html, _notification.html) and its sidebar count ---- */
.qms-tree__unread {
    margin-inline-start: auto;
}

.qms-inbox {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.qms-inbox__entry {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-inbox__entry--unread {
    box-shadow: inset 3px 0 0 var(--mv-accent);
}

.qms-inbox__what {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
    min-width: 0;
}

.qms-inbox__time {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-inbox__excerpt {
    flex-basis: 100%;
    margin: 0;
    color: var(--mv-text-secondary);
    overflow-wrap: anywhere;
}

.qms-inbox__actions {
    display: flex;
    gap: 4px;
}

@media (pointer: coarse) {
    /* A notification's key link, and the key of an item in "Items you changed recently", are 21px high otherwise. */
    .qms-inbox__entry .qms-key {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- The Checks page (qms/templates/qms/checks.html) ---- */
.qms-check + .qms-check {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--mv-border);
}

/* A check that found nothing is folded and quiet: one line, its count 0, the checks that need a look stand out. */
.qms-check[data-qms-check-none]:not([open]) > .qms-check__summary {
    color: var(--qms-muted-text);
}

.qms-check[data-qms-check-none] + .qms-check[data-qms-check-none] {
    margin-top: 8px;
    padding-top: 8px;
}

.qms-check__summary {
    display: flex;
    gap: 8px;
    align-items: center;
    cursor: pointer;
    list-style: none;
}

.qms-check__summary::-webkit-details-marker {
    display: none;
}

.qms-check__chevron {
    flex: none;
    transition: transform 150ms;
}

.qms-check[open] > .qms-check__summary .qms-check__chevron {
    transform: rotate(90deg);
}

.qms-check__title {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
    margin: 0;
}

.qms-check[open] > .qms-check__summary {
    margin-bottom: 8px;
}

.qms-check__findings {
    margin: 0;
    padding: 0;
    list-style: none;
}

.qms-check__finding {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    align-items: baseline;
    padding: 4px 0;
    min-width: 0;
}

.qms-check__message {
    flex-basis: 100%;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
    overflow-wrap: anywhere;
}

.qms-check__none,
.qms-check__more {
    margin: 0;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
}

@media (pointer: coarse) {
    .qms-check__summary {
        min-height: 44px;
    }

    .qms-check__finding .qms-key,
    .qms-check__more a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- The release pages (release.html, plan_entry.html, plan_record.html) ---- */

.qms-muted {
    color: var(--qms-muted-text);
}

.qms-bulk-assign,
.qms-plan-field,
.qms-release-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.qms-bulk-assign .form-select,
.qms-release-status .form-select {
    width: auto;
    min-width: 9rem;
}

/* One field of the release's bulk bar (Assignee, Impacted): its label, its picker and the button that sets it, kept together. */
.qms-bulk-assign__set {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

/* The Test status page's scope: the Release select on one line with its label, the sentence under it. */
.qms-status-scope {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.qms-status-scope .form-select {
    width: auto;
    min-width: 14rem;
}

.qms-status-scope p {
    flex-basis: 100%;
}

/* The release's testing period (_release_period.html): one line, the Administrator's form folded under it. */
.qms-release-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
}

.qms-release-period__edit {
    flex-basis: 100%;
}

.qms-release-period__form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 12px;
    margin-top: 8px;
}

@media (pointer: coarse) {
    .qms-release-period__link,
    .qms-release-period__edit > summary,
    .qms-status-scope a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

.qms-plan-field {
    margin-top: 4px;
}

.qms-plan-field .form-control {
    flex: 1 1 20rem;
}

.qms-plan__tick {
    width: 3.5rem;
}

/* A release's groups are tables of their own: the same fixed columns in each (the colgroup in release.html), so they line up down the
   page and the title, cut with its full-text button, takes what is left instead of pushing Assignee past the card's edge. */
.qms-plan {
    table-layout: fixed;
}

.qms-plan__col-tick {
    width: 3rem;
}

.qms-plan__col-key {
    width: 10.5rem;
}

.qms-plan__col-impacted {
    width: 7.5rem;
}

.qms-plan__col-assignee {
    width: 9rem;
}

.qms-plan__col-state {
    width: 7.5rem;
}

.qms-plan__col-result {
    width: 8.5rem;
}

.qms-plan__col-record {
    width: 6.5rem;
}

.qms-plan > tbody > tr > * {
    overflow: hidden;
    text-overflow: ellipsis;
}

.qms-plan .qms-key {
    white-space: nowrap;
}

/* Phones: a planned test is a card of lines, as the list's rows are: the tick box and the key, the title on its own line, then the
   impacted, assignee, state and result in a line that wraps; the column heads go (the group's tick-all box stays). */
@media (max-width: 767.98px) {
    .qms-plan,
    .qms-plan > tbody {
        display: block;
    }

    .qms-plan > colgroup,
    .qms-plan > thead > tr > :not(.qms-plan__tick) {
        display: none;
    }

    .qms-plan > thead {
        display: block;
    }

    .qms-plan > thead > tr,
    .qms-plan > tbody > tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        column-gap: 12px;
        padding: 4px 8px;
        border-bottom: 1px solid var(--mv-border);
    }

    .qms-plan > thead > tr > *,
    .qms-plan > tbody > tr > * {
        display: block;
        width: auto;
        padding: 2px 0;
        border-bottom: 0;
        overflow: visible;
    }

    .qms-plan > tbody > tr > th {
        flex: 1 1 auto;
    }

    .qms-plan > tbody > tr > td {
        order: 3;
    }

    .qms-plan > tbody > tr > .qms-plan__tick {
        order: 0;
    }

    .qms-plan > tbody > tr > th {
        order: 1;
    }

    .qms-plan > tbody > tr > .qms-plan__title {
        flex: 1 1 100%;
        order: 2;
        min-width: 0;
    }

    .qms-plan > tbody > tr > .qms-plan__title .qms-title {
        white-space: normal;
        overflow-wrap: break-word;
    }
}

/* A plan entry's runs (plan_entry.html): one card each, its result and id on the first line, the SOP's fields in a grid that wraps,
   the anomalies drawn as Markdown under a disclosure (they are often a whole report). */
.qms-run {
    padding: 12px 16px;
    border-top: 1px solid var(--mv-border);
}

.qms-runs > .qms-run:first-child {
    border-top: 0;
}

.qms-run__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.qms-run__id {
    font-weight: 600;
}

.qms-run__facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 8px 24px;
    margin: 8px 0;
}

.qms-run__facts dt {
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
    font-weight: 400;
}

.qms-run__facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.qms-run__wide {
    grid-column: 1 / -1;
}

.qms-run__notes > summary,
.qms-run-marks > summary {
    color: var(--qms-muted-text);
}

.qms-run__notes .qms-prose {
    margin-top: 8px;
    max-width: 110ch;
}

.qms-run__notes .qms-prose > :last-child {
    margin-bottom: 0;
}

.qms-plan-history {
    margin: 0;
    padding-left: 1.25rem;
}

.qms-plan-history > li + li {
    margin-top: 8px;
}

.qms-plan-history__changes {
    margin: 2px 0 0;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
}

.qms-record__text {
    color: var(--qms-muted-text);
}

/* The record form's checks (_record_form.html): each a fieldset with its text, the four marks in a line that wraps, a note. */
.qms-record__check {
    padding: 8px 12px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-record__check > legend {
    float: none;
    width: auto;
    margin-bottom: 4px;
}

.qms-record__check-text > :last-child {
    margin-bottom: 4px;
}

.qms-record__marks {
    display: flex;
    flex-wrap: wrap;
    column-gap: 16px;
}

.qms-run-marks__list {
    margin: 8px 0 0;
    padding-left: 1.25rem;
}

.qms-run-marks__list > li + li {
    margin-top: 8px;
}

.qms-run-marks__list .qms-prose > :last-child {
    margin-bottom: 0;
}

@media (pointer: coarse) {
    .qms-plan__tick .form-check-input {
        width: 44px;
        height: 44px;
    }

    /* A mark's radio counts together with its label: the label is the 44px target. */
    .qms-record__marks .form-check-label {
        display: inline-flex;
        align-items: center;
        min-width: 44px;
        min-height: 44px;
    }

    .qms-run-marks summary,
    .qms-run__notes summary {
        display: flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- The Findings chip and My work's findings card (M6) ---- */
.qms-toolbar__warning {
    flex-basis: 100%;
    margin: 0;
}

@media (pointer: coarse) {
    /* A saved view's link on My work is 21px high otherwise (the key links have their own rule above). */
    .qms-inbox__link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* ---- Delete and restore (spec Part 4): the panel's Delete, a deleted item's note, the two dialogs ---- */

.qms-panel__deleted {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid var(--bs-secondary-border-subtle);
    border-radius: var(--mv-radius);
    background-color: var(--bs-secondary-bg-subtle);
    font-size: var(--mv-fs-sm);
}

.qms-delete {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qms-delete h3 {
    margin-bottom: 4px;
}

.qms-delete__list {
    margin: 0;
    padding-inline-start: 20px;
    overflow-wrap: anywhere;
}


/* ---- M6c: the Quality search bar, its suggestions and the results page (_search_bar.html, search/, qms_search.js) ---- */

/* The bar sits above every page's content, as wide as the page up to a comfortable line, never folded into an icon. The product
   it searches is a token inside the field, in the cell between the magnifier and the words. */
.qms-search {
    position: relative;
    max-width: 46rem;
}

/* The row above each page's content: the search field, and before it the button that shows a hidden tree (qms/base.html). */
.qms-main__top {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 16px;
}

.qms-main__top > .qms-search {
    flex: 1 1 auto;
    min-width: 0;
}

.qms-search__icon,
.qms-search__hint,
.qms-search__scope-cell {
    color: var(--mv-text-secondary);
    background-color: var(--mv-ground);
}

.qms-search__icon,
.qms-search__scope-cell {
    border-right: 0;
}

.qms-search__scope-cell {
    min-width: 0;
    padding: 0 4px;
}

.qms-search__scope {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    padding: 2px 8px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-selected);
    color: var(--mv-text);
    font-size: var(--mv-fs-sm);
    line-height: 1.4;
}

.qms-search__scope:hover {
    border-color: var(--mv-accent);
}

.qms-search__scope-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-search__input {
    min-width: 0;
    border-left: 0;
    border-right: 0;
}

.qms-search__hint {
    border-left: 0;
}

.qms-search__hint kbd {
    color: var(--mv-text-secondary);
    background: transparent;
    font-size: var(--mv-fs-2xs);
}

.qms-search__input:focus ~ .qms-search__hint {
    display: none;
}

/* The suggestions: a dropdown surface under the field, shown by qms_search.js (it toggles d-none and .show; Popper never
   positions it). Groups are a heading and their options; the highlighted option has the accent at its start. */
.qms-search__menu {
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    max-height: min(70dvh, 34rem);
    margin: 0;
    padding: 4px 0;
    overflow-y: auto;
}

.qms-search__list,
.qms-search__options {
    margin: 0;
    padding: 0;
    list-style: none;
}

.qms-search__group + .qms-search__group {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--mv-border);
}

.qms-search__heading {
    padding: 4px 12px 2px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-weight: 500;
}

.qms-search__option {
    cursor: pointer;
}

.qms-search__hit {
    display: grid;
    gap: 2px;
    padding: 6px 12px;
    border-inline-start: 3px solid transparent;
    color: var(--mv-text);
}

.qms-search__option--active > .qms-search__hit,
.qms-search__hit:hover {
    border-inline-start-color: var(--mv-accent);
    background-color: var(--mv-selected);
}

/* The key, the title and the status in one line; on a phone the title takes a line of its own when less than 8rem is left for it. */
.qms-search__line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 8px;
    min-width: 0;
}

.qms-search__line > .qms-search__title {
    flex: 1 1 8rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-search__line > .badge {
    margin-inline-start: auto;
}

.qms-search__time,
.qms-search__meta {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-search__hit .qms-search__snippet {
    overflow: hidden;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-search__option--more .qms-search__line {
    justify-content: flex-end;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-sm);
}

.qms-search__none {
    margin: 0;
    padding: 12px;
    color: var(--mv-text-secondary);
}

/* A matched word: the snippet escapes the text first and adds these tags itself. */
.qms-main mark {
    padding: 0 2px;
    border-radius: var(--mv-radius);
    background-color: var(--qms-mark-bg);
    color: var(--qms-mark-text);
}

/* The results page: the kinds with their counts, the summary line, the hits. */
.qms-search__kinds {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.qms-search__kind {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    color: var(--mv-text);
    font-size: var(--mv-fs-sm);
    text-decoration: none;
}

.qms-search__kind:hover,
.qms-search__kind[aria-current="true"] {
    border-color: var(--mv-accent);
    background-color: var(--mv-selected);
}

.qms-search__count {
    color: var(--mv-text-secondary);
    font-variant-numeric: tabular-nums;
}

.qms-search__summary {
    margin: 0 0 12px;
    color: var(--mv-text-secondary);
}

.qms-search__what {
    min-width: 9rem;
    overflow-wrap: anywhere;
}

.qms-search__what > span {
    display: block;
}

.qms-search__what .qms-search__title {
    color: var(--mv-text);
    font-weight: 500;
}

.qms-search__what .qms-search__snippet,
.qms-search__why,
.qms-search__retired {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-sm);
}

.qms-search__who {
    color: var(--mv-text-secondary);
}

.qms-search__pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.qms-search__cut {
    margin: 8px 0 0;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

/* The list's text chip (_text_chip.html): the words of a search, a label and a ×; it takes no menu. */
.qms-chip__static {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    padding: 4px 10px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-selected);
    color: var(--mv-text);
    font-size: var(--mv-fs-sm);
}

/* A comment a search hit opened the panel at: the accent a changed field gets (qms_workspace.js). */
.qms-comment--flash {
    box-shadow: inset 3px 0 0 var(--mv-accent);
    padding-left: 8px;
}

@media (pointer: coarse) {
    .qms-search__icon,
    .qms-search__input,
    .qms-search__scope-cell {
        min-height: 44px;
    }

    .qms-search__scope {
        min-width: 44px;
        min-height: 44px;
    }

    /* No keyboard shortcut to hint at; the field takes the hint's place at the end of the group, with its border and corners. */
    .qms-search__hint {
        display: none;
    }

    .qms-search__input {
        border-right: var(--bs-border-width) solid var(--bs-border-color);
        border-start-end-radius: var(--mv-radius);
        border-end-end-radius: var(--mv-radius);
    }

    .qms-search__hit {
        min-height: 44px;
        align-content: center;
    }

    .qms-search__kind,
    .qms-chip__static,
    .qms-search__pager .btn {
        min-height: 44px;
    }

    .qms-search__what .qms-key,
    .qms-search__table .qms-key,
    .qms-inbox__what > a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* The Exports page's error and outcome cells: an error is one long word-breaking string, which a narrow table squeezed into a
   column a few letters wide (the table scrolls inside its card instead). */
.qms-export-message {
    min-width: 14rem;
}

/* A run set's requirement tree (qms/runs/_tree.html): the first column indents by depth (a UR 0, an SR 1, a test 2, its Then 3), and
   keeps room for a requirement's words so the environment columns do not squeeze it to a few letters (the table scrolls inside its card).
   Beats mvui's .table-sm cell padding on specificity, never with !important. */
.qms-run-table > tbody > tr > .qms-run-name {
    min-width: 16rem;
}

.qms-run-table > tbody > tr > .qms-run-depth-1 {
    padding-inline-start: 24px;
}

.qms-run-table > tbody > tr > .qms-run-depth-2 {
    padding-inline-start: 40px;
}

.qms-run-table > tbody > tr > .qms-run-depth-3 {
    padding-inline-start: 56px;
}

.qms-run-table > tbody > tr > td {
    min-width: 9rem;
    vertical-align: top;
}

/* Touch targets on the run pages: a link or a cell's details toggle in these tables (and in the adopt page's cards) is 44px high on a
   coarse pointer (a code site, a commit, a run set's name and a key are short words). The summary stays a list item so its marker stays. */
@media (pointer: coarse) {
    .qms-run-links a:not(.btn) {
        display: inline-flex;
        align-items: center;
        min-width: 44px;
        min-height: 44px;
    }

    .qms-run-links summary {
        display: list-item;
        min-height: 44px;
        padding-block: 12px;
    }

    .qms-resources a:not(.btn) {
        display: inline-flex;
        align-items: center;
        min-width: 44px;
        min-height: 44px;
    }
}

/* The resources a test declared (qms/runs/_automated.html) and the run sets that saw a document or dataset
   (qms/workspace/_resource_uses.html): a path is a repository path or a long file name, so it breaks where it must. */
.qms-resources > li {
    padding-block: 2px;
}

.qms-resource__path {
    overflow-wrap: anywhere;
}

/* A Then's text under its test's key in the compare page's diff tables (qms/runs/compare.html): it wraps, but never below a readable
   width (a Then column of its own was squeezed to a word or a few letters a line on a phone, every other cell being nowrap); a long
   token still breaks rather than widening the table. */
.qms-compare-then {
    min-width: 9rem;
    overflow-wrap: break-word;
}

/* A failure text or skip reason in a run set's cell (qms/runs/_cell.html): the whole text as the runner sent it (line breaks kept, a long
   line wrapped), in a block that scrolls once it is taller than a screenful's part, so a long traceback never stretches the table. It
   has tabindex="0" in the markup, so the keyboard can scroll it (axe's scrollable-region-focusable), as a Markdown code block does. Its
   min-width keeps a traceback readable in a narrow environment column (a phone cut it to a few letters a line): the table scrolls
   sideways inside its card instead, and only while the details are open, since a closed <details> lays out nothing. */
.qms-run-text {
    min-width: 18rem;
    max-height: 20rem;
    margin: 0 0 8px;
    padding: 8px 12px;
    overflow: auto;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-ground);
    color: var(--mv-text);
    font-family: var(--mv-font-mono);
    font-size: var(--mv-fs-xs);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---- Labels (qms/workspace/labels.py): components, sections and tags, and the review, findings and impacted values ----
   A tint of the hue (18% into the surface) behind text of a deeper shade (45% into mvui's text colour), opaque, so a hovered or
   selected row behind it does not change its contrast. A value that says something takes mvui's status surface and its emphasis
   text, as its badge does; "No section" and its like are the secondary text's hue. Long names wrap rather than being cut. */
.qms-label {
    --qms-label-hue: var(--mv-text-secondary);
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 20px;
    padding: 0 8px;
    border-radius: var(--mv-radius);
    background-color: color-mix(in srgb, var(--qms-label-hue) 18%, var(--mv-surface));
    color: color-mix(in srgb, var(--qms-label-hue) 45%, var(--mv-text));
    font-size: var(--mv-fs-xs);
    font-weight: 500;
    line-height: 1.3;
    overflow-wrap: break-word; /* never "anywhere": it lets a table shrink a label to one letter a line */
    vertical-align: middle;
}

.qms-label--0 { --qms-label-hue: var(--qms-label-0); }
.qms-label--1 { --qms-label-hue: var(--qms-label-1); }
.qms-label--2 { --qms-label-hue: var(--qms-label-2); }
.qms-label--3 { --qms-label-hue: var(--qms-label-3); }
.qms-label--4 { --qms-label-hue: var(--qms-label-4); }
.qms-label--5 { --qms-label-hue: var(--qms-label-5); }
.qms-label--6 { --qms-label-hue: var(--qms-label-6); }
.qms-label--7 { --qms-label-hue: var(--qms-label-7); }
.qms-label--8 { --qms-label-hue: var(--qms-label-8); }
.qms-label--9 { --qms-label-hue: var(--qms-label-9); }
.qms-label--10 { --qms-label-hue: var(--qms-label-10); }
.qms-label--11 { --qms-label-hue: var(--qms-label-11); }

.qms-label--success { background-color: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.qms-label--warning { background-color: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.qms-label--danger { background-color: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.qms-label--info { background-color: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.qms-label--primary { background-color: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); }

/* A list's tags (.qms-labels--quiet, _row.html, _cell.html, the matrix): one neutral chip each, its hue a dot before the name, so a row
   of three tags is not three colours beside the result and the status. Components and sections keep their tint. */
.qms-labels--quiet .qms-label {
    gap: 4px;
    background-color: color-mix(in srgb, var(--mv-text-secondary) 12%, var(--mv-surface));
    color: var(--mv-text);
}

.qms-labels--quiet .qms-label::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--qms-label-hue);
}

/* mvui's chip (mvui_values style="chips") around a label: the label is the chip, so the frame goes. */
.mv-values__chip:has(> .qms-label:only-child) {
    min-height: 0;
    padding: 0;
    border: 0;
}

/* A label list outside mvui_values (the group heads, the panel's header): a row of labels that wraps. */
.qms-labels {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* ---- The room (qms_layout.js, each choice kept per browser): the tree beside the page hidden from lg up; the item panel's width
   (its left edge, a separator), Expand (the window but a strip) and its Activity column hidden ---- */
.qms-tree__hide,
.qms-tree__show {
    display: none;
}

.qms-flip {
    transform: scaleX(-1);
}

@media (min-width: 992px) {
    .qms-sidebar .offcanvas-body {
        position: relative;
    }

    .qms-tree__hide {
        position: absolute;
        top: 6px;
        right: 6px;
        z-index: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
        color: var(--mv-text-secondary);
    }

    .qms-shell--tree-hidden .qms-sidebar {
        display: none;
    }

    /* The button a hidden tree leaves before the search field: the tree's Hide icon turned round, as tall as the field. */
    .qms-shell--tree-hidden .qms-tree__show {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        min-width: 38px;
        padding: 0 8px;
    }
}

@media (min-width: 992px) and (pointer: coarse) {
    .qms-tree__hide,
    .qms-shell--tree-hidden .qms-tree__show {
        min-width: 44px;
        min-height: 44px;
    }
}

.qms-panel__resize {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    width: 8px;
    cursor: col-resize;
    touch-action: none;
}

.qms-panel__resize::after {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    content: "";
}

.qms-panel__resize:hover::after,
.qms-panel--resizing .qms-panel__resize::after {
    background-color: var(--mv-accent);
}

.qms-panel__resize:focus-visible {
    outline: 2px solid var(--mv-focus);
    outline-offset: -2px;
}

.qms-panel--resizing {
    transition: none;
    user-select: none;
}

@media (min-width: 768px) {
    .qms-panel.qms-panel--expanded {
        --bs-offcanvas-width: calc(100vw - 48px);
    }
}

.qms-panel--expanded .qms-panel__resize {
    display: none;
}

.qms-panel--no-activity .qms-panel__side {
    display: none;
}

.qms-panel--no-activity .qms-panel__body {
    grid-template-columns: minmax(0, 1fr);
}

/* A phone's panel is the whole screen: nothing to resize or expand. A touch screen has no edge to drag (and its 8px would be no target):
   Expand serves there. */
@media (max-width: 767.98px) {
    .qms-panel__resize,
    .qms-panel__expand {
        display: none;
    }
}

@media (pointer: coarse) {
    .qms-panel__resize {
        display: none;
    }
}

/* ---- The Automated section's own labels (runs/_automated.html): under the section's heading, never louder than it ---- */
.qms-automated__label {
    margin: 0 0 4px;
    padding: 0;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    font-weight: 500;
}

/* "Must pass in" and its chips on one line, the Edit button at its end; the label is the form's legend while the form is open. */
.qms-automated__envs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin-bottom: 12px;
}

.qms-automated__envs > .qms-automated__label {
    margin: 0;
}

.qms-automated__envs--editing {
    display: none;
}

/* A Then's text heads its row for a screen reader; it reads as the row's text, not as bold. */
.qms-run-links > tbody > tr > th.qms-run-name {
    font-weight: 400;
}

/* ---- A sandbox deployment's chip after the page's subtitle (qms/base.html) ---- */
.qms-sandbox {
    margin-inline-start: 8px;
    font-size: var(--mv-fs-sm);
    vertical-align: middle;
}

/* ---- Compare (runs/compare.html): the kinds of change with none, on one line ---- */
.qms-compare-none {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0 0 12px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-sm);
}

.qms-compare-none > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ---- The management review pack (oversight/pack.html): a contents list beside the cards ---- */
.qms-pack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.qms-pack__toc-title {
    margin-bottom: 4px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-sm);
    font-weight: 600;
}

.qms-pack__toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--mv-fs-sm);
}

.qms-pack__toc-list a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.qms-pack__toc-count {
    color: var(--mv-text-secondary);
    font-variant-numeric: tabular-nums;
}

@media (pointer: coarse) {
    .qms-pack__toc-list a {
        min-height: 44px;
    }
}

@media (min-width: 992px) {
    .qms-pack {
        grid-template-columns: minmax(0, 1fr) 14rem;
    }

    .qms-pack__toc {
        position: sticky;
        top: var(--mv-sticky-top);
        grid-column: 2;
        grid-row: 1;
        align-self: start;
    }

    .qms-pack__body {
        grid-column: 1;
        grid-row: 1;
    }

    .qms-pack__toc-list {
        flex-direction: column;
        padding-inline-start: 12px;
        border-inline-start: 1px solid var(--mv-border);
    }

    .qms-pack__toc-list a {
        justify-content: space-between;
        width: 100%;
    }
}

/* Cards a contents link scrolls to stop below the sticky header. */
.qms-pack__body > .card,
.qms-pack__body .card[id] {
    scroll-margin-top: calc(var(--mv-sticky-top) + 8px);
}

/* The clauses matrix (register/clauses.html): one mark per clause whose documents carry a register flag. */
@media (pointer: coarse) {
    .qms-clause-flag {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        margin-block: -12px;
    }
}

/* A count of 0 in a number table (PMS periods, event trends, the review pack, the run sets: the qms_zero filter) recedes, so the
   counts that are not zero stand out. */
.qms-num--zero {
    color: var(--qms-muted-text);
}

/* The Checks page's "Passing checks (N)" (checks.html): the checks of a category that found nothing, folded at its end. */
.qms-checks-passing {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--mv-border);
}

.qms-checks-passing__summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
    cursor: pointer;
}

.qms-checks-passing[open] > .qms-checks-passing__summary {
    margin-bottom: 8px;
}

.qms-checks-passing > .qms-check {
    margin-inline-start: 16px;
}

@media (pointer: coarse) {
    .qms-checks-passing__summary {
        min-height: 44px;
    }
}

/* The quality calendar: a card per month, each its own table with the same fixed columns (the colgroup in calendar.html), so the dates,
   areas and states line up down the page; the title takes what is left. Below md the table keeps its natural widths and scrolls. */
@media (min-width: 768px) {
    .qms-calendar {
        table-layout: fixed;
    }

    .qms-calendar__col-date {
        width: 9.5rem;
    }

    .qms-calendar__col-area {
        width: 13rem;
    }

    .qms-calendar__col-owner {
        width: 12rem;
    }

    .qms-calendar__col-state {
        width: 7.5rem;
    }
}

/* The quality objectives' audit picker: a scrolling box of checkboxes, as long as the programme. */
.qms-objective-audits {
    max-height: 14rem;
    overflow-y: auto;
}

/* A text cell of a QMS table keeps a readable width on a phone (2026-11-06): with the other columns nowrap, a `.text-break` cell (an
   event's title, a document's name, a file in a release record) was squeezed to a few letters a line ("Interna / l audit / 2026-").
   The table scrolls sideways inside its .table-responsive instead, as the wide-table hint above such tables says. */
@media (max-width: 767.98px) {
    .qms-main .table-responsive > .table > tbody > tr > :is(td, th).text-break {
        min-width: 9rem;
    }
}

/* Sortable columns (qms_tables.js): the header's words in a button that looks like the header, an arrow beside them that is faint until the
   column sorts the table. A coarse pointer gets the 44px target. */
.qms-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
}

.qms-sort__icon {
    display: inline-flex;
    opacity: 0.45;
}

[aria-sort] > .qms-sort .qms-sort__icon,
.qms-sort:hover .qms-sort__icon {
    opacity: 1;
}

/* The filter field above a long table, and the count of what it shows. */
.qms-table-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.qms-table-filter__field {
    max-width: 18rem;
}

@media (pointer: coarse) {
    .qms-sort {
        min-width: 44px;
        min-height: 44px;
    }
}

/* The Test status page's verdict bars (runs/_verdict_bar.html): every test split by its latest automated verdict, then by its recorded
   result, as one proportional bar each (an SVG, so the segments' widths are attributes) over a legend whose entries filter the list. The
   bar is what shows how far verification has come; the legend carries the numbers and the links. */
.qms-verdict + .qms-verdict {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--mv-border);
}

.qms-verdict__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.qms-verdict__bar {
    display: block;
    width: 100%;
    height: 14px;
    border-radius: var(--mv-radius);
    overflow: hidden;
}

.qms-verdict__track {
    fill: var(--bs-tertiary-bg);
}

.qms-verdict__seg + .qms-verdict__seg {
    stroke: var(--bs-body-bg);
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.qms-verdict--passed {
    fill: var(--bs-success);
    background-color: var(--bs-success);
}

.qms-verdict--failed {
    fill: var(--bs-danger);
    background-color: var(--bs-danger);
}

.qms-verdict--partial,
.qms-verdict--blocked {
    fill: var(--bs-warning);
    background-color: var(--bs-warning);
}

.qms-verdict--running {
    fill: var(--bs-info);
    background-color: var(--bs-info);
}

.qms-verdict--skipped {
    fill: var(--bs-secondary-color);
    background-color: var(--bs-secondary-color);
}

/* Not run and no run recorded are the track itself: what is still to do. */
.qms-verdict--not_run,
.qms-verdict--none {
    fill: var(--bs-tertiary-bg);
    background-color: var(--bs-tertiary-bg);
    outline: 1px solid var(--mv-border);
    outline-offset: -1px;
}

.qms-verdict__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    margin: 0.5rem 0 0;
}

.qms-verdict__key {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--mv-text);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

a.qms-verdict__key:hover,
a.qms-verdict__key:focus-visible {
    border-bottom-color: currentcolor;
}

.qms-verdict__key.active,
.qms-verdict__all.active {
    border-bottom-color: var(--mv-accent);
    font-weight: 600;
}

.qms-verdict__key--zero {
    color: var(--qms-muted-text);
}

.qms-verdict__swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: var(--mv-radius);
}

@media (pointer: coarse) {
    .qms-verdict__key,
    .qms-verdict__all {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* The status page's modules with nothing to look at today (oversight/system.html): one row each, the name and clause, then the figures that
   are not zero; the modules that need a look keep their cards above it. */
.qms-system-clear__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: baseline;
    gap: 0.25rem 1.5rem;
}

@media (min-width: 768px) {
    .qms-system-clear__row {
        grid-template-columns: minmax(16rem, 2fr) 3fr;
    }
}

.qms-system-clear__name {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
}

.qms-system-clear__name a {
    font-weight: 500;
    text-decoration: none;
}

.qms-system-clear__name a:hover,
.qms-system-clear__name a:focus-visible {
    text-decoration: underline;
}

.qms-system-clear__figures {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    color: var(--mv-text-secondary);
}

@media (pointer: coarse) {
    .qms-system-clear__name a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

/* The library's table (library/_files_table.html): the document's title keeps room for a few words a line, and a file no rule classes says
   so in muted text rather than as a badge on every row. */
.qms-library-title {
    min-width: 14rem;
}

.badge.qms-class-unset {
    padding-left: 0;
    padding-right: 0;
    background-color: transparent;
    color: var(--qms-muted-text);
    font-weight: 400;
}

/* A section's own pages in the side bar have fixed names: a long one ("Post-market surveillance") wraps to a second line rather than being
   cut, so it is no clipping label (.qms-tree__label) and needs no full-text button; a saved view's name, which a person types, is still cut. */
.qms-tree__name {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.25;
}

/* A filter form folded behind its Filters button on a phone (includes/_filters_toggle.html): the opened form starts under the button. */
.qms-filters-toggle + .qms-filters {
    margin-top: 0.5rem;
}

@media (min-width: 768px) {
    .qms-filters-toggle + .qms-filters {
        margin-top: 0;
    }
}

/* ---- The panel's details as ClickUp's task page lays them out (_fields.html, editing.field_layout) ----
   Properties (status, owner, components, tags, a choice, a short text or link) in two columns of icon + name | value; a property
   opens its editor under it as a popover over what follows. Then the long texts, each under its name in a box that shows it can
   hold a long text. Then "More details" (.mv-kv, as before). */
.qms-props {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 32px;
    row-gap: 2px;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--mv-border);
}

@container qms-panel (min-width: 576px) {
    .qms-props {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.qms-props > .qms-field {
    position: relative;
    display: grid;
    grid-template-columns: minmax(6.5rem, 40%) minmax(0, 1fr);
    align-items: start;
    column-gap: 8px;
}

.qms-props > .qms-field > dt,
.qms-texts > .qms-field > dt {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    margin: 0;
    color: var(--mv-text-secondary);
    font-weight: 400;
}

.qms-field__icon {
    flex: 0 0 auto;
    opacity: 0.8;
}

.qms-props > .qms-field > dd,
.qms-texts > .qms-field > dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

/* The value is the click target (qms_edit.js opens the editor on it): a row that lights up under the pointer, as ClickUp's. */
.qms-props .qms-field__value {
    align-items: center;
    gap: 4px;
}

.qms-props .qms-field__display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: var(--mv-radius);
}

.qms-props .qms-field:has([data-qms-editor]) .qms-field__display,
.qms-texts .qms-field:has([data-qms-editor]) .qms-field__display {
    cursor: pointer;
}

.qms-props .qms-field:has([data-qms-editor]) .qms-field__display:hover,
.qms-props .qms-field--editing .qms-field__display {
    background-color: var(--qms-field-hover);
}

/* The pencil stays (a keyboard's way in, a touch screen's too), quietly: no frame until it is pointed at or focused. */
.qms-props .qms-field__edit,
.qms-texts .qms-field__edit {
    border-color: transparent;
    color: var(--mv-text-secondary);
}

.qms-props .qms-field__edit:hover,
.qms-props .qms-field__edit:focus-visible,
.qms-texts .qms-field__edit:hover,
.qms-texts .qms-field__edit:focus-visible {
    border-color: var(--mv-border);
    color: var(--mv-text);
}

/* A property being edited keeps its value in sight; the editor opens under the row, over what follows. */
.qms-props > .qms-field--editing > dd > .qms-field__value {
    display: flex;
}

.qms-props > .qms-field--editing {
    z-index: 3;
}

.qms-props .qms-field__editor {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    padding: 8px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-surface);
    box-shadow: var(--mv-shadow-float);
}

@container qms-panel (min-width: 576px) {
    .qms-props .qms-field__editor {
        min-width: 18rem;
    }

    /* The right-hand column's editor grows to the left, so it never leaves the panel. */
    .qms-props > .qms-field:nth-child(even) .qms-field__editor {
        left: auto;
    }
}

/* A single choice saves the moment it is picked (qms_picker.js): its Save button would only repeat that. */
.qms-field__editor:has([data-qms-picker="one"]) .qms-field__actions [type="submit"],
.qms-cell__menu:has([data-qms-picker="one"]) > [type="submit"] {
    display: none;
}

.qms-texts {
    display: grid;
    grid-template-columns: minmax(0, 1fr); /* never wider than the panel: a long code line scrolls in its own block */
    gap: 16px;
    margin: 0 0 16px;
}

/* A long text's pencil sits at the end of its name's line, so the box below has the panel's whole width (a phone's too). */
.qms-texts > .qms-field {
    position: relative;
}

.qms-texts .qms-field__edit {
    position: absolute;
    top: 0;
    right: 0;
}

.qms-texts > .qms-field > dt {
    padding-right: 48px;
    margin-bottom: 4px;
    font-size: var(--mv-fs-sm);
    font-weight: 500;
}

/* A long text reads as a box that holds one: a frame, room below the text, and an empty one says what goes there. */
.qms-texts .qms-field__display {
    min-height: 5.5rem;
    padding: 8px 12px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-texts .qms-field:has([data-qms-editor]) .qms-field__display:hover {
    border-color: color-mix(in srgb, var(--mv-text-secondary) 60%, var(--mv-border));
    background-color: var(--qms-field-hover);
}

/* The editor of a long text: a big box, as tall as its text (field-sizing) up to most of the screen, and the person can drag it. */
.qms-texts textarea[data-qms-markdown] {
    min-height: 14rem;
    max-height: 70vh;
    field-sizing: content;
    resize: vertical;
}

/* A test's parts are several boxes: each starts smaller and grows with its text. */
.qms-texts .qms-test-editor textarea[data-qms-markdown] {
    min-height: 5rem;
}

.qms-panel__more {
    margin: 4px 0 8px;
    color: var(--mv-text-secondary);
}

/* ---- The picker (qms_picker.js): a search box over the options, drawn as labels, avatars or status pills ---- */
.qms-picker {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.qms-picker__list {
    position: relative;
    max-height: 16rem;
    overflow-y: auto;
    padding: 2px 0;
}

.qms-picker__group-head {
    padding: 6px 8px 2px;
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
}

.qms-picker__option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: var(--mv-radius);
    cursor: pointer;
}

.qms-picker__option:hover,
.qms-picker__option--active {
    background-color: var(--qms-field-hover);
}

.qms-picker__option--active {
    outline: 1px solid color-mix(in srgb, var(--bs-primary) 50%, transparent);
    outline-offset: -1px;
}

.qms-picker__plain {
    color: var(--mv-text);
}

/* A single choice's tick, and a multiple choice's box: drawn, so they need no icon from a script that may not have run yet. */
.qms-picker__check,
.qms-picker__box {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.qms-picker__box {
    border: 1px solid var(--mv-text-secondary);
    border-radius: var(--mv-radius);
}

.qms-picker__option--chosen .qms-picker__box {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
}

.qms-picker__option--chosen .qms-picker__check::after,
.qms-picker__option--chosen .qms-picker__box::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid var(--bs-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.qms-picker__option--chosen .qms-picker__box::after {
    top: 1px;
    left: 4px;
    border-color: var(--bs-white);
}

.qms-picker__empty {
    margin: 0;
    padding: 4px 8px;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-sm);
}

.qms-cell__menu .qms-picker {
    width: min(20rem, 80vw);
}

@media (pointer: coarse) {
    .qms-picker__option {
        min-height: 44px;
    }
}

/* ---- A field's hint (values.FIELD_HINTS): an empty field says what it is for, muted and in italics so it never reads as its value;
   the same words are the editor's placeholder, which goes as soon as the box has the focus (a click on the hint opens the editor) ---- */
.qms-field__hint {
    color: var(--qms-muted-text);
    font-style: italic;
}

.qms-field:has([data-qms-edit]) .qms-field__hint {
    cursor: text;
}

.qms-field__editor ::placeholder,
.qms-check-row__text::placeholder {
    color: var(--qms-muted-text);
    font-style: italic;
    opacity: 1;
}

.qms-field__editor :focus::placeholder,
.qms-check-row__text:focus::placeholder {
    color: transparent;
}

/* ---- A select as a searchable combo (qms_picker.js buildCombo): a button that reads as the select did, opening the picker's search
   box and list in a box fixed under it (a table's overflow does not cut it). The native select stays in the form, visually hidden. ---- */
.qms-combo {
    min-width: 0;
}

.qms-combo__toggle {
    display: flex;
    align-items: center;
    min-width: 0;
    text-align: start;
}

.qms-combo__toggle > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qms-combo__empty {
    color: var(--qms-muted-text);
}

.qms-combo__pop {
    position: fixed;
    z-index: 1090;
    display: grid;
    gap: 4px;
    max-width: min(28rem, calc(100vw - 8px));
    padding: 6px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-surface);
    box-shadow: var(--mv-shadow-float);
}

.qms-picker__option--disabled {
    color: var(--qms-muted-text);
    cursor: not-allowed;
}

/* In a table cell (the release page's Impacted and Assignee): a quiet button that shows its frame only on hover or focus. */
.qms-combo--cell .qms-combo__toggle {
    border-color: transparent;
    background-color: transparent;
}

.qms-combo--cell .qms-combo__toggle:hover,
.qms-combo--cell .qms-combo__toggle:focus-visible,
.qms-combo--cell .qms-combo__toggle[aria-expanded="true"] {
    border-color: var(--mv-border);
}

@media (pointer: coarse) {
    .qms-combo__toggle {
        min-height: 44px;
    }
}

/* ---- A share's "Add documents" (qms_share_picker.js): a search box whose matches open under it as ticks, as ClickUp picks tags, and the
   documents picked listed below it, each with its version ---- */
.qms-share-find {
    position: relative;
    max-width: 48rem;
}

.qms-share-find__icon {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    color: var(--mv-text-secondary);
    transform: translateY(-50%);
    pointer-events: none;
}

.qms-share-find > .form-control {
    padding-left: 2.25rem;
}

.qms-share-find__pop {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 1050;
    padding: 6px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
    background-color: var(--mv-surface);
    box-shadow: var(--mv-shadow-float);
}

.qms-share-find__list {
    max-height: min(22rem, 55vh);
    overflow-y: auto;
}

.qms-share-find__text {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
}

/* A match's title and path wrap rather than being cut: two paths often differ only at their end (a version folder, a file name). */
.qms-share-find__title {
    overflow-wrap: anywhere;
}

.qms-share-find__path {
    color: var(--mv-text-secondary);
    font-size: var(--mv-fs-xs);
    overflow-wrap: anywhere;
}

.qms-share-find__meta {
    flex: 0 0 auto;
    color: var(--qms-muted-text);
    font-size: var(--mv-fs-xs);
}

.qms-share-picks {
    display: grid;
    gap: 6px;
    max-width: 48rem;
}

.qms-share-pick {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(10rem, 18rem) auto;
    gap: 8px 12px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--mv-border);
    border-radius: var(--mv-radius);
}

.qms-share-pick__icon {
    color: var(--mv-text-secondary);
}

.qms-share-pick__doc,
.qms-share-pick__version {
    min-width: 0;
}

@media (max-width: 575.98px) {
    .qms-share-pick {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .qms-share-pick__version {
        grid-column: 2 / 4;
        grid-row: 2;
    }
}

/* ---- The QMS's own utilities (the base rules every page wants, cards, card titles, code, tables, Select2, phones and workstations,
   are mvui's, 0.8.0) ---- */

/* A text kept as typed (an event's description, an audit's scope, a review action's outcome): its line breaks, and a long word
   breaks rather than widen the page. */
.qms-pre-wrap {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.qms-w-12rem {
    width: 12rem;
}

.qms-w-35 {
    width: 35%;
}

/* The external reviewers' pages (qms/external/base.html, on mvui's minimal page): the column each page keeps, the invite's QR code. */
.qms-mw-12rem {
    max-width: 12rem;
}

.qms-mw-26rem {
    max-width: 26rem;
}

.qms-mw-40rem {
    max-width: 40rem;
}

.qms-mw-72rem {
    max-width: 72rem;
}

.qms-totp-qr {
    display: block;
    width: 100%;
    height: auto;
}
