:root {
    --qap-primary: #00548e;
    --qap-tenant-primary: #0a6aa1;
    --qap-tenant-primary-light: #2f80af;
    --qap-secondary: #7aa4d3;
    --qap-accent: #2870a8;
    --qap-dark: #013759;
    --qap-text: #002c4a;
    --qap-muted: #6b7280;
    --qap-border: #d9dde1;
    --qap-bg-grey: #ececec;
    --qap-secondary-light: #f1f6fb;
    --qap-tables-grey: #e2eaf1;
    --qap-warn: #e9c31e;
    --qap-bright-blue: #3c91e3;

    /* ======= Z-index scale =======
       Single source of truth for stacking order. Mirrors Bootstrap 5's scale
       so .modal / .offcanvas / .dropdown-menu cooperate without overrides.
       Never write a raw z-index number — pick a token (or extend this list). */
    --z-base: 0;
    --z-sticky: 100;
    --z-map-overlay: 200;     /* deliberately LOW — map overlays must sit below dropdowns/modals */
    --z-dropdown-backdrop: 999;
    --z-dropdown: 1000;       /* Bootstrap default */
    --z-offcanvas-backdrop: 1040;
    --z-offcanvas: 1045;
    --z-modal-backdrop: 1050;
    --z-modal: 1055;
    --z-popover: 1070;
    --z-toast: 1090;
}

* { box-sizing: border-box; }

/* ============================================================================
   ONE root base. Everything else in this file is sized in `rem`, so this single
   declaration is the only "knob" that controls the overall scale of the UI
   (Bootstrap's rem base tracks it too).



   To rescale the WHOLE UI, change these %s (keep them proportional). Bootstrap's
   rem base tracks this too. The < 1600 step is the one to tune for normal laptops.
   ============================================================================ */
html { font-size: 71%; }                         
/* ~10.2px 64 */
@media (min-width: 1400px) { html { font-size: 71%; } }     /* ~11.2px 70 */
@media (min-width: 1600px) { html { font-size: 75%; } }     /* ~11.2px 70 */
@media (min-width: 2000px) { html { font-size: 85%; } }     /* ~12.5px 78 */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Lato', -apple-system, 'Segoe UI', Arial, sans-serif;
    color: var(--qap-text);
    background: var(--qap-bg-grey);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ======= Shell ======= */
.qap-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ======= Header ======= */
.qap-header {
    display: flex;
    align-items: stretch;
    background: var(--qap-tenant-primary);
    color: #fff;
    height: 5rem;
    flex-shrink: 0;
    padding-left: 1.7143rem;
}

.qap-header-btn {
    background: none;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0 1.1429rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5714rem;
    height: 100%;
    font-family: 'Lato', sans-serif;
}
.qap-header-btn:hover { background: rgba(255,255,255,0.06); }

.qap-toggle {
    font-size: 1.2857rem;
    padding: 0 1.1429rem 0 0;
    justify-content: flex-start;
}

.qap-header-sep {
    width: 0.0714rem;
    background: rgba(255,255,255,0.5);
    margin: 0.7143rem 0;
    align-self: stretch;
    flex-shrink: 0;
}

.qap-logo {
    display: flex;
    align-items: center;
    padding: 1.1429rem 1.1429rem 1.1429rem 0;
    min-width: 12.1429rem;
    overflow: visible;
}
.qap-logo img {
    max-height: 2.8571rem;
    height: 2.8571rem;
    display: block;
    object-fit: scale-down;
}

@media (min-width: 1400px) {
    .qap-logo { min-width: 22.8571rem; }
}

/* Tab nav yields first when the header is tight: it may shrink (and scroll as a
   last resort) so the right-side controls (user menu, language) are never clipped. */
.qap-tabs {
    display: flex;
    align-items: stretch;
    height: 100%;
    flex: 0 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.qap-tabs::-webkit-scrollbar { display: none; }
.qap-tab {
    display: flex;
    align-items: center;
    padding: 0 1.5714rem;
    font-size: 1.4286rem;
    font-weight: 400;
    color: rgba(255,255,255,0.95);
    height: 100%;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.qap-tab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.qap-tab.active {
    color: #fff;
    background: var(--qap-tenant-primary-light);
}

.qap-header-spacer { flex: 1; }

.qap-env-wrap { height: 100%; flex-shrink: 0; }
.qap-env {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    padding: 0.2857rem 1.1429rem;
    color: #fff;
    height: 100%;
    min-width: 11.4286rem;
}
.qap-env span { font-size: 1.4286rem; }

/* Hover-reveal scrollbar: thumb is transparent at rest and only tints on
   hover, so nothing about the track's width changes and there is no layout
   shift when the affordance appears. Reusable wherever a native scrollbar
   needs to survive but shouldn't look chunky (currently: the env dropdown).

   Deliberately -webkit- only. The standard properties (scrollbar-width /
   scrollbar-color) are NOT used, because when scrollbar-color is set Chrome
   >=121 switches to the standards path and ignores the rules below — and its
   scrollbar-width:thin is a browser-chosen thickness (~11px) rather than ours
   (~5px). Declaring both therefore makes the bar's thickness depend on the
   user's Chrome version. Sticking to -webkit- alone pins one identical
   thickness across Chrome/Edge/Safari on both Windows and macOS, which is the
   point: this replaces the platform-native bar (chunky and always-on on
   Windows, thin auto-hiding overlay on macOS) with one consistent treatment.
   Firefox falls back to its own native scrollbar, accepted as QAP is a
   Chrome-targeted internal tool. */
.qap-scroll-hover::-webkit-scrollbar {
    width: 0.4286rem;
}
.qap-scroll-hover::-webkit-scrollbar-track {
    background: transparent;
}
.qap-scroll-hover::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 0.2143rem;
    transition: background 0.15s ease;
}
.qap-scroll-hover:hover::-webkit-scrollbar-thumb {
    background: var(--qap-muted);
}

/* width: max-content + a bounded max-width auto-fits the menu to the longest
   environment name instead of clipping it at a fixed width; overflow-x:hidden
   is the other half of that fix — it guarantees a horizontal scrollbar can
   never appear even if some future content is wider than max-width allows.

   The rem base here is ~11.4px (html { font-size: 71% }, see top of file), so
   the old fixed 15.7143rem was only ~179px — about 6px short of the longest
   name ("Monitor Healthcare Limited"), which is precisely what produced the
   reported horizontal scrollbar. min-width is raised to give real breathing
   room rather than a hairline fit.

   scrollbar-gutter: stable matters more than it looks. max-content sizes the
   menu to its text, and a scrollbar that takes layout width then eats into
   that — with overflow-x hidden the longest name would be silently clipped
   rather than visibly overflowing. Reserving the gutter keeps the text box
   the same width whether the list scrolls or not. The .qap-scroll-hover bar
   above is ~5px on every platform, but the native bar this replaces was
   ~11-15px on Windows versus a zero-width overlay on macOS — that asymmetry
   is why the clipping would have shown up on Windows only, which is the one
   platform the bug was reported from. min-width leaves ~30px of slack over
   the longest current name so neither case is tight. */
.qap-tenant-menu {
    min-width: 19rem;
    width: max-content;
    max-width: min(90vw, 28.5714rem);
    scrollbar-gutter: stable;
    max-height: calc(100vh - 6.4286rem);
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 0;
    border-radius: 0.2857rem;
    box-shadow: 0 0.1429rem 0.5714rem rgba(0,0,0,0.18);
    padding: 0;
    margin-top: 0 !important;
}
/* Search row pinned to the top of the environment dropdown while the list
   below scrolls. Reuses .qap-env-search-input for the field itself.
   Explicit width: 100% guards this row so it keeps spanning the menu's
   resolved (now content-fit) width rather than shrinking to its own content,
   which would break the sticky header-bar look. */
.qap-tenant-search {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    width: 100%;
    padding: 0.7143rem 1.1429rem;
    color: var(--qap-muted);
    border-bottom: 0.0714rem solid var(--qap-border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.qap-tenant-item.dropdown-item {
    padding: 1rem 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 400;
    color: #000;
    min-height: 3.4286rem;
    display: flex;
    align-items: center;
}
.qap-tenant-item.dropdown-item:hover,
.qap-tenant-item.dropdown-item:focus {
    background: var(--qap-secondary-light);
    color: #000;
}
/* Selected environment (or "All environments" when unscoped). Overrides
   Bootstrap's default .dropdown-item.active — a bright non-palette blue — with
   the app's own selected-row treatment: the menu's light tint, a primary-blue
   bold label, and a left accent bar (same primary the filter list's selected
   row uses). The extra .active class outranks Bootstrap's .dropdown-item.active. */
.qap-tenant-item.dropdown-item.active,
.qap-tenant-item.dropdown-item.active:hover,
.qap-tenant-item.dropdown-item.active:focus {
    background: var(--qap-secondary-light);
    color: var(--qap-primary);
    font-weight: 700;
    box-shadow: inset 0.2143rem 0 0 var(--qap-primary);
}

/* ======= User profile dropdown ======= */
.qap-user-wrap { height: 100%; flex-shrink: 0; }
.qap-user-menu {
    min-width: 15.7143rem;
    background: #fff;
    border: 0;
    border-radius: 0.2857rem;
    box-shadow: 0 0.1429rem 0.5714rem rgba(0,0,0,0.18);
    padding: 0;
    margin-top: 0 !important;
}
.qap-user-info {
    padding: 1rem 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: #000;
    line-height: 1.4;
    white-space: nowrap;
}
.qap-user-info strong {
    font-weight: 700;
}
.qap-user-sep {
    margin: 0;
    border: 0;
    border-top: 0.0714rem solid rgba(0,0,0,0.08);
}
.qap-user-item.dropdown-item {
    padding: 1rem 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: #000;
    min-height: 3.4286rem;
    display: flex;
    align-items: center;
}
.qap-user-item.dropdown-item:hover,
.qap-user-item.dropdown-item:focus {
    background: var(--qap-secondary-light);
    color: #000;
}
.qap-user-section {
    padding: 0.7143rem 1.1429rem 0.2857rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.7857rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(0,0,0,0.45);
}
.qap-user-toggle {
    width: 100%;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}
.qap-switch {
    margin-left: auto;
    flex: 0 0 auto;
    position: relative;
    width: 2.7143rem;
    height: 1.4286rem;
    border-radius: 71.3571rem;
    background: rgba(0,0,0,0.2);
    transition: background 0.18s ease;
}
.qap-switch.on {
    background: var(--qap-tenant-primary, #0a6aa1);
}
.qap-switch-knob {
    position: absolute;
    top: 0.1429rem;
    left: 0.1429rem;
    width: 1.1429rem;
    height: 1.1429rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0.0714rem 0.1429rem rgba(0,0,0,0.3);
    transition: transform 0.18s ease;
}
.qap-switch.on .qap-switch-knob {
    transform: translateX(1.2857rem);
}

/* ======= Language dropdown ======= */
.qap-lang-wrap { height: 100%; flex-shrink: 0; }
.qap-lang-menu {
    width: 15.7143rem;
    background: #fff;
    border: 0;
    border-radius: 0.2857rem;
    box-shadow: 0 0.1429rem 0.5714rem rgba(0,0,0,0.18);
    padding: 0;
    margin-top: 0 !important;
}
.qap-lang-item.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.5714rem 1.1429rem;
    min-height: 3.4286rem;
    font-family: 'Lato', sans-serif;
    color: #000;
}
.qap-lang-item.dropdown-item:hover,
.qap-lang-item.dropdown-item:focus {
    background: var(--qap-secondary-light);
    color: #000;
}
.qap-lang-code {
    min-width: 2.5714rem;
    font-size: 1.1429rem;
    font-weight: 700;
    text-transform: uppercase;
}
.qap-lang-name {
    font-size: 1.1429rem;
    font-weight: 400;
}

.qap-user {
    flex-direction: column;
    gap: 0.2857rem;
    padding: 0.2857rem 1.7143rem;
    min-width: 0;
}
.qap-user .qap-avatar {
    font-size: 1.5714rem;
    width: 1.7857rem;
    height: 1.7857rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
}
.qap-user small {
    font-size: 0.7857rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.0214rem;
    color: #fff;
    white-space: nowrap;
}

.qap-lang {
    font-size: 1rem;
    font-weight: 500;
    padding: 0 1.1429rem;
    letter-spacing: 0.0357rem;
}

/* ======= Offcanvas z-index — uses Bootstrap's native layer via token.
   Scoped to < lg, i.e. only while these panels are ACTUAL offcanvas overlays.
   On desktop the KPI drawer is an in-flow panel (position: relative) and the
   home filter panel is a map overlay (z-index 200). Applying the offcanvas
   z-index there turned .qap-drawer into a stacking context (position:relative +
   z-index) capped at --z-offcanvas, which trapped fixed modals/backdrops opened
   from inside it (e.g. the KPI definition modal) below the map filter panel. */
@media (max-width: 991.98px) {
    .qap-drawer.offcanvas-lg,
    .qap-overlay-filter.offcanvas-lg {
        z-index: var(--z-offcanvas);
    }
}
.offcanvas-backdrop { z-index: var(--z-offcanvas-backdrop); }

/* ======= Mobile nav drawer =======
   Native Popover API (not Bootstrap offcanvas): renders in the browser top
   layer, so no z-index juggling and no shared backdrop that can strand another
   drawer. Full-height panel sliding in from the left; entry animates via
   @starting-style, close is instant (same approach as .qap-modal). */
.qap-nav-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    margin: 0;
    width: min(94vw, 28rem);
    height: 100%;
    max-height: none;
    padding: 0;
    border: 0;
    background: #fff;
    color: var(--qap-text);
    box-shadow: 0.2857rem 0 1.4286rem rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    transform: translateX(-100%);
    font-family: 'Lato', sans-serif;
}
.qap-nav-drawer:popover-open { transform: translateX(0); }
.qap-nav-drawer::backdrop { background: rgba(15, 23, 42, 0.45); }
@media (prefers-reduced-motion: no-preference) {
    .qap-nav-drawer { transition: transform 200ms ease; }
    @starting-style {
        .qap-nav-drawer:popover-open { transform: translateX(-100%); }
    }
}
.qap-nav-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8571rem;
    height: 5rem;
    padding: 0 1.4286rem;
    background: var(--qap-primary);
    color: #fff;
}
.qap-nav-drawer-title {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 500;
}
.qap-nav-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5714rem;
    height: 2.5714rem;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.2857rem;
    cursor: pointer;
    border-radius: 0.2857rem;
}
.qap-nav-drawer-close:hover { background: rgba(255, 255, 255, 0.12); }
.qap-nav-mobile { display: flex; flex-direction: column; padding: 0; }
/* Collapsible environment switcher inside the mobile drawer. Circuit-free: a
   hidden checkbox toggles the list open via :has() (same pattern as the KPI
   drawer); an inline component script filters the list as you type. A grey band
   separates it from the page-navigation links above. */
.qap-nav-env { border-top: 0.5714rem solid var(--qap-bg-grey); }
.qap-nav-env-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8571rem;
    cursor: pointer;
}
/* Keep "Current environment: <name>" on one line; ellipsis only if a name is
   unusually long. */
.qap-nav-env-current > span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qap-nav-env-caret { flex: none; }
.qap-nav-env-caret { color: var(--qap-muted); font-size: 0.9286rem; transition: transform 150ms ease; }
.qap-nav-env:has(.qap-nav-env-toggle:checked) .qap-nav-env-caret { transform: rotate(180deg); }
.qap-nav-env-list { display: none; }
.qap-nav-env:has(.qap-nav-env-toggle:checked) .qap-nav-env-list { display: block; }
.qap-nav-env-search {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.8571rem 1.4286rem;
    color: var(--qap-muted);
    border-bottom: 0.0714rem solid var(--qap-border);
}
/* Shared by the mobile drawer search and the desktop dropdown search. */
.qap-env-search-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 1.0714rem;
    color: var(--qap-text);
}
/* Keyboard highlight (arrow keys) over the filtered list — the row Enter picks.
   Sits on the option (mobile <a>, desktop <li>); the desktop link is transparent
   so the row tint shows through. A touch stronger than hover, and with a left
   accent bar, so it reads clearly as the active target even beside the selected
   row (same tenant-blue tint the filter list uses for its selected row). */
.qap-env-highlight {
    background: rgba(10, 106, 161, 0.12);
    box-shadow: inset 0.2143rem 0 0 var(--qap-tenant-primary);
}
.qap-nav-mobile-link {
    display: block;
    padding: 1.1429rem 1.4286rem;
    color: var(--qap-text);
    border-bottom: 0.0714rem solid var(--qap-border);
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 400;
}
.qap-nav-mobile-link:hover { background: var(--qap-secondary-light); }
.qap-nav-mobile-link.active {
    background: var(--qap-secondary-light);
    color: var(--qap-primary);
    font-weight: 700;
    border-left: 0.2143rem solid var(--qap-primary);
    padding-left: 1.2143rem;
}

/* ======= Body ======= */
.qap-body {
    flex: 1;
    min-height: 0;
    display: flex;
}
.qap-body-content {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    background: var(--qap-bg-grey);
    display: flex;
    flex-direction: column;
}

.qap-page {
    display: flex;
    height: 100%;
    flex: 1;
}

/* ======= Drawer (KPI panel) ======= */
.qap-drawer {
    width: 22.8571rem;
    flex-shrink: 0;
    background-color: #fff !important;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Desktop drawer show/hide driven by the #qap-kpi-drawer-open checkbox (no JS).
   The reopen tab is hidden while the drawer is open and revealed when closed. */
.qap-drawer-reopen, .qap-drawer-reopen-sep { display: none; }
@media (min-width: 992px) {
    .qap-shell:has(.qap-drawer-toggle:not(:checked)) .qap-drawer { display: none; }
    .qap-shell:has(.qap-drawer-toggle:not(:checked)) .qap-drawer-reopen { display: flex; }
    .qap-shell:has(.qap-drawer-toggle:not(:checked)) .qap-drawer-reopen-sep { display: block; }
}

@media (max-width: 991.98px) {
    .qap-drawer.offcanvas-lg {
        position: fixed !important;
        top: 0; left: 0; bottom: 0;
        width: min(86vw, 25.7143rem) !important;
        height: 100% !important;
        flex-shrink: 1 !important;
    }
}

.qap-drawer-close {
    position: absolute;
    top: 0; right: 0;
    background: none;
    border: 0;
    color: var(--qap-primary);
    cursor: pointer;
    width: 4rem; height: 4rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2857rem;
    z-index: 1;
}
.qap-drawer-close:hover { background: rgba(0,0,0,0.04); }

.qap-drawer-title {
    display: flex;
    align-items: center;
    margin-top: 1.1429rem;
    padding: 0 1.1429rem 0.5714rem;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    font-size: 1.4286rem;
    color: var(--qap-text);
    height: 2.8571rem;
}
.qap-drawer-title i {
    font-size: 2.2857rem;
    color: var(--qap-secondary);
    padding-right: 1.1429rem;
}

/* ======= KPI list ======= */
.qap-kpi-list {
    margin: 0;
    padding: 0;
}

.qap-kpi-section + .qap-kpi-section { border-top: 0.0714rem solid rgba(0, 0, 0, 0.12); }

.qap-kpi-section-head {
    display: flex;
    align-items: center;
    width: 100%;
    background: #fff;
    border: 0;
    outline: 0;
    padding: 1.1429rem;
    margin: 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 700;
    color: var(--qap-text);
    cursor: pointer;
    text-align: left;
    line-height: 1.4;
}
.qap-kpi-section-head:focus-visible { outline: 0.1429rem solid var(--qap-primary); outline-offset: -0.1429rem; }
.qap-kpi-section-head { gap: 0.5714rem; }
.qap-kpi-section-head > span { flex: 1; }
.qap-kpi-section-sub {
    font-size: 1rem;
    font-weight: 400;
    color: var(--qap-muted);
    margin-left: 0.2857rem;
}
/* Explanation inside an open section (period, "static", …) — kept out of the header. */
.qap-kpi-section-note {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    /* Same horizontal inset as .qap-kpi-item, so it lines up with the rows below. */
    margin: 0.1429rem 1.1429rem 0.4286rem;
    padding: 0.4286rem 0.7143rem;
    border-radius: 0.4286rem;
    background: rgba(0, 84, 142, 0.06);
    color: var(--qap-muted);
    font-size: 0.8571rem;
    line-height: 1.4;
}
.qap-kpi-section-note > i { color: var(--qap-primary); opacity: 0.7; }
.qap-kpi-section-head > i {
    font-size: 1.4286rem;
    color: var(--qap-text);
    transition: transform 120ms ease;
}
/* <summary> native disclosure: drop the default marker, point the chevron up
   when the section is open. */
.qap-kpi-section-head { list-style: none; }
.qap-kpi-section-head::-webkit-details-marker { display: none; }
.qap-kpi-section[open] > .qap-kpi-section-head > i { transform: rotate(180deg); }

.qap-kpi-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.2857rem 1.1429rem;
    min-height: 2.2857rem;
}
.qap-kpi-item > i {
    color: var(--qap-secondary);
    font-size: 1.7143rem;
    flex-shrink: 0;
}
/* When a drawer row's info icon is wrapped in .qap-tip (for the hover
   tooltip), keep the icon at the drawer's size/spacing — the shared .qap-tip
   rules size it for the smaller KPI-tile icon. */
.qap-kpi-item > .qap-tip {
    flex-shrink: 0;
    margin-right: 0;
}
.qap-kpi-item > .qap-tip > i,
.qap-kpi-item > .qap-tip > .qap-tip-btn > i {
    font-size: 1.7143rem;
}
.qap-kpi-label {
    flex: 1;
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 1.2857rem;
    color: var(--qap-text);
    line-height: 1.9286rem;
}
.qap-kpi-value {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 1.2857rem;
    color: var(--qap-text);
}

/* ======= Map area ======= */
.qap-map-area {
    flex: 1;
    position: relative;
    min-width: 0;
    background: #cfe6f5;
    overflow: hidden;
}

.qap-map-bg {
    position: absolute; inset: 0;
}

.qap-map-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: rgba(0,0,0,0.32);
    pointer-events: none;
}
.qap-map-placeholder i { font-size: 4.5714rem; margin-bottom: 0.8571rem; }
.qap-map-placeholder p { font-size: 1rem; margin: 0; }
.qap-map-placeholder .spinner-border {
    color: var(--qap-tenant-primary, #0a6aa1);
    border-width: 0.1429rem;
    margin-bottom: 0.7143rem;
}

.qap-pulse-loader {
    width: 12.8571rem;
    height: 3.4286rem;
    margin-bottom: 0.4286rem;
    display: block;
}
.qap-pulse-loader path {
    fill: none;
    stroke: var(--qap-tenant-primary);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: qap-heartbeat 1.4s ease-out infinite;
}
@keyframes qap-heartbeat {
    0%   { stroke-dashoffset: 400; }
    50%  { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -400; }
}
@media (prefers-reduced-motion: reduce) {
    .qap-pulse-loader path { animation: none; stroke-dashoffset: 0; }
}

.qap-map-refresh {
    position: absolute;
    top: 1.1429rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: center;
    gap: 0.5714rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.4286rem 1rem;
    border-radius: 71.3571rem;
    box-shadow: 0 0.1429rem 0.4286rem rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.65);
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    z-index: var(--z-toast);
    pointer-events: none;
    animation: qap-map-refresh-in 160ms ease-out;
}
.qap-map-refresh .spinner-border {
    color: var(--qap-tenant-primary, #0a6aa1);
}
@keyframes qap-map-refresh-in {
    from { opacity: 0; transform: translate(-50%, -0.2857rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Global "Refreshing…" indicator — same transient-overlay card treatment as
   .qap-notice below (white card, bordered, tenant-coloured left accent),
   pinned to the viewport so it floats over whatever page is currently
   mounted (map, charts, scope table, …). Top offset (6.1429rem) clears the
   5rem header + 1.1429rem breathing room. Centered horizontally on the entire
   viewport — close enough to the content centre to read as anchored to it. */
.qap-global-refresh {
    position: fixed;
    top: 6.1429rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: center;
    gap: 0.7143rem;
    background: #fff;
    border: 0.0714rem solid var(--qap-border);
    border-left: 0.2857rem solid var(--qap-tenant-primary);
    padding: 0.7143rem 1.1429rem;
    border-radius: 0.5714rem;
    box-shadow: 0 0.1429rem 0.4286rem rgba(0, 0, 0, 0.15);
    color: var(--qap-text);
    font-size: 1rem;
    line-height: 1.4;
    z-index: var(--z-toast);
    pointer-events: none;
    animation: qap-map-refresh-in 160ms ease-out;
}
.qap-global-refresh .spinner-border {
    color: var(--qap-tenant-primary, #0a6aa1);
}
/* Always rendered, toggled via the native [hidden] attribute (qap-loading.js
   flips it on any user-initiated navigation — link clicks, full reloads,
   filter Apply, Refresh data — not just filter submits; see MainLayout.razor).
   The rule above sets an explicit "display" that would otherwise win over the
   browser's default [hidden] rule, so restate it here, same pattern as the
   filter tree's own [hidden] rows above. */
.qap-global-refresh[hidden] { display: none; }

/* Transient info notice (e.g. not-yet-supported actions). Sits below the
   header like the refresh pill so it never overlaps the nav tabs. */
.qap-notice {
    position: fixed;
    top: 6.1429rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.7143rem;
    max-width: min(45.7143rem, 92vw);
    background: #fff;
    color: var(--qap-text);
    border: 0.0714rem solid var(--qap-border);
    border-left: 0.2857rem solid var(--qap-tenant-primary);
    padding: 0.7143rem 1rem;
    border-radius: 0.5714rem;
    box-shadow: 0 0.1429rem 0.4286rem rgba(0, 0, 0, 0.15);
    font-family: 'Lato', -apple-system, 'Segoe UI', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.4;
    z-index: var(--z-toast);
    animation: qap-map-refresh-in 160ms ease-out;
}
.qap-notice > i {
    color: var(--qap-tenant-primary);
    font-size: 1.0714rem;
}
.qap-notice-close {
    border: none;
    background: none;
    color: var(--qap-muted);
    cursor: pointer;
    padding: 0 0.1429rem;
    line-height: 1;
    font-size: 1rem;
}
.qap-notice-close:hover { color: var(--qap-text); }

/* Circuit-free dismiss: a hidden checkbox (id keyed by route code, so each
   scoped environment gets its own dismiss state) paired with a <label> close
   button. Same :has() primitive as the KPI drawer toggle above — no JS. */
.qap-shell:has(.qap-notice-toggle:checked) .qap-notice { display: none; }

/* Empty-state shown when a chart's envelope has no rows / all zero values.
   Same vertical footprint as the chart it replaces so toggling between
   "has data" and "no data" doesn't reflow the card. */
.qap-chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.7143rem;
    color: var(--qap-text);
    padding: 1.7143rem;
}
.qap-chart-empty-icon {
    font-size: 3.1429rem;
    color: rgba(10, 106, 161, 0.25);
    margin-bottom: 0.4286rem;
}
.qap-chart-empty-title {
    margin: 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 600;
    color: var(--qap-primary);
}
.qap-unavailable .qap-chart-empty-icon { color: rgba(0, 0, 0, 0.25); }
.qap-unavailable-retry {
    display: inline-flex;
    align-items: center;
    height: 2.8571rem;
    padding: 0 1.4286rem;
    margin-top: 0.4286rem;
    border-radius: 0.2857rem;
    background: var(--qap-primary);
    color: #fff;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 700;
    text-decoration: none;
}
.qap-unavailable-retry:hover { color: #fff; filter: brightness(0.95); }
.qap-chart-empty-hint {
    margin: 0;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    color: rgba(0, 0, 0, 0.55);
    max-width: 25.7143rem;
}

/* ======= Find overlay ======= */
.qap-overlay-find {
    position: absolute;
    top: 0.7143rem;
    left: 0.7143rem;
    width: 29.4286rem;
    z-index: var(--z-map-overlay);
}

.qap-find {
    width: 100%;
    background: #fff;
    border: 0;
    border-radius: 0.2143rem;
    box-shadow: 0 0.0714rem 0.1429rem rgba(0,0,0,0.1);
    color: var(--qap-text);
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 1.1429rem;
    height: 3.7143rem;
    cursor: pointer;
}
.qap-find:hover { background: #fafbfc; }
/* Selected-facility pill: same shell as the unselected button, but it's a
   <div> instead of a <button> — the only clickable child is the X. Override
   the hover/cursor so the whole pill doesn't read as clickable. */
.qap-find-selected { cursor: default; }
.qap-find-selected:hover { background: #fff; }
/* Search-in-flight cue for the "Find a facility" input (htmx fragment GET,
   hx-indicator="#qap-find-icon, #qap-find-results" — see Home.razor). The
   input fires on every keystroke (keyup changed delay:150ms), so this must
   not strobe: the hospital icon and the spinner are stacked in the same grid
   cell and only OPACITY/VISIBILITY are transitioned — never `display`, which
   would apply instantly and defeat the transition-delay below (verified:
   toggling `display` alongside `opacity` made the spinner flash on every
   keystroke even against a fast local network). transition-delay only
   reveals the spinner once a request has actually been in flight for a beat,
   matching the 200ms show-delay qap-loading.js uses for full-page
   navigation. Swapping this icon (rather than only dimming #qap-find-results
   below) is what covers the very first search, when the results list is
   still empty and has nothing to dim. */
.qap-find-icon {
    width: 1.7857rem;
    display: grid;
    grid-template-areas: "icon";
    place-items: center;
    color: var(--qap-primary);
    font-size: 1.5714rem;
    flex-shrink: 0;
}
.qap-find-icon > * { grid-area: icon; }
.qap-find-icon .fa-hospital,
.qap-find-icon-spinner {
    transition: opacity 0.15s ease 0.2s, visibility 0.15s ease 0.2s;
}
.qap-find-icon-spinner {
    opacity: 0;
    visibility: hidden;
}
#qap-find-icon.htmx-request .fa-hospital {
    opacity: 0;
    visibility: hidden;
}
#qap-find-icon.htmx-request .qap-find-icon-spinner {
    opacity: 1;
    visibility: visible;
}
.qap-find-label {
    flex: 1;
    text-align: left;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    font-size: 1.4286rem;
    color: var(--qap-text);
}
.qap-find-search {
    color: var(--qap-text);
    font-size: 1.4286rem;
    flex-shrink: 0;
}

/* Expanded find state */
.qap-overlay-find.expanded {
    width: 29.4286rem;
    max-height: calc(100% - 4.2857rem);
    background: #fff;
    border-radius: 0.2143rem;
    box-shadow: 0 0.0714rem 0.1429rem rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

/* Static-SSR find states — all three markers live in the DOM; qap-find.js
   toggles .expanded / .has-selection on .qap-overlay-find to pick which shows.
   Default (collapsed, no selection) = the trigger button only. */
.qap-overlay-find .qap-find-input-row,
.qap-overlay-find #qap-find-results,
.qap-overlay-find .qap-find-selected { display: none; }
.qap-overlay-find.expanded .qap-find-input-row { display: flex; }
.qap-overlay-find.expanded #qap-find-results { display: block; }
.qap-overlay-find.expanded .qap-find-trigger { display: none; }
.qap-overlay-find.has-selection:not(.expanded) .qap-find-trigger { display: none; }
.qap-overlay-find.has-selection:not(.expanded) .qap-find-selected { display: flex; }

.qap-find-input-row {
    width: 100%;
    background: #fff;
    border: 0;
    border-bottom: 0.0714rem solid rgba(0,0,0,0.12);
    border-radius: 0.2143rem 0.2143rem 0 0;
    box-shadow: none;
    color: var(--qap-text);
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 1.1429rem;
    height: 3.7143rem;
}
.qap-find-input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 500;
    color: var(--qap-text);
    padding: 0;
}
.qap-find-clear {
    background: none;
    border: 0;
    padding: 0;
    color: var(--qap-text);
    font-size: 1.5714rem;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 0;
}
.qap-find-clear:hover { color: var(--qap-primary); }

.qap-find-results {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    border-radius: 0 0 0.2143rem 0.2143rem;
}
/* Dim stale hits while a later keystroke's search is in flight (empty on the
   very first search — see .qap-find-icon-spinner above for that case).
   Delayed the same way so a fast response never flashes it. */
#qap-find-results.htmx-request {
    opacity: 0.55;
    transition: opacity 0.15s ease 0.2s;
}
/* Shared search-result row primitive: bold name + muted secondary line, used
   by both the home page "Find a facility" picker (.qap-find-result) and the
   shared filter panel's Facilities typeahead (.qap-filter-facility-result,
   below near the rest of the filter panel rules) — these were two
   near-identical class sets duplicating the same name/loc typography.
   Consolidated here; each call site still carries its own thin modifier for
   the couple of properties that are genuinely different (row padding/gap/
   divider tint, name color/truncation, trailing icon treatment) so both keep
   rendering exactly as they did as standalone class sets. */
.qap-search-result {
    width: 100%;
    background: #fff;
    border: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
    text-align: left;
    font-family: 'Lato', sans-serif;
}
.qap-search-result:hover { background: var(--qap-secondary-light); }
.qap-search-result-text { flex: 1; min-width: 0; }
.qap-search-result-name {
    font-size: 1.1429rem;
    font-weight: 700;
}
.qap-search-result-loc {
    font-size: 1rem;
    font-weight: 400;
    color: var(--qap-muted);
    margin-top: 0.1429rem;
}

/* Home picker modifier — original .qap-find-result standalone spacing/divider/
   name-color values, now layered on top of .qap-search-result. */
.qap-find-result {
    gap: 0.8571rem;
    padding: 0.7143rem 1.1429rem;
    border-bottom: 0.0714rem solid rgba(0,0,0,0.12);
    color: #000;
}
.qap-find-result-name {
    color: #000;
    line-height: 1.25;
}
.qap-find-result-arrow {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 0.0714rem solid var(--qap-secondary);
    color: var(--qap-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9286rem;
    flex-shrink: 0;
}
.qap-find-empty {
    padding: 1.4286rem 1.1429rem;
    color: var(--qap-muted);
    text-align: center;
    font-size: 1.0714rem;
}

/* Hide filters when find is expanded */
.qap-map-area.find-open .qap-overlay-filter {
    display: none;
}

/* ======= Filter overlay ======= */
.qap-overlay-filter {
    position: absolute;
    top: 5.1429rem;
    left: 0.7143rem;
    width: 29.4286rem;
    background: #fff;
    border-radius: 0.2143rem;
    box-shadow: 0 0.0714rem 0.1429rem rgba(0,0,0,0.1);
    color: var(--qap-text);
    z-index: var(--z-map-overlay);
    /* Leave clearance at the bottom so the panel never reaches down into the
       legend (bottom-left), even if the legend wraps to two rows. */
    max-height: calc(100% - 9.4286rem);
    overflow-y: auto;
}

@media (max-width: 991.98px) {
    .qap-overlay-filter.offcanvas-lg {
        position: fixed;
        top: auto;
        max-height: 100%;
        width: min(86vw, 29.4286rem) !important;
        height: 100% !important;
        border-radius: 0;
    }
}

/* Structural-only wrapper: exists so :has() can scope the collapse checkbox to
   this panel, without adding a layout box that would disturb the offcanvas
   flex/scroll (header + body lay out as before). */
.qap-filter { display: contents; }

.qap-filter-head {
    width: 100%;
    background: #fff;
    border-bottom: 0.0714rem solid var(--qap-border);
    display: flex;
    align-items: stretch;
    font-family: 'Lato', sans-serif;
}
/* The whole row (minus the ×) is a <label> for the collapse checkbox. */
.qap-filter-head-toggle {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 1.1429rem;
    height: 3.4286rem;
    background: none;
    border: 0;
    color: var(--qap-text);
    cursor: pointer;
}
/* Collapse: CSS :has() on the checkbox — no JS. Chevron points up when open. */
.qap-filter-chev i { transition: transform 120ms ease; }
.qap-filter:has(.qap-filter-open-state:checked) .qap-filter-chev i { transform: rotate(180deg); }
.qap-filter:has(.qap-filter-open-state:not(:checked)) .qap-filter-body { display: none; }
.qap-filter-icon {
    width: 1.7857rem;
    display: flex; align-items: center; justify-content: center;
    color: var(--qap-primary);
    font-size: 1.5714rem;
    flex-shrink: 0;
}
.qap-filter-label {
    font-weight: 500;
    font-size: 1.4286rem;
}
/* Header's "( N Active )" count. Was .qap-filter-active, which collided with
   the Active filter ROW of the same class further down — same specificity, so
   this rule's colour/margin/weight leaked into the rows and painted their
   labels --qap-secondary while every other label in the panel is --qap-text. */
.qap-filter-active-count {
    margin-left: auto;
    font-weight: 400;
    font-size: 1.1429rem;
    color: var(--qap-secondary);
}
.qap-filter-chev {
    color: var(--qap-text);
    font-size: 1.2857rem;
    margin-left: 0.5714rem;
}

/* Filter rows */
.qap-filter-row { background: #fff; border-top: 0.0714rem solid rgba(0,0,0,0.12); }
.qap-filter-row:first-child { border-top: 0; }
.qap-filter-row.open .qap-filter-row-head { background: #fff; }
.qap-filter-row.open + .qap-filter-row { border-top: 0.0714rem solid rgba(0,0,0,0.12); }
.qap-filter-row-head {
    width: 100%;
    background: #fff;
    border: 0;
    color: var(--qap-text);
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 1.1429rem;
    height: 4.5714rem;
    cursor: pointer;
    text-align: left;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 400;
}
.qap-filter-row-head > span:first-child { flex: 1; }
.qap-filter-row-head > i { color: var(--qap-text); font-size: 1.1429rem; }
.qap-filter-row-badge {
    background: var(--qap-primary);
    color: #fff;
    border-radius: 0.2143rem;
    padding: 0.1429rem 0.5714rem;
    font-size: 1rem;
    font-weight: 700;
    min-width: 1.7143rem;
    text-align: center;
}
.qap-filter-row-body { padding: 0.2857rem 1.1429rem 1rem; background: #fff; }

.qap-filter-tree { list-style: none; padding: 0; margin: 0; }
.qap-filter-tree li {
    display: flex;
    align-items: center;
    gap: 0.2857rem;
    padding: 0;
    min-height: 2rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 400;
    color: var(--qap-text);
}
.qap-filter-tree li > i {
    color: rgb(158, 158, 158);
    font-size: 1.1429rem;
    width: 1.1429rem;
    text-align: center;
    flex-shrink: 0;
}
.qap-filter-tree input[type="checkbox"] {
    accent-color: var(--qap-primary);
    width: 1.4286rem;
    height: 1.4286rem;
    margin: 0 0.2857rem 0 0;
    flex-shrink: 0;
}
.qap-filter-tree-caret {
    background: transparent;
    border: 0;
    padding: 0;
    width: 1.1429rem;
    height: 1.1429rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgb(158, 158, 158);
    font-size: 1.1429rem;
    flex-shrink: 0;
}
.qap-filter-tree-caret[disabled] {
    cursor: default;
    visibility: hidden;
}
.qap-filter-tree .qap-filter-count {
    color: rgba(0, 0, 0, 0.45);
    font-size: 1rem;
    margin-left: auto;
    padding-left: 0.5714rem;
}
.qap-filter-empty {
    padding: 0.5714rem 0 0.2857rem;
    color: rgba(0, 0, 0, 0.45);
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
}
.qap-filter-subtitle {
    padding: 0 0 0.4286rem;
    color: rgba(0, 0, 0, 0.55);
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    line-height: 1.35;
}
.qap-filter-tree-group {
    display: flex;
    align-items: center;
    gap: 0.4286rem;
}
/* Count of selected children, shown next to a group's label (e.g. "Onsite -
   Regular  [2]"). Compact mirror of .qap-filter-row-badge so it matches the
   section-header badge. Sits right after the title, not pushed to the edge. */
.qap-filter-tree-badge {
    flex-shrink: 0;
    background: var(--qap-primary);
    color: #fff;
    border-radius: 0.2143rem;
    padding: 0 0.4286rem;
    min-width: 1.4286rem;
    height: 1.4286rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8571rem;
    font-weight: 700;
}
.qap-filter-tree li.qap-filter-tree-child {
    padding: 0.2143rem 0 0.2143rem 3.4286rem;
    min-height: 2.2857rem;
    color: rgba(0, 0, 0, 0.7);
}

/* Static-SSR tree: the group wrapper stacks its header row + children column
   (overrides the flex-row .qap-filter-tree li default). Children collapse under
   the caret but stay in the DOM so the native form still submits them. */
.qap-filter-tree > li.qap-filter-tree-group-wrap {
    display: block;
    min-height: 0;
}
.qap-filter-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}
.qap-filter-tree-group-wrap.collapsed .qap-filter-tree-children { display: none; }
/* Client-side narrowing (qap-filter.js) hides rows via the native [hidden]
   attribute; both selectors above set an explicit "display" that would
   otherwise win over the browser's default [hidden] rule, so restate it here. */
.qap-filter-tree-group-wrap[hidden],
.qap-filter-tree li.qap-filter-tree-child[hidden] { display: none; }
.qap-filter-tree-group-wrap:not(.collapsed) > .qap-filter-tree-group .qap-filter-tree-caret {
    transform: rotate(90deg);
}
.qap-filter-scope[hidden] { display: none; }

/* Facility-active row: a single Yes toggle with an inline date pill that
   reveals once the toggle is on. Native date input is layered transparently
   over the styled button so the OS picker fires on click but the user sees
   the app's typography. */
/* Active filter rows (facility + assessment tabs). Font stack, size and colour
   deliberately mirror .qap-filter-tree li so these labels read identically to
   every checkbox label in the panel — they sit in the same
   .qap-filter-tree-item-label wrapper. */
.qap-filter-active {
    display: flex;
    flex-direction: column;
    gap: 0.5714rem;
    padding: 0.2857rem 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 400;
    color: var(--qap-text);
}
.qap-filter-active input[type="checkbox"],
.qap-filter-active input[type="radio"] {
    accent-color: var(--qap-primary);
    width: 1.4286rem;
    height: 1.4286rem;
    margin: 0 0.2857rem 0 0;
    flex-shrink: 0;
}

/* The Active row's three options are radios (exclusive by nature — a facility
   is on one side of the gate at a given date), but every other control in this
   panel is a FilterCheckboxTree checkbox. Painted as squares so the row doesn't
   read as a foreign widget. Hand-drawn rather than accent-color because
   accent-color can only tint the native circle, not reshape it. Tracks
   .qap-filter-tree input[type="checkbox"] above — keep the two in step. */
.qap-filter-active input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    border: 0.1429rem solid rgba(0, 0, 0, 0.4);
    border-radius: 0.2143rem;
    background: #fff;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
}
.qap-filter-active input[type="radio"]:checked {
    background: var(--qap-primary);
    border-color: var(--qap-primary);
}
/* Same tick a native accent-color checkbox draws: two borders of an empty box,
   rotated into a check. */
.qap-filter-active input[type="radio"]:checked::before {
    content: "";
    width: 0.7143rem;
    height: 0.3571rem;
    border-left: 0.1429rem solid #fff;
    border-bottom: 0.1429rem solid #fff;
    transform: translateY(-0.0714rem) rotate(-45deg);
}
.qap-filter-active input[type="radio"]:focus-visible {
    outline: 0.1429rem solid var(--qap-primary);
    outline-offset: 0.1429rem;
}
.qap-filter-active-aside {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5714rem;
    padding-left: 2rem; /* line up with checkbox label text */
    color: rgba(0, 0, 0, 0.65);
    font-size: 1rem;
}
.qap-filter-active-as-of { color: rgba(0, 0, 0, 0.6); }

/* "All facilities" selected: the as-of date has no effect, so mute it rather
   than disable it. A disabled input is not posted at all, which would drop the
   user's chosen date from the form instead of merely leaving it unused — they
   would lose it on every round trip through All. pointer-events stays on so the
   picker is still reachable if they set a date before picking a side. */
.qap-filter-active-aside.is-muted {
    opacity: 0.45;
}

.qap-filter-active-date-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    padding: 0.2857rem 0.7143rem;
    border: 0.0714rem solid rgba(0, 0, 0, 0.15);
    border-radius: 71.3571rem;
    background: #fff;
    color: rgba(0, 0, 0, 0.8);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 120ms ease;
}
.qap-filter-active-date-button:hover {
    border-color: var(--qap-primary);
}
.qap-filter-active-date-button i {
    color: var(--qap-primary);
    font-size: 0.9286rem;
}
.qap-filter-active-date-text {
    line-height: 1;
}
.qap-filter-active-date-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    /* Stretch the native control over the pill so the picker opens on click
       — but visually we render our own text + icon above. The native input
       still owns keyboard focus and accessibility. */
    color: transparent;
    border: 0;
    padding: 0;
    background: transparent;
}
.qap-filter-active-today {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0.2857rem 0.5714rem;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.2857rem;
}
.qap-filter-active-today:hover {
    background: rgba(10, 106, 161, 0.08);
}

/* Period row: row of preset chips + two date pills + an optional hint
   underneath. Chips re-use the same pill geometry as the active-date
   button but are smaller and rendered with a flat background so they
   read as quick-picks rather than primary actions. */
.qap-filter-period {
    display: flex;
    flex-direction: column;
    gap: 0.7143rem;
    padding: 0.2857rem 0;
    font-family: 'Lato', sans-serif;
}
/* Tiny explanatory subtitle under the Period row. The info icon's title
   attribute carries the full definition of "finalized" so non-power users
   can hover for context without leaving the panel. */
.qap-filter-period-subtitle {
    display: flex;
    align-items: center;
    gap: 0.4286rem;
    color: rgba(0, 0, 0, 0.55);
    font-size: 0.8571rem;
    margin-bottom: 0.1429rem;
}
.qap-filter-period-info {
    color: rgba(0, 0, 0, 0.4);
    font-size: 0.8571rem;
    cursor: help;
}
.qap-filter-period-info:hover { color: var(--qap-primary); }

.qap-filter-period-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2857rem;
}
.qap-filter-period-chip {
    appearance: none;
    background: rgba(10, 106, 161, 0.06);
    border: 0.0714rem solid transparent;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    font-weight: 500;
    padding: 0.2143rem 0.6429rem;
    border-radius: 71.3571rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease;
}
.qap-filter-period-chip:hover {
    background: rgba(10, 106, 161, 0.12);
}
.qap-filter-period-chip.active {
    background: var(--qap-primary);
    color: #fff;
    border-color: var(--qap-primary);
}
.qap-filter-period-reset {
    appearance: none;
    background: transparent;
    border: 0.0714rem solid transparent;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.8571rem;
    width: 1.5714rem;
    height: 1.5714rem;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.1429rem;
    transition: background 120ms ease, color 120ms ease;
}
.qap-filter-period-reset:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.7);
}

/* Saved filters strip — sits at the top of the panel above the first filter
   row. Solid off-white grey reads as a distinct section against the
   panel's pure-white rows. Layout is "header row (label + Save action) +
   selector chip + popover" — designed to stay one row regardless of how
   many filters the user has saved. */
.qap-filter-presets {
    padding: 0.7143rem 1.1429rem 0.8571rem;
    background: #f4f6f8;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.08);
    font-family: 'Lato', sans-serif;
}
.qap-filter-presets-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5714rem;
    margin-bottom: 0.5714rem;
}
.qap-filter-presets-label {
    font-size: 0.7857rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(0, 0, 0, 0.55);
}

/* Selector — the combined "active preset + dropdown caret" pill. When a
   preset matches the applied filter it shows that name (with ⭐ if system);
   otherwise it reads as a generic "Saved filters" trigger. Always one
   element so the strip height never changes. */
.qap-filter-preset-anchor {
    position: relative;
}
.qap-filter-preset-selector {
    appearance: none;
    background: #fff;
    border: 0.0714rem solid rgba(0, 0, 0, 0.12);
    border-radius: 71.3571rem;
    padding: 0.3571rem 0.8571rem;
    color: var(--qap-text);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    white-space: nowrap;
    transition: border-color 120ms ease, background 120ms ease;
}
.qap-filter-preset-selector:hover { border-color: var(--qap-primary); }
.qap-filter-preset-selector.active {
    background: var(--qap-primary);
    color: #fff;
    border-color: var(--qap-primary);
}
.qap-filter-preset-selector.open {
    border-color: var(--qap-primary);
    box-shadow: 0 0 0 0.2143rem rgba(10, 106, 161, 0.12);
}
.qap-filter-preset-selector-star { color: #ffd24a; font-size: 0.8571rem; }
.qap-filter-preset-selector.empty .qap-filter-preset-selector-star { color: #d29c00; }
.qap-filter-preset-selector-caret {
    font-size: 0.7857rem;
    color: rgba(0, 0, 0, 0.5);
    margin-left: 0.1429rem;
}
.qap-filter-preset-selector.active .qap-filter-preset-selector-caret { color: #fff; }

/* Popover — anchored below the selector. Backdrop is full-viewport but
   transparent so clicks outside dismiss without a visible scrim. */
.qap-filter-preset-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-dropdown-backdrop);
}
.qap-filter-preset-popover {
    position: absolute;
    top: calc(100% + 0.4286rem);
    left: 0;
    z-index: var(--z-dropdown);
    width: 20rem;
    max-height: 25.7143rem;
    background: #fff;
    border: 0.0714rem solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5714rem;
    box-shadow: 0 0.4286rem 1.4286rem rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: qap-preset-pop-in 120ms ease-out;
}
@keyframes qap-preset-pop-in {
    from { opacity: 0; transform: translateY(-0.2857rem); }
    to   { opacity: 1; transform: translateY(0); }
}
.qap-filter-preset-search-row {
    display: flex;
    align-items: center;
    gap: 0.4286rem;
    padding: 0.5714rem 0.7143rem;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.5);
}
.qap-filter-preset-search-row i { font-size: 0.8571rem; }
.qap-filter-preset-search {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    outline: none;
    color: rgba(0, 0, 0, 0.85);
}
.qap-filter-preset-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.qap-filter-preset-list {
    overflow-y: auto;
    padding: 0.2857rem 0;
}
.qap-filter-preset-section {
    padding: 0.5714rem 0.8571rem 0.2857rem;
    font-size: 0.7143rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(0, 0, 0, 0.45);
}
.qap-filter-preset-item {
    display: flex;
    align-items: stretch;
    transition: background 120ms ease;
}
.qap-filter-preset-item:hover { background: rgba(10, 106, 161, 0.06); }
.qap-filter-preset-item.active { background: rgba(10, 106, 161, 0.08); }
.qap-filter-preset-item.pending-delete {
    background: rgba(220, 53, 69, 0.1);
}
.qap-filter-preset-item.pending-delete .qap-filter-preset-item-apply,
.qap-filter-preset-item.pending-delete .qap-filter-preset-item-delete {
    color: #b02a37;
}

.qap-filter-preset-item-apply {
    appearance: none;
    background: transparent;
    border: 0;
    flex: 1;
    text-align: left;
    padding: 0.5rem 0.8571rem;
    color: var(--qap-text);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5714rem;
}
.qap-filter-preset-item-star { color: #d29c00; font-size: 0.8571rem; }
.qap-filter-preset-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qap-filter-preset-item-check {
    color: var(--qap-primary);
    font-size: 0.8571rem;
}
.qap-filter-preset-item-delete {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0 0.8571rem;
    color: rgba(0, 0, 0, 0.4);
    font-size: 0.8571rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease, color 120ms ease;
}
.qap-filter-preset-item:hover .qap-filter-preset-item-delete,
.qap-filter-preset-item.pending-delete .qap-filter-preset-item-delete { opacity: 1; }
.qap-filter-preset-item-delete:hover { color: #b02a37; }

.qap-filter-preset-empty {
    padding: 1.1429rem 0.8571rem;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9286rem;
    text-align: center;
}

/* Save action — sits in the header row, right-aligned, separate from the
   apply selector below. Inline-save chip swaps in when the user clicks
   the button. */
.qap-filter-preset.saving {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 0.0714rem solid var(--qap-primary);
    border-radius: 71.3571rem;
    padding: 0 0.1429rem 0 0.7143rem;
}
.qap-filter-preset-name {
    appearance: none;
    border: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    color: rgba(0, 0, 0, 0.85);
    outline: none;
    padding: 0.2143rem 0;
    width: 9.2857rem;
}
.qap-filter-preset-confirm,
.qap-filter-preset-cancel {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0 0.4286rem;
    font-size: 0.8571rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}
.qap-filter-preset-confirm { color: var(--qap-primary); }
.qap-filter-preset-confirm:disabled { color: rgba(0, 0, 0, 0.25); cursor: not-allowed; }
.qap-filter-preset-cancel { color: rgba(0, 0, 0, 0.45); }
.qap-filter-preset-cancel:hover { color: rgba(0, 0, 0, 0.65); }

.qap-filter-preset-add {
    appearance: none;
    background: transparent;
    border: 0.0714rem dashed rgba(10, 106, 161, 0.35);
    border-radius: 71.3571rem;
    padding: 0.2143rem 0.7143rem;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    white-space: nowrap;
}
.qap-filter-preset-add:hover {
    background: rgba(10, 106, 161, 0.08);
    border-color: var(--qap-primary);
}

/* ===== Chart Compare =====
   Chart cards opt in to comparison mode by being wrapped in
   .qap-compare-card. In single mode the card behaves like a normal
   qap-card. In compare mode the body splits into two side-by-side panes
   with their own headers identifying which filter each pane represents. */
.qap-compare-card {
    position: relative;
}
/* Three zones — empty | centered title+info | toolbar — so the title sits
   dead-centre in the card (the two 1fr edges are equal) while the toolbar
   pins right, all in one row (no extra vertical space). */
.qap-compare-card-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.8571rem;
    margin-bottom: 0.5714rem;
}
.qap-compare-card-header .qap-card-title {
    grid-column: 2;
    justify-self: center;
    margin: 0;
    min-width: 0;
    /* Flex centres the info icon against the title's optical middle (an inline
       icon would sit on the text baseline and look low). */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4286rem;
}
/* Title text in its own item so a long title still wraps inside the flex. */
.qap-compare-card-header .qap-card-title > span:first-child {
    min-width: 0;
}
.qap-compare-card-header .qap-chart-menu-btn {
    grid-column: 3;
    justify-self: end;
}
/* Optional per-card header slot (CompareEnvelopeCard's HeaderActions) — left
   column, left-aligned, so the control sits opposite the (currently
   commented-out) chart-menu button rather than competing with it. Empty/
   absent for every card that doesn't pass one, so the 1fr edge column just
   collapses back to blank space and the title stays centred. */
.qap-compare-card-header-actions {
    grid-column: 1;
    justify-self: start;
}
/* Score-type selector scoped to a service-element chart card's header slot
   (Network Level's Average-quality-score-per-service-element card and the
   Facility page's Quality-score-over-time-per-service-element card) — reuses
   the .qap-select-field shell (see Detailed assessment scores' Score type
   dropdown) but sized + stripped of the shell's default vertical margin so
   it sits inline in the card header. Shared across both pages — do not fork
   a per-page variant. */
.qap-scorekind-field {
    width: 15.7143rem;
    max-width: 100%;
    margin: 0;
}
/* Phone: the 1fr auto 1fr header can't hold a ~16rem selector next to the
   title — the title gets crushed into a tall ragged column while the trailing
   1fr sits empty. Collapse to one column so the title keeps the full width and
   the selector drops onto its own row underneath, full-width like the rest of
   the mobile form controls. */
@media (max-width: 767.98px) {
    .qap-compare-card-header {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 0.5714rem;
    }
    .qap-compare-card-header .qap-card-title,
    .qap-compare-card-header .qap-chart-menu-btn,
    .qap-compare-card-header-actions {
        grid-column: 1;
    }
    .qap-compare-card-header-actions { justify-self: stretch; }
    .qap-scorekind-field { width: 100%; }
}
/* The header is a 1fr auto 1fr grid with the title in column 2, so a sibling
   caption would land in the trailing column. Span every column instead, which
   drops it onto its own row centred under the title. */
.qap-compare-card-header .qap-card-coverage {
    grid-column: 1 / -1;
}

/* Single overflow ("⋯") trigger that replaces the Compare/viz pill — opens the
   chart menu (Compare + chart-type) so the header stays compact and centred. */
.qap-chart-menu-btn {
    appearance: none;
    background: transparent;
    border: 0.0714rem solid rgba(10, 106, 161, 0.35);
    border-radius: 71.3571rem;
    width: 2.2857rem;
    height: 2.2857rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--qap-primary);
    font-size: 1.1429rem;
    cursor: pointer;
    transition: background 120ms ease;
}
.qap-chart-menu-btn:hover,
.qap-chart-menu-btn.open {
    background: rgba(10, 106, 161, 0.08);
}
/* Chart menu item internals — icon+text label, and a thin separator between
   Compare and the chart-type options. */
.qap-chart-menu-item-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
}
.qap-chart-menu-sep {
    height: 0.0714rem;
    background: rgba(0, 0, 0, 0.08);
    margin: 0.2857rem 0;
}

/* Segmented chart toolbar — Compare + Change visualization in one pill.
   Two buttons that visually merge into a single capsule with a divider so
   the user reads them as "the chart toolset", not "two unrelated actions". */
.qap-chart-toolbar {
    display: inline-flex;
    align-items: stretch;
    border: 0.0714rem solid rgba(10, 106, 161, 0.35);
    border-radius: 71.3571rem;
    overflow: hidden;
    background: #fff;
}
.qap-chart-toolbar-btn {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0.3571rem 0.8571rem;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    transition: background 120ms ease;
}
.qap-chart-toolbar-btn:hover:not(:disabled) {
    background: rgba(10, 106, 161, 0.08);
}
.qap-chart-toolbar-btn:disabled {
    color: rgba(0, 0, 0, 0.35);
    cursor: not-allowed;
}
.qap-chart-toolbar-btn.open {
    background: rgba(10, 106, 161, 0.12);
}
.qap-chart-toolbar-btn i { font-size: 0.7857rem; }
.qap-chart-toolbar-caret { margin-left: 0.1429rem; opacity: 0.7; }

/* Icon-only variant — tighter padding, no label. Used for secondary
   actions in the toolbar (e.g. "Change visualization") to keep the toolbar
   from overflowing onto a second row. The button stays accessible via
   the title / aria-label. */
.qap-chart-toolbar-btn--icon {
    padding: 0.3571rem 0.6429rem;
    gap: 0.2857rem;
}
.qap-chart-toolbar-divider {
    width: 0.0714rem;
    background: rgba(10, 106, 161, 0.25);
    align-self: stretch;
}

/* Visualization dropdown — small anchored menu listing the envelope's
   allowedCharts. Lives inside the chart card so position: absolute pins
   it under the toolbar; backdrop is transparent (no scrim — this is a
   menu, not a modal). */
.qap-chart-viz-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-dropdown-backdrop);
}
.qap-chart-viz-popover {
    position: absolute;
    top: 4rem;
    right: 1.1429rem;
    z-index: var(--z-dropdown);
    min-width: 12.8571rem;
    background: #fff;
    border: 0.0714rem solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5714rem;
    box-shadow: 0 0.4286rem 1.4286rem rgba(0, 0, 0, 0.15);
    padding: 0.2857rem 0;
    animation: qap-preset-pop-in 120ms ease-out;
}
.qap-chart-viz-item {
    appearance: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    color: var(--qap-text);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5714rem;
    transition: background 120ms ease;
}
.qap-chart-viz-item:hover { background: rgba(10, 106, 161, 0.06); }
.qap-chart-viz-item.active {
    background: rgba(10, 106, 161, 0.08);
    color: var(--qap-primary);
    font-weight: 500;
}
.qap-chart-viz-item i { font-size: 0.8571rem; color: var(--qap-primary); }

/* Back-compat: the old qap-compare-btn alias still works for any place
   that references it standalone. Same look as one toolbar segment but
   self-contained. Will be removed once compare lives only inside the
   segmented toolbar. */
.qap-compare-btn {
    appearance: none;
    background: transparent;
    border: 0.0714rem solid rgba(10, 106, 161, 0.35);
    border-radius: 71.3571rem;
    padding: 0.2857rem 0.8571rem;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    transition: background 120ms ease, border-color 120ms ease;
}
.qap-compare-btn:hover {
    background: rgba(10, 106, 161, 0.08);
    border-color: var(--qap-primary);
}
.qap-compare-btn-exit {
    color: rgba(0, 0, 0, 0.55);
    border-color: rgba(0, 0, 0, 0.15);
}
.qap-compare-btn-exit:hover {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.75);
    border-color: rgba(0, 0, 0, 0.3);
}

.qap-compare-panes {
    display: grid;
    /* minmax(0, 1fr) — not bare 1fr — so the columns are allowed to shrink
       BELOW each chart's intrinsic min-width. Without this the grid honors
       min-content and overflows the modal whenever the available width is
       narrower than 2 × the chart's natural min-width, which is exactly
       what was clipping the second pane off-screen. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.1429rem;
}
@media (max-width: 768px) {
    /* Stack panes on narrow viewports so each chart stays legible. */
    .qap-compare-panes { grid-template-columns: minmax(0, 1fr); }
}
.qap-compare-pane {
    display: flex;
    flex-direction: column;
    background: #f8f9fb;
    border: 0.0714rem solid rgba(0, 0, 0, 0.06);
    border-radius: 0.4286rem;
    padding: 0.7143rem 0.8571rem;
}
.qap-compare-pane-header {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    margin-bottom: 0.4286rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
}
.qap-compare-pane-eyebrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5714rem;
    height: 1.5714rem;
    border-radius: 50%;
    background: var(--qap-primary);
    color: #fff;
    font-size: 0.7857rem;
    font-weight: 700;
    flex-shrink: 0;
}
.qap-compare-pane-eyebrow.alt {
    background: #d29c00;
}
.qap-compare-pane-name {
    font-weight: 500;
    color: var(--qap-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Comparison modal — the actual two-pane viewer. Opens centered over the
   dashboard so the underlying chart card stays exactly where it was. Wider
   than the picker (it has to fit two full charts side-by-side) and the
   backdrop carries a real scrim so the user reads it as a separate
   surface, not part of the dashboard. */
/* ===== QapModal — the one modal in QAP =====
   Native <dialog> opened via showModal() (qap-modal.js), so it lives in the
   browser top layer: never clipped by a parent's overflow/stacking context and
   no z-index needed. We centre it ourselves (UA centring of an auto-height
   :modal is unreliable) and animate entry/exit natively with @starting-style. */
.qap-modal {
    position: fixed;
    inset: auto;
    top: 50%;
    left: 50%;
    margin: 0;
    transform: translate(-50%, calc(-50% + 0.8571rem));
    opacity: 0;
    width: 100%;
    max-width: min(var(--qap-modal-max-w, 48rem), calc(100vw - 2.2857rem));
    max-height: calc(100vh - 2.2857rem);
    max-height: calc(100dvh - 2.2857rem);
    padding: 0;
    border: 0;
    border-radius: 0.7143rem;
    background: #fff;
    color: var(--qap-text);
    box-shadow: 0 1.4286rem 4.2857rem rgba(0, 0, 0, 0.3);
    overflow: hidden;
    /* Neutral typography baseline — a trigger inside a big centred chart title
       would otherwise inherit its font in. */
    font-family: 'Lato', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
}
.qap-modal:popover-open {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translate(-50%, -50%);
}
.qap-modal::backdrop { background: rgba(15, 23, 42, 0.45); opacity: 1; }

.qap-modal--sm { --qap-modal-max-w: 34rem; }
.qap-modal--md { --qap-modal-max-w: 48rem; }
.qap-modal--lg { --qap-modal-max-w: 114.2857rem; }

/* Entry only: @starting-style animates the open; close is instant (the body is
   gated on IsOpen, so animating the exit would just fade an empty shell). */
@media (prefers-reduced-motion: no-preference) {
    .qap-modal { transition: opacity 160ms ease, transform 160ms ease; }
    .qap-modal::backdrop { transition: opacity 160ms ease; }
    @starting-style {
        .qap-modal:popover-open { opacity: 0; transform: translate(-50%, calc(-50% + 0.8571rem)); }
        .qap-modal:popover-open::backdrop { opacity: 0; }
    }
}

.qap-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8571rem;
    padding: 1.1429rem 1.4286rem;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.08);
}
.qap-modal-titles { flex: 1 1 auto; min-width: 0; }
.qap-modal-title {
    margin: 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.5714rem;
    font-weight: 700;
    color: var(--qap-primary);
}
.qap-modal-subtitle {
    margin: 0.2857rem 0 0;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: var(--qap-primary);
    opacity: 0.85;
}
.qap-modal-close {
    flex: 0 0 auto;
    appearance: none;
    background: transparent;
    border: 0;
    width: 2.2857rem;
    height: 2.2857rem;
    border-radius: 0.4286rem;
    color: rgba(0, 0, 0, 0.55);
    font-size: 1.1429rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease;
}
.qap-modal-close:hover { background: rgba(0, 0, 0, 0.06); color: rgba(0, 0, 0, 0.8); }
.qap-modal-body {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.4286rem;
}
/* List-style bodies own their row padding, so flush the body gutters. */
.qap-modal--flush .qap-modal-body { padding: 0.5714rem 0; }

/* Full-bleed sheet on phones — matches the map popup's ≤640px sheet. dvh keeps
   the modal clear of the collapsing mobile browser chrome. */
@media (max-width: 640px) {
    .qap-modal {
        width: 100vw;
        max-width: none;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
}

/* ===== List-modal row content =====
   The striped rows shown inside a QapModal by EnvelopeListModal. The modal
   shell (backdrop, header, close, body) is QapModal now — only the row styling
   specific to the list lives here. The body uses the .qap-modal--flush variant
   so these rows own their own horizontal padding. */
.qap-list-modal-empty {
    margin: 0;
    padding: 1.7143rem;
    text-align: center;
    color: rgba(0, 0, 0, 0.55);
    font-style: italic;
}
.qap-list-modal-rows {
    list-style: none;
    margin: 0;
    padding: 0;
}
.qap-list-modal-row {
    display: flex;
    align-items: center;
    gap: 0.8571rem;
    padding: 0.8571rem 1.7143rem;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.05);
    font-family: 'Lato', sans-serif;
    font-size: 1.0714rem;
    color: var(--qap-text);
    cursor: default;
    transition: background 100ms ease;
}
.qap-list-modal-row:nth-child(even) { background: rgba(10, 106, 161, 0.04); }
.qap-list-modal-row:hover { background: rgba(10, 106, 161, 0.10); }
.qap-list-modal-row-link {
    display: flex;
    align-items: center;
    gap: 0.8571rem;
    flex: 1 1 auto;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.qap-list-modal-row-title { flex: 1 1 auto; min-width: 0; }
.qap-list-modal-row-subtitle {
    color: rgba(0, 0, 0, 0.55);
    font-size: 0.9286rem;
}
.qap-list-modal-row-chevron {
    color: rgba(10, 106, 161, 0.55);
    font-size: 0.8571rem;
}

/* ===== Compare Picker Popover =====
   Anchored at the card level so it floats above the chart. Same structural
   pattern as the saved-filters popover but parameterized for "pick a filter
   to compare against" semantics (no save / delete affordances). */
/* Anchored dropdown — sits at the top-right of the chart card. Transparent
   backdrop is just an outside-click catcher; the picker itself reads as a
   regular dropdown, not a modal. The chart's compare view (rendered as a
   separate modal) is what visually "takes the user forward". */
.qap-chart-compare-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-dropdown-backdrop);
}
.qap-chart-compare-picker {
    position: absolute;
    top: 3.4286rem;
    right: 1.1429rem;
    z-index: var(--z-dropdown);
    width: 21.4286rem;
    max-height: 28.5714rem;
    background: #fff;
    border: 0.0714rem solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5714rem;
    box-shadow: 0 0.4286rem 1.4286rem rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: qap-preset-pop-in 120ms ease-out;
}
.qap-chart-compare-picker-search-row {
    display: flex;
    align-items: center;
    gap: 0.4286rem;
    padding: 0.5714rem 0.7143rem;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.5);
}
.qap-chart-compare-picker-search-row i { font-size: 0.8571rem; }
.qap-chart-compare-picker-search {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    outline: none;
    color: rgba(0, 0, 0, 0.85);
}
.qap-chart-compare-picker-list {
    overflow-y: auto;
    padding: 0.2857rem 0;
}
.qap-chart-compare-picker-section {
    padding: 0.5714rem 0.8571rem 0.2857rem;
    font-size: 0.7143rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(0, 0, 0, 0.45);
}
.qap-chart-compare-picker-item {
    appearance: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.8571rem;
    color: var(--qap-text);
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    transition: background 120ms ease;
}
.qap-chart-compare-picker-item:hover { background: rgba(10, 106, 161, 0.06); }
.qap-chart-compare-picker-item-icon {
    color: rgba(0, 0, 0, 0.45);
    font-size: 0.8571rem;
    width: 1rem;
    text-align: center;
}
.qap-chart-compare-picker-item-icon.system { color: #d29c00; }
.qap-chart-compare-picker-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qap-chart-compare-picker-item-hint {
    color: rgba(0, 0, 0, 0.45);
    font-size: 0.7857rem;
    flex-shrink: 0;
}
.qap-chart-compare-picker-empty {
    padding: 1.1429rem 0.8571rem;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9286rem;
    text-align: center;
}
.qap-filter-period-pills {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4286rem;
    color: rgba(0, 0, 0, 0.65);
    font-size: 1rem;
}
.qap-filter-period-pill-label {
    color: rgba(0, 0, 0, 0.6);
    font-size: 0.9286rem;
}
.qap-filter-period-hint {
    margin-top: 0.1429rem;
    padding: 0.4286rem 0.7143rem;
    background: rgba(10, 106, 161, 0.06);
    border-left: 0.2143rem solid var(--qap-primary);
    border-radius: 0.2857rem;
    color: rgba(0, 0, 0, 0.65);
    font-size: 0.8571rem;
    line-height: 1.4;
}
.qap-filter-tree-item-label {
    display: inline-flex;
    align-items: center;
    gap: 0.2857rem;
    margin: 0;
    cursor: pointer;
    user-select: none;
}
.qap-filter-loading {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 0 0.2857rem;
    color: rgba(0, 0, 0, 0.55);
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
}
.qap-filter-loading .spinner-border { color: var(--qap-primary); }

/* Facilities row — search-as-you-type picker (QapFilterPanel,
   /qap/fragment/facility-filter-search). Search box shell is bespoke; the
   result rows share the .qap-search-result primitive (defined above, near
   .qap-find-result) with .qap-filter-facility-result as the thin modifier —
   see that comment for why. Its text sizes are pinned to the tree's own scale
   so the row doesn't look "off" next to Contracts/Countries: 1.1429rem for
   the name, 1rem for the secondary location line (matches .qap-filter-count,
   the tree's own secondary-text size). The selected list below
   (QapFilterPanel.razor) renders as a plain .qap-filter-tree instead —
   checked checkbox rows, not cards — since that view reads better as "one
   of the filter's own selections" rather than a search result. */
.qap-filter-facility-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5714rem;
}
.qap-filter-facility-search-row {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 0.8571rem;
    border: 0.0714rem solid rgba(0, 0, 0, 0.15);
    border-radius: 0.2857rem;
    color: var(--qap-muted);
    font-size: 1.1429rem; /* sizes the magnifier icon with the input text below */
}
.qap-filter-facility-search-row:focus-within {
    border-color: var(--qap-primary);
}
/* Search-in-flight cue, same pattern as .qap-find-icon in the home page
   picker (site.css, near .qap-find-icon): swap the magnifier for a spinner
   rather than only dimming the results below, since the very first search has
   nothing in #qap-filter-facility-results to dim yet. The two icons are
   stacked in the same grid cell and only OPACITY/VISIBILITY are transitioned
   — never `display`, which applies instantly and defeats transition-delay
   (verified against .qap-find-icon; see that comment). Delayed so the
   `keyup changed delay:150ms` trigger firing on every keystroke never
   strobes — only a request that's actually slow gets to show it. */
.qap-filter-facility-search-icon {
    display: grid;
    grid-template-areas: "icon";
    place-items: center;
}
.qap-filter-facility-search-icon > * { grid-area: icon; }
.qap-filter-facility-search-icon .fa-magnifying-glass,
.qap-filter-facility-search-spinner {
    transition: opacity 0.15s ease 0.2s, visibility 0.15s ease 0.2s;
}
.qap-filter-facility-search-spinner {
    opacity: 0;
    visibility: hidden;
}
.qap-filter-facility-search-icon.htmx-request .fa-magnifying-glass {
    opacity: 0;
    visibility: hidden;
}
.qap-filter-facility-search-icon.htmx-request .qap-filter-facility-search-spinner {
    opacity: 1;
    visibility: visible;
}
/* Dim stale hits while a later keystroke's search is in flight. */
.qap-filter-facility-results.htmx-request {
    opacity: 0.55;
    transition: opacity 0.15s ease 0.2s;
}
.qap-filter-facility-search {
    flex: 1;
    appearance: none;
    border: 0;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem; /* match the result-name size so input text and results read as one control */
    outline: none;
    color: var(--qap-text);
}
.qap-filter-facility-search::-webkit-search-cancel-button { -webkit-appearance: none; }
.qap-filter-facility-results:not(:empty) {
    max-height: 15.7143rem;
    overflow-y: auto;
    border: 0.0714rem solid rgba(0, 0, 0, 0.1);
    border-radius: 0.2857rem;
}
/* Filter panel modifier on .qap-search-result — original standalone spacing/
   divider values, plus the ellipsis-truncated name .qap-find-result doesn't
   need (its row never got narrow enough for the home picker's use to matter). */
.qap-filter-facility-result {
    gap: 0.5714rem;
    padding: 0.5714rem 0.8571rem;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.08);
}
.qap-filter-facility-result:last-child { border-bottom: 0; }
.qap-filter-facility-result-name {
    display: block;
    color: var(--qap-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qap-filter-facility-result-loc {
    display: block;
}
.qap-filter-facility-result-add {
    color: var(--qap-primary);
    font-size: 1.1429rem; /* matches .qap-filter-tree li > i's icon size */
    flex-shrink: 0;
}

/* Filter action bar — pinned below the filter rows. Holds Apply / Clear. */
.qap-filter-actions {
    display: flex;
    gap: 0.5714rem;
    padding: 0.8571rem 1.1429rem;
    background: #fff;
    border-top: 0.0714rem solid rgba(0, 0, 0, 0.12);
    position: sticky;
    bottom: 0;
}
.qap-filter-btn {
    flex: 1;
    height: 2.8571rem;
    border-radius: 0.2857rem;
    border: 0;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 700;
}
.qap-filter-btn-primary {
    background: var(--qap-primary);
    color: #fff;
}
.qap-filter-btn-primary:hover {
    filter: brightness(0.95);
}
.qap-filter-btn-secondary {
    background: #fff;
    color: var(--qap-text);
    border: 0.0714rem solid rgba(0, 0, 0, 0.2);
}
.qap-filter-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Busy state for whichever filter-form submit button was pressed (Apply,
   Reset, or the Clear-all menu item) — qap-filter.js adds this class to the
   submitter on submit, so the click can't register as a no-op and a second
   click can't double-submit. aria-disabled (not the disabled attribute) is
   set at the same time: disabling a submit button synchronously can drop it
   as the form's submitter on some browsers, so the real `disabled` is applied
   a tick later, after the submit has already been handed to the browser.
   pointer-events:none blocks further clicks in that window regardless. The
   spinner reuses Bootstrap's spinner-border, same as every other in-flight
   indicator in this file (.qap-filter-loading, .qap-global-refresh, …) —
   inserted by qap-filter.js, not a new primitive. */
.qap-filter-btn.qap-btn-busy,
.qap-filter-reset-menu-item.qap-btn-busy {
    pointer-events: none;
    opacity: 0.75;
}
.qap-filter-btn.qap-btn-busy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5714rem;
}
/* Bootstrap's .dropdown-item is display:block; switch to flex only while busy
   so the inserted spinner sits inline with the label instead of stacking. */
.qap-filter-reset-menu-item.qap-btn-busy {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
}
.qap-filter-btn-primary.qap-btn-busy .spinner-border {
    color: #fff;
}
.qap-filter-btn-secondary.qap-btn-busy .spinner-border,
.qap-filter-reset-menu-item.qap-btn-busy .spinner-border {
    color: var(--qap-primary);
}

/* ======= Reset split button ======= */
/* Reset + caret read as one control sharing Apply's half of the bar, so the
   destructive-ish "Clear all" doesn't sit at the same visual weight as Apply.
   The seam between the two halves is a single shared border. */
.qap-filter-reset-group {
    flex: 1;
    display: flex;
}
.qap-filter-reset-group .qap-filter-btn-reset {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.qap-filter-reset-group .qap-filter-btn-caret {
    flex: 0 0 auto;
    width: 2.4286rem;
    /* No left border — the Reset half's right border is the seam. */
    border-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-size: 0.8571rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.qap-filter-reset-group .qap-filter-btn-caret[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.06);
}
/* data-bs-reference="parent" anchors the menu to the whole group, so matching
   its width keeps the popup visually attached to the control. */
.qap-filter-reset-menu {
    min-width: 100%;
    margin-bottom: 0.2857rem;
}
.qap-filter-reset-menu-item {
    font-family: 'Lato', sans-serif;
    font-size: 1.0714rem;
    font-weight: 700;
    color: var(--qap-text);
    cursor: pointer;
}

/* ======= FAB (mobile only) ======= */
/* Mobile-only filter button, integrated into the right edge of the search
   bar next to the search icon. Absolutely positioned inside .qap-overlay-find
   so it overlays the bar's right edge regardless of the bar's state. */
.qap-find-filter {
    position: absolute;
    top: 50%;
    right: 0.8571rem;
    transform: translateY(-50%);
    padding: 0;
    border: 0;
    background: none;
    color: var(--qap-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4286rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1;
}
.qap-find-filter:hover { color: var(--qap-primary); }
/* When the search panel is expanded the close (X) takes the corner, so the
   in-bar filter button steps aside. */
.qap-overlay-find.expanded .qap-find-filter { display: none; }

/* ======= Drawer Legend ======= */

.qap-overlay-legend {
    position: absolute;
    bottom: 0.2857rem;
    left: 0.7143rem;
    right: auto;
    max-width: calc(100% - 1.4286rem);
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(0.2857rem);
    backdrop-filter: blur(0.2857rem);
    border-radius: 0.2143rem;
    box-shadow: 0 0.1429rem 0.5714rem rgba(0, 0, 0, 0.18);
    padding: 0.7143rem 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5714rem 1.1429rem;
    font-size: 1.0714rem;
    color: var(--qap-text);
    z-index: var(--z-map-overlay);
}
.qap-overlay-legend-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5714rem 1.4286rem;
}
.qap-overlay-legend-items li { display: flex; align-items: center; gap: 0.5714rem; }

.qap-dot {
    display: inline-block;
    width: 0.8571rem; height: 0.8571rem;
    border-radius: 50%;
    background: #999;
    flex-shrink: 0;
}
/* Must match the map marker palette in PinMap.razor.cs (LevelColors),
   itself taken verbatim from legacy QPS MapConfig.ts. Keep in sync. */
.qap-dot-l1 { background: #8971E0; }
.qap-dot-l2 { background: #57BCF9; }
.qap-dot-l3 { background: #2D5CB4; }
.qap-dot-l4 { background: #53A886; }
.qap-dot-l5 { background: #306A52; }
.qap-dot-self { background: #EDBE41; }  /* active self (-2) */
.qap-dot-entry { background: #8B4513; } /* active entry (-3) */

/* ======= Page filter bar (shared across all non-home pages) ======= */
.qap-page-filters {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: #fff;
    flex-shrink: 0;
    box-shadow:
        0 0.0714rem 0.2143rem rgba(0,0,0,0.2),
        0 0.0714rem 0.0714rem rgba(0,0,0,0.14),
        0 0.1429rem 0.0714rem -0.0714rem rgba(0,0,0,0.12);
}
.qap-page-filters > .qap-page-filters-inner {
    height: 3.5714rem;
}
/* Desktop page-filters as a native popover, anchored to the Filters button so
   it hangs just under the bar (top layer — no z-index juggling, light-dismiss
   built in). The button carries anchor-name; the popover positions against it. */
.qap-pf-anchor { anchor-name: --qap-pf-btn; }
.qap-page-filters-popover {
    position: fixed;
    position-anchor: --qap-pf-btn;
    inset: auto;                 /* clear the UA-centered popover inset */
    top: anchor(bottom);
    left: anchor(left);
    margin: 0;
    padding: 0;
    border: none;
    width: 29.4286rem;
    max-height: calc(100vh - 8.5714rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 0 0 0.2857rem 0.2857rem;
    box-shadow: 0 0.5714rem 1.1429rem rgba(0, 0, 0, 0.18);
}
.qap-page-filters-popover::backdrop { background: transparent; }
/* Placeholder shown inside the popover/offcanvas shell until the lazy-loaded
   filter panel fragment lands. */
.qap-filter-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5714rem;
    padding: 2rem;
    color: rgba(0, 0, 0, 0.55);
    font-family: 'Lato', sans-serif;
}
/* Below lg the desktop popover is replaced by the offcanvas drawer. If it was
   opened on a wide screen and the window is then shrunk, hide it so the desktop
   panel doesn't linger over the mobile layout (!important beats the UA
   [popover]:popover-open display). Re-widening shows it again. */
@media (max-width: 991.98px) {
    .qap-page-filters-popover { display: none !important; }
}
.qap-page-filters-inner {
    width: 100%;
    max-width: 107.1429rem;
    margin: 0 auto;
    padding: 0 1.7143rem;
    display: flex;
    align-items: center;
    /* Positioning anchor for the dropdown panel — placing it on inner means
       the panel hangs at a known offset from the bar's content area, not from
       the body-content's left edge. */
    position: relative;
}
.qap-filter-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.2857rem;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 500;
    color: var(--qap-text);
}
.qap-filter-summary > i {
    color: var(--qap-primary);
    font-size: 2.1429rem;
    margin-right: 0.8571rem;
    margin-left: 1.1429rem;
}
.qap-icon-sliders {
    width: 2rem;
    height: 2rem;
    margin-right: 0.8571rem;
    color: var(--qap-primary);
    fill: #fff;
    stroke: currentColor;
    stroke-width: 1;
    stroke-linecap: round;
}
.qap-filter-summary-active { color: var(--qap-text); font-weight: 500; font-size: 1.4286rem; }

/* Page wrapper must always be at least the height of its scrolling parent
   (.qap-body-content) so any transient content shrink inside (Blazor
   re-render, popover open/close, toggle re-fetch, chart card swapping its
   loading placeholder for the real chart) can't drop the scrollable
   contentHeight below the viewport. Without this the browser clamps
   scrollTop to the new (smaller) max, and when content bounces back the
   scroll position is stuck — that's the "gray void below the chart"
   behaviour where everything below appears to vanish. Scrolling to the top
   and back undoes it because the browser resets scrollTop on the way up.

   Percentage min-height resolves unreliably inside overflow:auto flex
   columns (containing-block height becomes indeterminate), so we combine
   `flex: 1 0 auto` (grow to fill, never shrink) with an explicit dvh-based
   floor for browsers that ignore the flex hint. */
.qap-network-body {
    padding: 1.7143rem;
    max-width: 107.1429rem;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    flex: 1 0 auto;
    min-height: calc(100dvh - 5rem);
    overflow-anchor: auto;
}

.qap-section-title {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 3.4286rem;
    line-height: 5.1429rem;
    color: var(--qap-primary);
    text-align: center;
    margin: 1.7143rem 0 0.2857rem;
}
/* FocusOnNavigate (Routes.razor) focuses the first <h1> on each navigation for
   screen-reader users. Headings aren't interactive, so suppress the visible
   focus ring that otherwise frames the page title on first load. */
h1:focus,
.qap-section-title:focus {
    outline: none;
}
.qap-section-subtitle {
    font-family: 'Lato', sans-serif;
    font-size: 1.7143rem;
    font-weight: 400;
    line-height: 2.5714rem;
    color: var(--qap-primary);
    text-align: center;
    margin: 0 0 2.2857rem;
}

/* KPI Quality Status groups */
.qap-kpi-groups {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.7143rem;
    margin-bottom: 2.2857rem;
}
.qap-kpi-group { padding: 1.1429rem 1.7143rem; }
.qap-kpi-group + .qap-kpi-group { border-left: 0.0714rem solid rgba(0,0,0,0.08); }
.qap-kpi-group--self { padding-top: 1.1429rem; }
.qap-kpi-group-title {
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 1.8571rem;
    line-height: 2.7857rem;
    color: var(--qap-primary);
    margin-bottom: 1.1429rem;
}
.qap-kpi-group-row {
    display: flex;
    justify-content: space-around;
    gap: 1.1429rem;
}
.qap-kpi-group-row--center { justify-content: center; gap: 5.7143rem; }

/* Quality Status tiles are shared <QapKpi> tiles (.qap-kpi-tile*, defined in
   the "Shared KPI tile" block). This rule only sizes them within a group row;
   the tile internals (value, label, info link) live with the component. */
.qap-kpi-group-row > .qap-kpi-tile {
    flex: 0 1 auto;
    min-width: 11.4286rem;
}

/* Cards (matches Quasar q-card elevation 1) */
.qap-card {
    background: #fff;
    border-radius: 0.2857rem;
    border: 0.0714rem solid rgba(0,0,0,0.12);
    padding: 1.7143rem;
    box-shadow:
        0 0.0714rem 0.3571rem 0 rgba(0,0,0,0.2),
        0 0.1429rem 0.1429rem 0 rgba(0,0,0,0.14),
        0 0.2143rem 0.0714rem -0.1429rem rgba(0,0,0,0.12);
    margin-bottom: 1.7143rem;
}
/* ── .qap-row — standard QAP dashboard card row ──────────────────────────────
   Use with the Bootstrap grid and let the framework do the rest:
       <div class="row qap-row">
         <div class="col-12 col-lg-6"> <card/> </div>
         <div class="col-12 col-lg-6"> <card/> </div>
       </div>
   Provides, so no page needs its own layout fix:
     • equal-height cards — every .qap-card fills its column, so side-by-side
       cards always match height;
     • a consistent horizontal + vertical gutter (no per-row `g-*`);
     • a consistent gap below the row (no reliance on card margin-bottom, which
       breaks the equal-height fill and collapses row-to-row spacing).
   Cols need no `d-flex` and cards need no margin — the row supplies both. */
.qap-row {
    --bs-gutter-x: 1.7143rem;
    --bs-gutter-y: 1.7143rem;
    margin-bottom: 1.7143rem;
}
.qap-row > [class*="col"] { display: flex; }
.qap-row .qap-card { height: 100%; margin-bottom: 0; }
.qap-card-title {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 2.5714rem;
    line-height: 3.8571rem;
    color: var(--qap-primary);
    text-align: center;
    margin: 0 0 0.4286rem;
}
/* Card-title info icon tracks its heading size (em), so it matches whatever
   card header it sits in. Scoped to .qap-card-title — KPI tile icons keep theirs. */
.qap-card-title .qap-tip > i,
.qap-card-title .qap-tip > .qap-tip-btn > i {
    font-size: 0.6667em;
}
.qap-card-sub {
    font-family: 'Lato', sans-serif;
    font-size: 1.7143rem;
    font-weight: 400;
    line-height: 2.5714rem;
    color: var(--qap-primary);
    text-align: center;
    margin: 0 0 1.1429rem;
}
/* Provenance caption under a card title — how much of the network a total is
   actually based on. Deliberately quiet: it qualifies the number above it. */
.qap-card-coverage {
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 400;
    line-height: 1.7143rem;
    color: var(--qap-muted);
    text-align: center;
    margin: 0.2857rem 0 0;
}
.qap-card-body {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    color: var(--qap-primary);
    line-height: 2.1429rem;
}
.qap-card-body p { margin: 0 0 1.1429rem; }
.qap-card-body p:last-child { margin-bottom: 0; }

/* Tabs row */
.qap-tabs-row {
    display: flex;
    justify-content: center;
    gap: 2.2857rem;
    margin: 0.8571rem 0 1.1429rem;
}

/* ======= Sticky SurveyType tabs (NetworkLevel) =======
   The wrap is the sticky's containing block: while the user scrolls within
   the wrap (Average-quality-score chart + criteria-row + Detailed-assessment-
   scores card), the tab strip pins to the top of the viewport just below the
   page-filters bar. Scrolling past the wrap releases the tabs back into flow.
   position: relative on the wrap is what scopes "sticky time" to this
   section instead of the whole page. */
.qap-sticky-tabs-wrap {
    position: relative;
}
.qap-sticky-tabs {
    position: sticky;
    /* Page-filters bar is sticky at top: 0 with inner height 3.5714rem — land the
       tabs flush against its bottom edge. If we lift the page-filters bar's
       height, bump this value too. */
    top: 3.5714rem;
    /* Deliberately NOT --z-sticky (100) — that token is already taken by the
       global page-filters bar. Same value here would put both stacking
       contexts at z-index 100 and the later-in-DOM one (us) would render on
       top of the page-filters' dropdown panel (1000 inside its own context).
       Just 1 — enough to escape default flow stacking so scrolling content
       paints underneath, but well below the page-filters bar so its open
       dropdown still wins. */
    z-index: 1;
    /* Page bg matches qap-bg-grey so the sticky tabs blend into the
       dashboard background as they pin. Thin bottom border + subtle shadow
       cue the user that the bar is floating over content while stuck. */
    background: var(--qap-bg-grey);
    padding: 0.5714rem 0;
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 0.1429rem 0.2857rem rgba(0, 0, 0, 0.04);
}
/* The SurveyTypeTabs component already adds vertical margin via .qap-tabs-row;
   inside the sticky wrap that margin compounds with our padding. Strip it so
   the sticky bar stays a tight, predictable height. */
.qap-sticky-tabs .qap-tabs-row {
    margin: 0;
}
.qap-card-tab {
    background: none;
    border: 0;
    padding: 0.4286rem 0.2857rem;
    font-family: 'Lato', sans-serif;
    font-weight: 500;
    font-size: 1.4286rem;
    line-height: 2.1429rem;
    color: var(--qap-primary);
    opacity: 0.6;
    cursor: pointer;
    border-bottom: 0.1429rem solid transparent;
    letter-spacing: 0.0357rem;
}
.qap-card-tab.active { opacity: 1; border-bottom-color: var(--qap-primary); }
.qap-card-tab:hover { opacity: 1; }
/* Tabs render as <a> under static SSR (query-string navigation) — keep the
   button look. */
a.qap-card-tab { text-decoration: none; display: inline-block; }
/* QapVariantChart: tabs are <label>s wrapping a hidden radio; the active state
   is pure CSS off :checked (no circuit, no JS). Same for the toggle's on-state. */
.qap-card-tab:has(input:checked) { opacity: 1; border-bottom-color: var(--qap-primary); }
.qap-switch-label:has(input:checked) .qap-switch { background: var(--qap-tenant-primary, #0a6aa1); }
.qap-switch-label:has(input:checked) .qap-switch .qap-switch-knob { transform: translateX(1.2857rem); }

/* ======= Sticky page title on the facility page (Facility.razor) =======
   The facility page is one long scroll, so its <h1> — the facility name —
   scrolls out of view almost immediately and the page loses its "which
   facility am I looking at" anchor. Pin that same <h1>; no second copy of the
   name is rendered. Scoped to .qap-facility-body so .qap-section-title stays
   non-sticky on NetworkLevel/Scope/FacilityNumbers/QipMonitoring, which share
   the class.
   DIRECT child (>) on purpose: FacilityQipMonitoring and FacilityAppEngagement
   are pages in their own right that this page also embeds as components, and
   each renders its own .qap-section-title. A descendant selector pins those
   too, and they then collide with this one at the same top offset. */
.qap-facility-body > .qap-section-title {
    position: sticky;
    top: 3.5714rem;               /* flush under .qap-page-filters (see its own comment) */
    z-index: 1;                   /* same layer as .qap-sticky-tabs, below --z-sticky so the
                                      page-filters dropdown still paints over both */
    /* The ONLY declaration beyond sticking it: the title must stay visually
       identical to every other page title, so no border, no shadow, no margin
       change. This matches the page background exactly, so it is invisible at
       rest and simply occludes content scrolling behind it once pinned. */
    background: var(--qap-bg-grey);
}
/* This page's .qap-sticky-tabs sits further down the same scroll. The title
   above stays pinned for the whole page, so the tabs must land under it
   rather than at the filters bar — bumped by the title's stuck height
   (line-height 5.1429rem, the same at every breakpoint; the responsive rules
   change only font-size). The base top: in .qap-sticky-tabs' own rule is
   unchanged for every other consumer. */
.qap-facility-body .qap-sticky-tabs {
    top: calc(3.5714rem + 5.1429rem);
}

/* Controls row: centre the tab strip, park an optional toggle on the right —
   same layout as the App-engagement card, generalised. */
.qap-variant-controls {
    position: relative;
    margin-bottom: 0.5714rem;
    min-height: 2.8571rem;
    display: flex;
    justify-content: center;
    align-items: center;
}
.qap-variant-controls .qap-tabs-row { margin: 0; justify-content: center; }
.qap-variant-controls .qap-switch-label {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}
@media (max-width: 767.98px) {
    .qap-variant-controls { flex-wrap: wrap; }
    .qap-variant-controls .qap-switch-label {
        position: static;
        transform: none;
        justify-content: center;
        margin-top: 0.5714rem;
        width: 100%;
    }
}

/* Chart wrapper makes the chart + legend a single block */
.qap-chart-wrap { display: flex; flex-direction: column; }

/* Fill mode: chart-wrap absolutely positioned to fill parent (home page map). */
.qap-chart-wrap--fill { position: absolute; inset: 0; }
.qap-chart-wrap--fill .qap-chart { flex: 1; min-height: 0; }

/* Pin-map host wraps the chart so the absolutely-positioned popup is
   anchored to the chart area, not the page. */
.qap-pinmap-host { position: absolute; inset: 0; }

/* Click feedback: a "sonar ping" anchored at the clicked dot. The element
   itself is a steady highlight ring (+ soft glow) so the active dot stays
   obvious while the popup is open; its two pseudo-elements fire a few
   expanding rings on click. Colour is the dot's own level colour, passed in
   via --qap-ripple-color. Sits above the chart canvas but below the popup. */
.qap-pinmap-ripple {
    position: absolute;
    width: 1.4286rem;
    height: 1.4286rem;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 15;
    box-shadow:
        0 0 0 0.1429rem var(--qap-ripple-color, #00548e),
        0 0 0.8571rem 0.1429rem var(--qap-ripple-color, #00548e);
    animation: qap-ripple-pop 0.3s ease-out;
}
.qap-pinmap-ripple::before,
.qap-pinmap-ripple::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 0.1429rem solid var(--qap-ripple-color, #00548e);
    animation: qap-ripple-ping 1.4s ease-out 3;
}
.qap-pinmap-ripple::after { animation-delay: 0.5s; }
@keyframes qap-ripple-pop {
    0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes qap-ripple-ping {
    0%   { transform: scale(0.6); opacity: 0.7; }
    100% { transform: scale(3.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .qap-pinmap-ripple { animation: none; }
    .qap-pinmap-ripple::before,
    .qap-pinmap-ripple::after { display: none; }
}

/* Breathing selection highlight on the Mapbox map. Rendered as a Mapbox
   Marker element anchored to the selected facility's coordinates, so it stays
   on the dot while the user pans/zooms. Soft glow ring (transparent centre so
   the dot shows through); colour is the dot's level colour via --qap-hl-color.
   Sizes are rem so it scales with the same root the circle radii key off. */
.qap-map-highlight {
    width: 2.8571rem;
    height: 2.8571rem;
    pointer-events: none;
}
.qap-map-highlight::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle,
        transparent 32%,
        var(--qap-hl-color, #00548e) 47%,
        transparent 76%);
    animation: qap-map-breathe 1.9s ease-in-out infinite;
}
@keyframes qap-map-breathe {
    0%, 100% { transform: scale(0.8); opacity: 0.45; }
    50%      { transform: scale(1.15); opacity: 0.7; }
}
@media (prefers-reduced-motion: reduce) {
    .qap-map-highlight::after { animation: none; opacity: 0.55; }
}

/* Facility popup overlay shown on map-click. Mirrors the legacy QPS
   .popupCard from MapPopupComponent.vue + LevelWidget: round avatar
   overlapping the card, big primary title, primary subtitle, centered
   action button, separator, and a 1–5 level row.

   On ≤ 45.7143rem viewports the popup turns into a bottom-anchored sheet so
   it's always visible regardless of the click position. */
.qap-facility-popup {
    position: absolute;
    z-index: 20;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 0.7143rem 2.1429rem rgba(0, 0, 0, 0.22);
    width: 22.8571rem;
    max-width: calc(100% - 1.7143rem);
    margin-top: 4.2857rem; /* leaves room for the avatar to overlap above */
    padding-bottom: 1.2857rem;
    color: var(--qap-primary);
    font-family: 'Lato', sans-serif;
    pointer-events: auto;
}

.qap-facility-popup-close {
    position: absolute;
    top: 0.4286rem;
    right: 0.7143rem;
    z-index: 2;
    background: transparent;
    border: 0;
    font-size: 1.7143rem;
    line-height: 1;
    color: var(--qap-muted);
    cursor: pointer;
    padding: 0.2857rem 0.5714rem;
}
.qap-facility-popup-close:hover { color: var(--qap-text); }

.qap-facility-popup-avatar {
    position: relative;
    width: 8.5714rem;
    height: 8.5714rem;
    border-radius: 50%;
    background: #b8b8b8;
    border: 0.3571rem solid #fff;
    margin: -4.2857rem auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 4rem;
    font-weight: 700;
    box-shadow: 0 0 0 0.0714rem rgba(0, 0, 0, 0.05);
}
.qap-facility-popup-avatar > span { line-height: 1; }
/* Picture overlays the "?" placeholder; until it has painted the <img> shows
   nothing, so the "?" behind it stays visible. */
.qap-facility-popup-avatar > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.qap-facility-popup-body {
    padding: 1rem 1.5714rem 0;
    text-align: center;
}
.qap-facility-popup-title {
    font-size: 1.5714rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--qap-primary);
}
.qap-facility-popup-subtitle {
    font-size: 1.1429rem;
    font-weight: 400;
    color: var(--qap-primary);
    margin-top: 0.2857rem;
}
.qap-facility-popup-status {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(0, 0, 0, 0.55);
    margin-top: 0.1429rem;
}

.qap-facility-popup-action-row {
    margin-top: 1.1429rem;
    display: flex;
    justify-content: center;
}
.qap-facility-popup-action {
    background: var(--qap-primary);
    color: #fff;
    border: 0;
    border-radius: 0.4286rem;
    padding: 0.7143rem 1.7143rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 10rem;
    /* Rendered as an <a> under static SSR (native nav, no circuit) — keep the
       button look. */
    display: inline-block;
    text-align: center;
    text-decoration: none;
}
.qap-facility-popup-action:hover { background: var(--qap-tenant-primary); }

.qap-facility-popup-divider {
    height: 0.0714rem;
    background: rgba(0, 0, 0, 0.08);
    margin: 1.1429rem 1.5714rem 1rem;
}

.qap-facility-popup-level-row {
    display: flex;
    justify-content: center;
    gap: 0.5714rem;
}
.qap-facility-popup-level-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #d8d8d8;
    color: #fff;
    font-size: 0.9286rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.qap-facility-popup-level-dot.is-active {
    background: var(--qap-primary);
    box-shadow: 0 0 0 0.1429rem rgba(0, 84, 142, 0.18);
}

.qap-facility-popup-level-caption {
    margin-top: 0.7143rem;
    text-align: center;
    font-size: 1rem;
    color: var(--qap-primary);
}
.qap-facility-popup-level-caption.self { color: #edbe41; }

@media (max-width: 640px) {
    .qap-facility-popup {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: auto !important;
        max-width: 100% !important;
        border-radius: 1rem 1rem 0 0;
        margin-top: 4.2857rem;
        padding-bottom: max(1.2857rem, env(safe-area-inset-bottom));
    }
    /* The bottom-sheet already shows the selected facility's own level, so the
       map-wide legend is redundant here and would overlap the sheet — hide it
       while a facility popup is open. It returns when the sheet is closed. */
    .qap-map-area:has(.qap-facility-popup) .qap-overlay-legend {
        display: none;
    }
}

/* Custom chart legend (matches live's Chart.js usePointStyle:circle, padding:40) */
.qap-chart-legend {
    list-style: none;
    margin: 0.2857rem 0 0;
    padding: 0 0 0.5714rem;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2.8571rem;
}
.qap-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.8571rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 400;
    color: #000;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.15s ease;
}
.qap-chart-legend-item:hover { opacity: 0.7; }
.qap-chart-legend-item.off { opacity: 0.4; }
.qap-chart-legend-item.off .qap-chart-legend-dot { background: #c8c8c8 !important; }
.qap-chart-legend-dot {
    width: 1.2857rem;
    height: 1.2857rem;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Pie renderer's own legend (Renderers/Comparison/Pie.razor) keeps its
   inline-styled, side-by-side markup as-is - it is laid out for N pies
   sharing one legend row, unlike the single-chart legend above - but still
   needs the same "toggled off" feedback, scoped to its own item class so
   none of the sizing/spacing rules above leak onto it. */
.qap-pie-legend-item.off { opacity: 0.4; }
.qap-pie-legend-item.off .qap-pie-legend-dot { background: #c8c8c8 !important; }

.qap-card-flex-fill { flex: 1; display: flex; flex-direction: column; }
.qap-card-flex-fill .qap-chart-wrap { flex: 1; }

/* Material outlined select (matches Quasar q-field--outlined q-select) */
.qap-select-field {
    position: relative;
    border: 0.0714rem solid rgba(0,0,0,0.24);
    border-radius: 0.2857rem;
    height: 4rem;
    width: 24.2857rem;
    max-width: 100%;
    background: #fff;
    margin: 1.1429rem 0 1.7143rem;
    padding: 0;
}
.qap-select-field:hover { border-color: rgba(0,0,0,0.6); }
.qap-select-field:focus-within { border-color: var(--qap-primary); border-width: 0.1429rem; padding: 0; }

.qap-select-label {
    position: absolute;
    top: -0.5714rem;
    left: 0.7143rem;
    background: #fff;
    padding: 0 0.4286rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    font-weight: 400;
    color: var(--qap-primary);
    line-height: 1;
    pointer-events: none;
}

.qap-select-input {
    width: 100%;
    height: 100%;
    border: 0;
    outline: 0;
    padding: 0 2.5714rem 0 1rem;
    background: transparent;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: rgba(0,0,0,0.87);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.qap-select-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(0,0,0,0.54);
    font-size: 1rem;
    pointer-events: none;
}

/* Critical criteria row */
.qap-criteria-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2.2857rem;
    margin-bottom: 2.2857rem;
    padding: 1.1429rem;
    flex-wrap: wrap;
}
.qap-criteria { text-align: center; min-width: 10rem; }
.qap-criteria-value {
    font-family: 'Lato', sans-serif;
    font-weight: 900;
    font-size: 4.2857rem;
    line-height: 3.9286rem;
    margin-bottom: 0.5714rem;
}
.qap-criteria-fc { color: #40882e; }
.qap-criteria-pc { color: #91b07c; }
.qap-criteria-nc { color: #ba3a34; }
.qap-criteria-na { color: #a6a6a6; }
.qap-criteria-label {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    color: var(--qap-text);
    line-height: 1.7143rem;
}
.qap-criteria-label > i {
    color: var(--qap-secondary);
    font-size: 1.4286rem;   /* match .qap-kpi-tile-label > i / 1.4286rem label text */
    margin-right: 0.4286rem;
}

/* ======= Detailed assessment scores ======= */
.qap-detailed-filters {
    display: flex;
    gap: 1.1429rem;
    flex-wrap: wrap;
    margin-bottom: 0.5714rem;
}
.qap-detailed-filters .qap-select-field { width: 21.4286rem; flex: 0 1 21.4286rem; }

.qap-detailed-toggles {
    display: flex;
    gap: 2.2857rem;
    flex-wrap: wrap;
    padding: 1.1429rem 0 1.7143rem;
}
.qap-toggle-row {
    display: inline-flex;
    align-items: center;
    gap: 0.8571rem;
    cursor: pointer;
    user-select: none;
}
.qap-toggle-row input[type="checkbox"] {
    /* Keep the input in normal flow at 0×0 instead of position:absolute.
       When the label is clicked the browser moves focus to the input; an
       absolutely-positioned 0-opacity input gets treated as "off-screen"
       and the browser calls scrollIntoView on it, which is what was
       jumping the page to the footer / some other anchor. A static 0×0
       sibling already sits inside the visible label, so focusing it
       doesn't trigger any scroll. */
    appearance: none;
    -webkit-appearance: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}
.qap-toggle-track {
    position: relative;
    width: 2.5714rem;
    height: 1.2857rem;
    background: rgba(0,0,0,0.26);
    border-radius: 0.6429rem;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.qap-toggle-thumb {
    position: absolute;
    top: -0.2143rem;
    left: -0.2143rem;
    width: 1.7143rem;
    height: 1.7143rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0.1429rem 0.2857rem rgba(0,0,0,0.2);
    transition: left 0.15s ease, background 0.15s ease;
}
.qap-toggle-row input:checked ~ .qap-toggle-track { background: rgba(0, 84, 142, 0.5); }
.qap-toggle-row input:checked ~ .qap-toggle-track .qap-toggle-thumb {
    left: 1.0714rem;
    background: var(--qap-primary);
}
.qap-toggle-label {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    color: var(--qap-text);
}

.qap-detailed-legend {
    display: flex;
    gap: 1.7143rem;
    justify-content: center;
    padding: 0.5714rem 0 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    color: var(--qap-text);
}

/* Subtle "refreshing" cue — keeps the grid mounted at full layout height so
   the page doesn't collapse + scroll-jump while waiting for the next response. */
.qap-detailed-grid--refreshing {
    opacity: 0.5;
    transition: opacity 0.15s ease;
    pointer-events: none;
}
/* htmx fragment swap: while the card's GET is in flight, htmx adds
   .htmx-request to it (hx-indicator points at the card itself). Dim + lock the
   card and show a busy cursor so a slow uncached query reads as loading, not
   frozen. */
#qap-detailed-card.htmx-request {
    opacity: 0.55;
    pointer-events: none;
    cursor: progress;
    transition: opacity 0.15s ease;
}
.qap-detailed-legend > span { display: inline-flex; align-items: center; gap: 0.5714rem; }
.qap-legend-bullet {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
}

.qap-detailed-grid {
    display: grid;
    grid-template-columns: minmax(20rem, max-content) 1fr;
    grid-auto-rows: auto;
}
.qap-detailed-label,
.qap-detailed-scores {
    border-bottom: 0.0714rem solid rgba(0, 0, 0, 0.12);
    padding: 0.5714rem;
    box-sizing: border-box;
}
.qap-detailed-label.first,
.qap-detailed-scores.first {
    border-top: 0.0714rem solid rgba(0, 0, 0, 0.12);
}
.qap-detailed-label {
    border-right: 0.0714rem solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 400;
    color: var(--qap-text);
    min-height: 4.5714rem;
}
.qap-detailed-info { background: none; border: 0; padding: 0; line-height: 1; color: var(--qap-secondary); font-size: 1.2857rem; cursor: pointer; }
.qap-detailed-info:hover,
.qap-detailed-info:focus-visible { color: var(--qap-primary); }
/* Criterion info popup body: the leading question's first improvement activity
   in a soft panel, under the shared modal header (number + short name + full
   statement). */
.qap-criterion-qip {
    background: #eef3f9;
    border-radius: 0.4286rem;
    padding: 1rem 1.1429rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--qap-text);
    white-space: pre-wrap;
}
.qap-criterion-qip-empty {
    margin: 0;
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.55);
    font-style: italic;
}
.qap-detailed-criteria {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 25rem;
}
/* Critical-criterion mark. Rendered as a Font Awesome <i class="fa-solid
   fa-exclamation"> to match the legacy QPS look — the color + sizing apply
   directly to the icon glyph. font-weight is irrelevant for FA but kept for
   any non-icon fallback (e.g. screen reader bypass text). */
.qap-detailed-critical {
    color: #ba3a34;
    font-size: 1.2857rem;
}
.qap-detailed-rowlabels {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-text);
    align-self: stretch;
    padding: 0.2857rem 0.5714rem;
}
.qap-detailed-scores {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2857rem;
}
/* Wrapper around each period's bar. display:contents makes it transparent on
   desktop, so the bar sits directly in the .qap-detailed-scores flex column as
   before; the per-bar period label is hidden here (the label column shows it).
   The mobile query below flips both on when the grid stacks. */
.qap-detailed-barrow { display: contents; }
.qap-detailed-barperiod { display: none; }
.qap-detailed-bar {
    display: flex;
    gap: 0.2143rem;
    height: 1.5714rem;
}
.qap-detailed-segment {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    min-width: 0;
}
.qap-detailed-segment-value {
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 500;
    color: #fff;
    padding: 0.1429rem 0.7143rem;
    line-height: 1;
    white-space: nowrap;
}
/* Compliance bucket colors lifted verbatim from legacy QPS
   (quasar.variables.scss: $compliant / $partially-compliant /
   $non-compliant / $not-applicable). Keep these literal — the legend
   bullets in DetailedAssessmentScores.razor reference the same hex codes,
   so any change has to land in both places to stay consistent. */
.qap-bar-fc   { background: #40882e; }
.qap-bar-fcpc { background: #40882e; }
.qap-bar-pc   { background: #9fc397; }
.qap-bar-nc   { background: #ba3a34; }
.qap-bar-na   { background: #a6a6a6; }
.qap-bar-na .qap-detailed-segment-value { color: var(--qap-text); }

/* No-data state: legacy QPS renders a flat gray bar (q-linear-progress
   :value="0" color="not-applicable") when a baseline or endline has no
   in-scope answers. Without this rule the row would collapse to an empty
   transparent strip and the layout would feel inconsistent. */
.qap-detailed-bar--empty {
    background: #a6a6a6;
}

/* Multiselect dropdown built on <details>/<summary>: native open/close
   semantics, no JS interop. Matches the .qap-select-field shell so it sits
   alongside the existing single-select dropdowns visually. */
.qap-multiselect {
    position: relative;
    width: 100%;
}
.qap-multiselect-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    min-height: 3.4286rem;
}
.qap-multiselect-summary::-webkit-details-marker { display: none; }
.qap-multiselect[open] .qap-select-arrow { transform: rotate(180deg); }
.qap-multiselect-menu {
    position: absolute;
    top: calc(100% + 0.2857rem);
    left: 0;
    right: 0;
    /* --z-dropdown (1000) — this menu IS a dropdown, semantically. The
       previous local value (20) was high enough to beat anything nested
       inside its own card but lost to in-content sticky elements like
       .qap-sticky-tabs (z-index 1) when those create stacking contexts
       at the same level in the root context. Tokenizing puts the menu
       firmly above every in-page sticky / chart card and below the
       app-level modal/offcanvas layers, which is the right contract. */
    z-index: var(--z-dropdown);
    max-height: 22.8571rem;
    overflow-y: auto;
    background: #fff;
    border: 0.0714rem solid rgba(0, 0, 0, 0.12);
    border-radius: 0.2857rem;
    box-shadow: 0 0.2857rem 0.8571rem rgba(0, 0, 0, 0.12);
    padding: 0.2857rem 0;
}
.qap-multiselect-option {
    display: flex;
    align-items: center;
    gap: 0.5714rem;
    padding: 0.5714rem 0.8571rem;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    color: var(--qap-text);
    /* Menus can sit in centred containers (.qap-bench-step); a label that
       wraps must stay left-aligned next to its checkbox. */
    text-align: left;
}
.qap-multiselect-option:hover { background: rgba(0, 84, 142, 0.06); }
.qap-multiselect-option input[type="checkbox"],
.qap-multiselect-option input[type="radio"] {
    width: 1.1429rem;
    height: 1.1429rem;
    accent-color: var(--qap-primary);
    margin: 0;
    flex-shrink: 0;
}

.qap-collapse-toggle {
    display: block;
    width: 100%;
    background: none;
    border: 0;
    padding: 1.1429rem;
    margin-top: 0.5714rem;
    cursor: pointer;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    color: var(--qap-bright-blue);
    text-transform: uppercase;
    letter-spacing: 0.0357rem;
}
.qap-collapse-toggle:hover { text-decoration: underline; }

.qap-detailed-footer {
    padding: 0.5714rem 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    color: var(--qap-primary);
    line-height: 1.5;
}
.qap-detailed-footer p { margin: 0.5714rem 0; }
.qap-detailed-footer .qap-detailed-critical { font-size: 1.4286rem; }

/* ======= Detailed assessment scores — stack on narrow screens =======
   The 2-column grid puts a ~20rem label beside the bars; once the viewport
   gets small the bars are starved and the % labels clip / overflow. Below md
   we drop to one column: the criterion header sits on top and each period's
   bar moves to a full-width row below it, prefixed with its Baseline/Endline
   label (the desktop label column is hidden). */
@media (max-width: 767.98px) {
    .qap-detailed-grid { grid-template-columns: 1fr; }

    /* Connect the header to its own bars (no divider/min-height); let a long
       criterion name wrap now that there's vertical room. */
    .qap-detailed-label {
        border-right: 0;
        border-bottom: 0;
        min-height: 0;
        flex-wrap: wrap;
        padding-bottom: 0;
    }
    .qap-detailed-criteria { white-space: normal; max-width: none; overflow: visible; }
    .qap-detailed-rowlabels { display: none; }

    /* First row's scores keeps no top border — that line belongs above the
       header, not between the header and its bars. */
    .qap-detailed-scores.first { border-top: 0; }
    /* Wider gap (one rem step up from the desktop 0.2857rem) separates the two
       period groups; the in-group label→bar gap stays at the base step. */
    .qap-detailed-scores { gap: 0.8571rem; }

    .qap-detailed-barrow { display: flex; flex-direction: column; gap: 0.2857rem; }
    .qap-detailed-barperiod {
        display: block;
        font-family: 'Lato', sans-serif;
        font-size: 1.1429rem;
        color: var(--qap-text);
    }
}

/* ======= Network Level mobile ======= */
@media (max-width: 991.98px) {
    .qap-network-body { padding: 1.1429rem; }
    .qap-section-title { font-size: 2.5714rem; }
    .qap-card-title { font-size: 1.5714rem; }
    .qap-kpi-groups { grid-template-columns: 1fr; gap: 1.1429rem; }
    .qap-kpi-group + .qap-kpi-group { border-left: 0; border-top: 0.0714rem solid rgba(0,0,0,0.08); padding-top: 1.7143rem; }
    .qap-kpi-group-row { flex-wrap: wrap; }
    .qap-kpi-group-row > .qap-kpi-tile .qap-kpi-tile-value { font-size: 3.1429rem; }
    .qap-criteria-value { font-size: 2.5714rem; }
}

@media (max-width: 575.98px) {
    .qap-section-title { font-size: 2rem; }
    .qap-kpi-group-row > .qap-kpi-tile { min-width: 9.2857rem; }
    .qap-kpi-group-row > .qap-kpi-tile .qap-kpi-tile-value { font-size: 2.5714rem; }
    .qap-tabs-row { gap: 0.8571rem; flex-wrap: wrap; }
    .qap-criteria-row { gap: 1.1429rem; }
}

/* ======= Mobile responsive tweaks ======= */
@media (max-width: 991.98px) {
    .qap-overlay-find {
        width: calc(100% - 1.4286rem);
        max-width: 29.4286rem;
    }
    /* Reserve room at the bar's right edge for the in-bar filter icon so
       the search/clear icon sits just to its left. */
    .qap-find { padding-right: 2.8571rem; }
}

@media (max-width: 991.98px) {
    .qap-logo { min-width: 0; padding: 0.5714rem 0.8571rem; }
    .qap-logo img { height: 2.5714rem; }
    .qap-toggle { padding: 0 0.8571rem; }
    .qap-header-btn { padding: 0 0.8571rem; }
    .qap-lang { padding: 0 0.8571rem; }
}

@media (max-width: 575.98px) {
    .qap-header { height: 4.2857rem; }
    .qap-logo img { height: 2.1429rem; }
    .qap-overlay-legend {
        font-size: 0.7857rem;
        padding: 0.5714rem 0.7143rem;
        gap: 0.4286rem 0.8571rem;
    }
    .qap-overlay-legend-items { gap: 0.4286rem 0.8571rem; }
}

/* ======= Scope page ======= */
.qap-scope-body { padding: 1.7143rem; max-width: 107.1429rem; margin: 0 auto; width: 100%; }

/* Payer view: the external dashboard fills everything below the header. */
.qap-payer-view { display: flex; flex-direction: column; width: 100%; min-height: calc(100vh - 4.5rem); background: #fff; }
.qap-payer-view-frame { flex: 1 1 auto; width: 100%; min-height: calc(100vh - 4.5rem); border: 0; }

.qap-scope-loading,
.qap-scope-empty {
    display: flex; align-items: center; justify-content: center;
    gap: 0.7143rem;
    padding: 2.8571rem;
    color: rgba(0, 0, 0, 0.55);
    font-family: 'Lato', sans-serif;
}
.qap-scope-loading .spinner-border {
    color: var(--qap-tenant-primary, #0a6aa1);
}

.qap-scope-summary {
    display: flex; align-items: center;
    gap: 2.2857rem;
    flex-wrap: wrap;
    margin: 1.1429rem 0 1.4286rem;
    padding: 1.1429rem 1.7143rem;
    background: #fff;
    border-radius: 0.5714rem;
    box-shadow: 0 0.0714rem 0.2143rem rgba(0, 0, 0, 0.08);
}
.qap-scope-summary-stat { display: flex; flex-direction: column; }
.qap-scope-summary-value {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 2.2857rem;
    line-height: 1.1;
    color: var(--qap-primary);
}
.qap-scope-summary-label {
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    color: rgba(0, 0, 0, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.qap-scope-summary-refresh {
    margin-left: auto;
    display: flex; align-items: center; gap: 0.5714rem;
    font-size: 0.8571rem;
    color: rgba(0, 0, 0, 0.55);
    font-family: 'Lato', sans-serif;
}
.qap-scope-summary-refresh .spinner-border {
    color: var(--qap-tenant-primary, #0a6aa1);
}

.qap-scope-table-wrap {
    background: #fff;
    border-radius: 0.5714rem;
    box-shadow: 0 0.0714rem 0.2143rem rgba(0, 0, 0, 0.08);
    overflow: auto;
}
.qap-scope-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
}
.qap-scope-table thead th {
    text-align: left;
    padding: 0.8571rem 1.1429rem;
    background: #f5f7fa;
    color: var(--qap-primary);
    font-weight: 600;
    border-bottom: 0.0714rem solid #e3e8ee;
    white-space: nowrap;
}
.qap-scope-table th.num,
.qap-scope-table td.num { text-align: right; }
.qap-scope-table tbody td {
    padding: 0.7143rem 1.1429rem;
    border-bottom: 0.0714rem solid #eef1f4;
    color: var(--qap-text);
}
.qap-scope-table tbody tr:last-child td { border-bottom: 0; }
.qap-scope-table tbody tr:hover td { background: #f8fafc; }
.qap-scope-table td.mono {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 0.8571rem;
    color: rgba(0, 0, 0, 0.7);
}
.qap-scope-facility-link {
    color: var(--qap-primary);
    text-decoration: none;
    font-weight: 600;
}
.qap-scope-facility-link:hover { text-decoration: underline; }
.qap-scope-fid {
    color: rgba(0, 0, 0, 0.4);
    font-size: 0.7857rem;
    margin-left: 0.4286rem;
}
.qap-scope-empty-row {
    text-align: center;
    padding: 2.2857rem;
    color: rgba(0, 0, 0, 0.5);
    font-style: italic;
}

.qap-scope-pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1.1429rem;
    margin-top: 1.1429rem;
    padding: 0.8571rem 0.2857rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    color: rgba(0, 0, 0, 0.6);
}
.qap-scope-pager-info { flex: 1; text-align: center; }
.qap-scope-pager-btn {
    background: #fff;
    border: 0.0714rem solid #ccd1d9;
    color: var(--qap-primary);
    padding: 0.4286rem 1rem;
    border-radius: 0.2857rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
}
.qap-scope-pager-btn:hover:not(:disabled):not(.disabled) {
    background: #f5f7fa;
    border-color: var(--qap-tenant-primary, #0a6aa1);
}
.qap-scope-pager-btn:disabled,
.qap-scope-pager-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.qap-scope-pager-size { margin: 0; }
.qap-scope-pager-size label {
    display: inline-flex;
    align-items: center;
    gap: 0.5714rem;
    color: rgba(0, 0, 0, 0.6);
}
.qap-scope-pager-size select {
    border: 0.0714rem solid #ccd1d9;
    border-radius: 0.2857rem;
    padding: 0.2857rem 0.5714rem;
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    color: var(--qap-primary);
    background: #fff;
    cursor: pointer;
}
.qap-scope-pager-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.8571rem;
}

/* ======= "Coming soon" placeholder pages ======= */
.qap-coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2.8571rem 1.4286rem;
}
.qap-coming-soon-card {
    max-width: 38.5714rem;
    text-align: center;
    background: #fff;
    border: 0.0714rem solid rgba(0,0,0,0.06);
    border-radius: 0.7143rem;
    box-shadow: 0 0.1429rem 1rem rgba(0,0,0,0.06);
    padding: 3.1429rem 2.8571rem;
}
.qap-coming-soon-icon {
    width: 4.5714rem;
    height: 4.5714rem;
    margin: 0 auto 1.4286rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--qap-secondary-light, #eaf3f8);
    color: var(--qap-tenant-primary, #0a6aa1);
    font-size: 1.8571rem;
}
.qap-coming-soon-badge {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.2857rem 0.8571rem;
    border-radius: 71.3571rem;
    background: var(--qap-secondary-light, #eaf3f8);
    color: var(--qap-tenant-primary, #0a6aa1);
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.qap-coming-soon-title {
    margin: 0 0 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.8571rem;
    font-weight: 700;
    color: #1a1a1a;
}
.qap-coming-soon-text {
    margin: 0 auto;
    max-width: 30rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.0714rem;
    line-height: 1.6;
    color: rgba(0,0,0,0.6);
}
.qap-coming-soon-thanks {
    margin-top: 1rem;
    font-style: italic;
}

/* ======= Shared KPI tile (<QapKpi>) =======
   The single source of truth for big-number KPI tiles. Used by the Quality
   Status group at the top of NetworkLevel and the Network QIP Monitoring strip.
   The tile owns its internals (value, optional "/ total", label, optional bar,
   optional "Show info" link); the surrounding strip/group owns layout +
   dividers. Kept global (not CSS-isolated) to match the rest of site.css. */
.qap-kpi-tile {
    flex: 1 1 auto;
    text-align: center;
}
.qap-kpi-tile-value-row {
    display: flex;
    justify-content: center;
    align-items: flex-end;   /* "/ total" sits on the value's baseline */
    gap: 0.4286rem;
    white-space: nowrap;     /* never wrap "/ total" into the middle of the number */
    margin-bottom: 0.5714rem;
}
.qap-kpi-tile-value {
    font-family: 'Lato', sans-serif;
    font-weight: 900;
    font-size: 4.2857rem;
    line-height: 3.9286rem;
    color: #40882e;
}
.qap-kpi-tile-value--blue { color: #00548e; }
.qap-kpi-tile-value--green { color: #40882e; }
.qap-kpi-tile-value--greenlight { color: #91b07c; }
.qap-kpi-tile-value--red { color: #c0392b; }
.qap-kpi-tile-value--gold { color: #edbe41; }
/* Secondary "(19%)" next to a KPI count — smaller, tone-coloured via the
   shared .qap-kpi-tile-value--<tone> colour, sits on the value's baseline. */
.qap-kpi-tile-pct {
    font-family: 'Lato', sans-serif;
    font-size: 1.7143rem;
    font-weight: 700;
    line-height: 2.2857rem;
}
.qap-kpi-tile-total {
    font-family: 'Lato', sans-serif;
    font-size: 1.7143rem;
    font-weight: 400;
    line-height: 2.2857rem;
    color: rgba(0,0,0,0.25);
}
.qap-kpi-tile-label {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    color: var(--qap-text);
    line-height: 1.7143rem;
}
/* Info icon + hover/focus tooltip. The icon is wrapped in .qap-tip so the
   tooltip can position relative to it. 1.4286rem icon matches the 1.4286rem label text
   (and the original QPS info icon); 1.1429rem native title was replaced with this
   styled popup to match the legacy q-tooltip. */
.qap-tip {
    position: relative;
    display: inline-block;
    margin-right: 0.4286rem;
}
/* The icon is a direct <i> for hint-only tips and an <i> inside a bare <button>
   for clickable ones (native popover invoker) — both must look identical. */
.qap-tip > i,
.qap-tip-btn > i {
    color: var(--qap-secondary);
    font-size: 1.4286rem;
    cursor: help;
}
.qap-tip--clickable > i,
.qap-tip-btn > i { cursor: pointer; }
.qap-tip--clickable > i:hover { color: var(--qap-primary); }
/* Bare-button reset so the invoker adds no chrome — but DON'T inherit color/font
   onto the icon (that reset the icon to the surrounding dark text and dropped its
   size); the combined .qap-tip-btn > i rule above owns the icon's look. */
.qap-tip-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    line-height: 0;
}
.qap-tip-btn:hover > i,
.qap-tip-btn:focus-visible > i { color: var(--qap-primary); }
.qap-tip-text {
    position: absolute;
    bottom: calc(100% + 0.7143rem);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 18.5714rem;
    background: var(--qap-text);
    color: #fff;
    border-radius: 0.4286rem;
    padding: 0.5714rem 0.8571rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    box-shadow: 0 0.2857rem 0.8571rem rgba(0,0,0,0.22);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    z-index: 100;
    pointer-events: none;
}
.qap-tip:hover .qap-tip-text,
.qap-tip:focus-within .qap-tip-text {
    opacity: 1;
    visibility: visible;
}

/* Progressive enhancement: where CSS anchor positioning is supported, the
   bubble auto-shifts/flips to stay on-screen ANYWHERE on the page — no
   above. Scoped to the shared .qap-tip primitive, so every tooltip (tile,
   drawer, anything reusing it) inherits the behaviour. */
@supports (anchor-name: --a) {
    /* anchor-scope keeps each wrapper's name local, so a page full of tooltips
       each binds to its own icon rather than the first/last one. */
    .qap-tip { anchor-scope: --qap-tip; }
    .qap-tip > i,
    .qap-tip > .qap-tip-btn > i { anchor-name: --qap-tip; }

    .qap-tip-text {
        position: fixed;                 /* viewport-relative → real edge detection */
        position-anchor: --qap-tip;
        position-area: top;              /* centered above the icon */
        inset: auto;                     /* drop the fallback bottom/left */
        transform: none;
        margin: 0 0 0.7143rem 0;         /* gap between bubble and icon */
        position-try-fallbacks:
            --qap-tip-shift-end,         /* near left edge: left-align, open right */
            --qap-tip-shift-start,       /* near right edge: right-align, open left */
            flip-block;                  /* no room above: drop below */
    }

    @position-try --qap-tip-shift-end { position-area: top span-inline-end; }
    @position-try --qap-tip-shift-start { position-area: top span-inline-start; }
}

.qap-kpi-tile-bar {
    margin-top: 0.8571rem;
    height: 0.4286rem;
    border-radius: 0.2143rem;
    background: rgba(0,0,0,0.1);
    overflow: hidden;
}
.qap-kpi-tile-bar-fill {
    height: 100%;
    border-radius: 0.2143rem;
}
.qap-kpi-tile-bar-fill--blue { background: #00548e; }
.qap-kpi-tile-bar-fill--green { background: #40882e; }
.qap-kpi-tile-bar-fill--red { background: #c0392b; }
.qap-kpi-tile-bar-fill--gold { background: #edbe41; }
.qap-kpi-tile-info {
    display: inline-block;
    margin-top: 0.2857rem;
    padding: 0;
    background: none;
    border: 0;
    text-align: left;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    line-height: 2.4286rem;
    color: var(--qap-bright-blue);
    text-decoration: none;
    cursor: pointer;
}
.qap-kpi-tile-info:hover { text-decoration: underline; }

/* ======= Network QIP Monitoring ======= */
.qap-qip-monitoring {
    margin-top: 1.7143rem;
}

/* KPI strip — a flex row of shared <QapKpi> tiles (.qap-kpi-tile*, defined in
   the "Shared KPI tile" block below). This rule only owns the strip layout:
   equal-width columns, vertical dividers, wrap when a column gets too narrow. */
.qap-qip-kpis {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    margin-bottom: 2.2857rem;
    flex-wrap: wrap;
}
.qap-qip-kpis > .qap-kpi-tile {
    flex: 1 1 auto;
    min-width: 12.8571rem;
    padding: 0 1.4286rem;
}
.qap-qip-kpis > .qap-kpi-tile + .qap-kpi-tile {
    border-left: 0.0714rem solid rgba(0,0,0,0.08);
}

/* Search box */
.qap-qip-search {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 22.8571rem;
    margin: 0 0 1.4286rem;
    border: 0.0714rem solid rgba(0,0,0,0.2);
    border-radius: 0.2857rem;
    padding: 0 0.8571rem;
    height: 3.4286rem;
}
.qap-qip-search > i.fa-magnifying-glass {
    color: var(--qap-secondary);
    margin-right: 0.7143rem;
}
.qap-qip-search input {
    flex: 1;
    border: 0;
    outline: 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    color: var(--qap-text);
    background: transparent;
}
.qap-qip-search-clear {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--qap-primary);
    font-size: 1.1429rem;
    padding: 0.2857rem;
}

/* Table */
.qap-qip-table-wrap {
    overflow-x: auto;
}
.qap-qip-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Lato', sans-serif;
    /* 1.4286rem = QAP's main-content scale (.qap-card-body / KPI labels) and what
       the legacy QPS FilterTable used. Smaller (14–1.1429rem) reads as cramped UI
       chrome next to the rest of the page. */
    font-size: 1.4286rem;
    color: var(--qap-text);
}
.qap-qip-table thead th {
    background: var(--qap-secondary-light);
    color: var(--qap-primary);
    font-weight: 700;
    font-size: 1.4286rem;
    text-align: left;
    padding: 1rem 1.1429rem;
    white-space: nowrap;
}
.qap-qip-table tbody td {
    padding: 0.8571rem 1.1429rem;
    border-top: 0.0714rem solid rgba(0,0,0,0.06);
}
.qap-qip-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.02);
}
.qap-qip-td-name {
    font-weight: 600;
    text-decoration: underline;
    color: var(--qap-text);
}
.qap-qip-td-name a {
    color: inherit;
    text-decoration: inherit;
}
.qap-qip-empty {
    text-align: center;
    color: rgba(0,0,0,0.5);
    padding: 2.2857rem 1.1429rem !important;
    font-style: italic;
}
.qap-qip-footnote {
    margin: 1.1429rem 0 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    font-style: italic;
    color: rgba(0,0,0,0.55);
}

/* Pager */
.qap-qip-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8571rem;
    margin-top: 1.1429rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-text);
}
.qap-qip-pager-range {
    color: rgba(0,0,0,0.6);
}
.qap-qip-pager-controls {
    display: flex;
    align-items: center;
    gap: 1.1429rem;
}
.qap-qip-pager-page {
    color: rgba(0,0,0,0.6);
    min-width: 7.8571rem;
    text-align: center;
}
.qap-qip-pager-size {
    display: inline-flex;
    align-items: center;
    gap: 0.5714rem;
    color: rgba(0,0,0,0.6);
}
/* Match the Previous/Next pager buttons: white field, primary text, custom
   chevron (native arrow removed) so it reads as part of the same control set. */
.qap-qip-pager-size select {
    appearance: none;
    -webkit-appearance: none;
    border: 0.0714rem solid rgba(0,0,0,0.2);
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2300548e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8571rem center;
    background-size: 0.8571rem;
    border-radius: 0.2857rem;
    padding: 0.5714rem 2.2857rem 0.5714rem 1rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-primary);
    cursor: pointer;
}
.qap-qip-pager-size select:hover { background-color: var(--qap-secondary-light); }
.qap-qip-pager-size select:focus-visible {
    outline: 0;
    border-color: var(--qap-primary);
}

/* Style-guide "Page anatomy" frame — renders the composed demo on the real
   grey app background so cards read as cards, the way a live page looks.
   Scoped overrides neutralise the section's page-level top margin / width so
   it sits cleanly inside the guide's content column. */
.qap-sg-page {
    background: var(--qap-bg-grey);
    border: 0.0714rem solid var(--qap-border);
    border-radius: 0.5714rem;
    padding: 1.7143rem;
    overflow: hidden;
}
.qap-sg-page .qap-section {
    margin: 0;
    max-width: none;
    padding: 0;
}
.qap-sg-page .qap-section-title { margin-top: 0; }
.qap-qip-pager-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    border: 0.0714rem solid rgba(0,0,0,0.2);
    background: #fff;
    border-radius: 0.2857rem;
    padding: 0.5714rem 1rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-primary);
    cursor: pointer;
}
.qap-qip-pager-btn:hover:not(:disabled) {
    background: var(--qap-secondary-light);
}
.qap-qip-pager-btn:disabled {
    color: rgba(0,0,0,0.3);
    cursor: default;
}

/* ======= QIP monitoring pager — stack on narrow screens =======
   The controls row (Show N / Previous / Page X of Y / Next) doesn't wrap, so on
   small screens it overflows the card. Below md we stack the pager: range on
   top, then the "Show N" selector on its own line, then Previous — Page — Next
   spread across the row so the buttons sit at the edges and nothing overflows. */
@media (max-width: 767.98px) {
    /* Stack range over controls; both keep their existing desktop gaps. */
    .qap-qip-pager { flex-direction: column; align-items: stretch; }
    .qap-qip-pager-range { text-align: center; }
    .qap-qip-pager-controls { flex-wrap: wrap; }
    .qap-qip-pager-size { flex-basis: 100%; justify-content: center; }
    /* Let the page indicator grow so Previous/Next are pushed to the edges,
       and shrink below its desktop min-width on very narrow phones. */
    .qap-qip-pager-page { flex: 1; min-width: 0; }
}

/* ======= Reusable toggle switch (QapSwitch) =======
   Wraps the existing .qap-switch / .qap-switch-knob / .on visual (also used by
   the user-menu Debug toggle in MainLayout) in a clickable, labelled button so
   it can be dropped in anywhere. Layout/positioning is the parent's job. */
.qap-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 0.7143rem;
    background: none;
    border: 0;
    padding: 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-text);
    cursor: pointer;
    user-select: none;
}
.qap-switch-label .qap-switch {
    margin-left: 0;   /* the base .qap-switch uses margin-left:auto for the menu row */
}
.qap-switch-label:focus-visible {
    outline: none;
}
.qap-switch-label:focus-visible .qap-switch {
    box-shadow: 0 0 0 0.2143rem rgba(60,145,227,0.4);
}

/* ======= Style guide page (/styleguide) ======= */
.qap-sg-intro {
    max-width: 58.5714rem;
    margin: 0 auto 0.5714rem;
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    line-height: 1.5;
    color: var(--qap-text);
}
.qap-sg code {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: var(--qap-secondary-light);
    color: var(--qap-dark);
    padding: 0.0714rem 0.4286rem;
    border-radius: 0.2857rem;
}
.qap-sg-toc {
    position: sticky;
    top: 1.1429rem;
    background: #fff;
    border: 0.0714rem solid var(--qap-border);
    border-radius: 0.5714rem;
    padding: 1.1429rem;
}
.qap-sg-toc-title {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    color: var(--qap-primary);
    margin-bottom: 0.5714rem;
}
.qap-sg-toc a {
    display: block;
    padding: 0.4286rem 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-bright-blue);
    text-decoration: none;
}
.qap-sg-toc a:hover { text-decoration: underline; }

.qap-sg-block {
    background: #fff;
    border: 0.0714rem solid var(--qap-border);
    border-radius: 0.5714rem;
    padding: 1.7143rem;
    margin-bottom: 1.7143rem;
}
.qap-sg-h {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    color: var(--qap-primary);
    margin: 0 0 0.5714rem;
}
.qap-sg-h3 {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 1.4286rem;
    color: var(--qap-text);
    margin: 1.7143rem 0 0.5714rem;
}
.qap-sg-desc {
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    line-height: 1.5;
    color: var(--qap-text);
    margin: 0 0 1.1429rem;
}
.qap-sg-demo {
    border: 0.0714rem dashed var(--qap-border);
    border-radius: 0.5714rem;
    padding: 1.7143rem;
    margin-bottom: 0.8571rem;
    background: #fcfdfe;
}
.qap-sg-state {
    margin: 0.8571rem 0 0;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-muted);
}
.qap-sg-code {
    background: var(--qap-dark);
    color: #eaf2f8;
    border-radius: 0.5714rem;
    padding: 1.1429rem;
    overflow-x: auto;
    margin: 0 0 0.8571rem;
}
.qap-sg-code code {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.9643rem;
    line-height: 1.55;
    background: none;
    color: inherit;
    padding: 0;
    white-space: pre;
}
.qap-sg-notes {
    margin: 0.5714rem 0 0;
    padding-left: 1.4286rem;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    line-height: 1.5;
    color: var(--qap-text);
}
.qap-sg-notes li { margin-bottom: 0.4286rem; }
.qap-sg-notes--lg { font-size: 1.2857rem; }

/* Token swatches */
.qap-sg-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.1429rem, 1fr));
    gap: 0.8571rem;
    margin-bottom: 0.8571rem;
}
.qap-sg-swatch {
    display: flex;
    gap: 0.8571rem;
    align-items: center;
    border: 0.0714rem solid var(--qap-border);
    border-radius: 0.5714rem;
    padding: 0.7143rem;
}
.qap-sg-swatch-chip {
    width: 3.1429rem;
    height: 3.1429rem;
    border-radius: 0.4286rem;
    border: 0.0714rem solid rgba(0,0,0,0.1);
    flex: 0 0 auto;
}
.qap-sg-swatch-name {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    color: var(--qap-text);
}
.qap-sg-swatch-use {
    font-family: 'Lato', sans-serif;
    font-size: 0.9286rem;
    color: var(--qap-muted);
    margin-top: 0.1429rem;
}

/* Tables */
.qap-sg-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Lato', sans-serif;
    font-size: 1.1429rem;
    color: var(--qap-text);
}
.qap-sg-table th {
    text-align: left;
    background: var(--qap-secondary-light);
    color: var(--qap-primary);
    padding: 0.7143rem 0.8571rem;
}
.qap-sg-table td {
    padding: 0.7143rem 0.8571rem;
    border-top: 0.0714rem solid var(--qap-border);
    vertical-align: top;
}

/* Grid demo blocks */
.qap-sg-griddemo {
    background: var(--qap-secondary-light);
    border: 0.0714rem solid var(--qap-secondary);
    border-radius: 0.4286rem;
    padding: 1.1429rem;
    text-align: center;
    font-family: ui-monospace, monospace;
    font-size: 0.9286rem;
    color: var(--qap-primary);
}

/* ======= App engagement & QIP progress per month ======= */
/* Tabs are centred in the card (like the title); the aggregate toggle floats
   to the right edge, absolutely positioned so it doesn't pull the tabs
   off-centre. Stacks below the tabs on small screens. */
.qap-app-engagement-controls {
    position: relative;
    margin-bottom: 0.5714rem;
    min-height: 2.8571rem;
}
.qap-app-engagement-tabs {
    margin: 0;
    justify-content: center;
}
.qap-app-engagement-controls .qap-switch-label {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}
@media (max-width: 767.98px) {
    .qap-app-engagement-controls .qap-switch-label {
        position: static;
        transform: none;
        justify-content: center;
        margin-top: 0.5714rem;
        width: 100%;
    }
}

/* Facility app-usage ranking — horizontal bars. label | track | value grid;
   bars scale to the global max so pages line up. */
.qap-ranking-rows {
    display: flex;
    flex-direction: column;
    gap: 0.857rem;
    padding-top: 0.5714rem;
    /* Match the QIP-monitoring table's content text (20px at the design root). */
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    gap: 0.5714rem;
}
.qap-ranking-row {
    display: grid;
    /* Fixed columns so every row's track is the same width — a wider label or a
       wider "100 %" value must not shrink its own bar. Label wide enough for
       most facility names before ellipsis. */
    grid-template-columns: minmax(0, 32rem) 1fr 4.5rem;
    align-items: center;
    gap: 1rem;
}
.qap-ranking-label {
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #002c4a;
}
.qap-ranking-track {
    background: #e6ecf2;
    border-radius: 0.2857rem;
    height: 1.7143rem;
    overflow: hidden;
}
.qap-ranking-bar {
    background: #00548e;
    height: 100%;
    border-radius: 0.2857rem;
    min-width: 0.1429rem;
    transition: width 0.4s ease;
}
.qap-ranking-value {
    font-weight: 700;
    color: #00548e;
    white-space: nowrap;
    text-align: right;
}

/* Loading overlay for htmx tab/sort/expand swaps. htmx adds .htmx-request to
   #ranking-loading (referenced via hx-indicator) for the duration of the fetch. */
.qap-ranking-viewport {
    position: relative;
}
#ranking-loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.65);
    z-index: 2;
}
#ranking-loading.htmx-request {
    display: flex;
}
#ranking-loading i {
    font-size: 2.2857rem;
    color: var(--qap-primary);
}

@media (max-width: 767.98px) {
    .qap-ranking-row {
        grid-template-columns: minmax(0, 8rem) 1fr 4rem;
        gap: 0.5714rem;
    }
}

/* Reusable "Show dates" reveal (QapShowDates) — native <details>, no circuit. */
.qap-show-dates-summary {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2857rem;
    cursor: pointer;
    color: #002c4a;
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    letter-spacing: 0.0357rem;
    padding: 0.8571rem;
}
.qap-show-dates-summary::-webkit-details-marker { display: none; }
.qap-show-dates-summary::marker { content: ""; }
.qap-show-dates[open] .qap-show-dates-chevron { transform: rotate(180deg); }
.qap-show-dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1.7143rem 1rem;
    border-top: 0.0714rem solid #d7dde3;
    border-bottom: 0.0714rem solid #d7dde3;
    padding: 1.7143rem 0;
    text-align: center;
}
.qap-show-dates-item {
    display: flex;
    flex-direction: column;
    gap: 0.5714rem;
}
.qap-show-dates-label {
    text-transform: uppercase;
    font-size: 1.1429rem;
    letter-spacing: 0.0357rem;
    color: #002c4a;
}
.qap-show-dates-value {
    font-weight: 700;
    color: #002c4a;
    text-transform: uppercase;
}

/* Facility QIP tasks — status groups (native <details>) + per-row info reveal. */
.qap-qip-group {
    border: 0.0714rem solid #e1e6eb;
    border-radius: 0.4286rem;
    margin-bottom: 0.8571rem;
    overflow: hidden;
}
.qap-qip-group-head {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.4286rem;
    background: #eef1f4;
    cursor: pointer;
}
.qap-qip-group-head::-webkit-details-marker { display: none; }
.qap-qip-group-count { font-size: 1.7143rem; font-weight: 700; color: #20558a; min-width: 2.5rem; }
.qap-qip-group-title { font-weight: 700; color: #002c4a; letter-spacing: 0.0357rem; }
.qap-qip-icon { font-size: 0.85em; }
.qap-qip-icon--out { color: #d64545; }
.qap-qip-icon--prog { color: #3c91e3; }
.qap-qip-icon--appr { color: #40882e; }
.qap-qip-group-chev { margin-left: auto; color: #20558a; transition: transform 0.2s; }
.qap-qip-group[open] .qap-qip-group-chev { transform: rotate(180deg); }
.qap-qip-group-body { background: #fff; }

.qap-qip-row { border-top: 0.0714rem solid #eef1f4; }
.qap-qip-row-head {
    list-style: none;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.4286rem;
    cursor: pointer;
}
.qap-qip-row-head::-webkit-details-marker { display: none; }
.qap-qip-row:nth-child(even) { background: #f6f8fa; }
.qap-qip-compliance { font-weight: 700; color: #20558a; min-width: 2.2rem; }
.qap-qip-row-main { flex: 1; display: flex; flex-direction: column; gap: 0.4286rem; }
.qap-qip-row-top { display: flex; align-items: center; gap: 0.5714rem; flex-wrap: wrap; }
.qap-qip-num { font-weight: 700; color: #002c4a; }
.qap-qip-critical { color: #d64545; }
.qap-qip-chip {
    background: #20558a;
    color: #fff;
    border-radius: 0.2857rem;
    padding: 0.2143rem 0.5714rem;
    font-size: 1.1429rem;
}
.qap-qip-row-text { color: #002c4a; }
.qap-qip-row-chev { color: #20558a; transition: transform 0.2s; margin-top: 0.2857rem; }
.qap-qip-row[open] .qap-qip-row-chev { transform: rotate(90deg); }
.qap-qip-info {
    margin: 0 1.4286rem 1.4286rem 4.2rem;
    border: 0.0714rem solid #e1e6eb;
    border-radius: 0.4286rem;
}
.qap-qip-info-head {
    text-align: center;
    color: #20558a;
    font-size: 1.1429rem;
    letter-spacing: 0.0357rem;
    padding: 0.5714rem;
    border-bottom: 0.1429rem solid #20558a;
}
.qap-qip-info-body { padding: 1.1429rem; white-space: pre-line; color: #002c4a; }
.qap-qip-empty { padding: 1rem 1.4286rem; color: #667; }
.qap-qip-tasks-note { color: #20558a; font-size: 1.1429rem; margin-top: 1rem; }

/* QIP-tasks filters row + htmx loading dim. Same shell/spacing as
   .qap-detailed-filters; search reuses the .qap-select-field box, with the icon
   overlaid and the input padded past it (no floating label, no dropdown arrow). */
.qap-qip-tasks-filters {
    display: flex;
    align-items: center;
    gap: 1.1429rem;
    flex-wrap: wrap;
    margin-bottom: 0.5714rem;
}
.qap-qip-tasks-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(0,0,0,0.54);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
}
.qap-qip-tasks-search .qap-qip-tasks-search-input {
    padding: 0 1rem 0 2.7143rem;
    cursor: text;
}
.qap-qip-tasks-search .qap-qip-tasks-search-input::-webkit-search-cancel-button { cursor: pointer; }
.qap-qip-tasks.htmx-request { opacity: 0.55; pointer-events: none; transition: opacity 0.1s; }

/* Hide the QIP KPI bars below xl (Bootstrap 85.7129rem) — the point at which the
   five tiles can no longer hold a single row. Only two of the five carry a bar,
   so once wrapped they sit next to bar-less tiles at ragged heights (and the
   lone bottom tile gets a stretched full-width bar). On one row the two bars
   share a baseline and read as intentional; below that the "X / Y" conveys the
   ratio. Breakpoints use Bootstrap's tokens to match the rest of site.css
   (e.g. the Network Level mobile block at 991.98 / 575.98) rather than ad-hoc
   magic numbers — a custom flex strip is still right here (5 tiles don't divide
   into Bootstrap's 12-col grid), we just borrow its breakpoints. */
@media (max-width: 1199.98px) {
    .qap-qip-kpis .qap-kpi-tile-bar { display: none; }
}

@media (max-width: 991.98px) {
    .qap-qip-kpis > .qap-kpi-tile {
        flex-basis: 45%;
        margin-bottom: 1.1429rem;
    }
    .qap-qip-kpis > .qap-kpi-tile:nth-child(odd) { border-left: 0; }
    .qap-kpi-tile-value { font-size: 3.1429rem; line-height: 3.1429rem; }
    .qap-kpi-tile-total { font-size: 1.4286rem; line-height: 1.8571rem; }
}

/* ===== Query-definition content =====
   The query-definition body shown inside the QapInfo popover (via
   QueryDefinitionContent): meta chips, sections and the query-key footer. */
.qap-def-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4286rem;
    margin-bottom: 1rem;
}
.qap-def-chip {
    background: var(--qap-secondary-light);
    color: var(--qap-primary);
    border-radius: 71.3571rem;
    padding: 0.1429rem 0.7143rem;
    font-size: 0.9286rem;
    font-weight: 600;
}
.qap-def-chip--tag {
    background: transparent;
    border: 0.0714rem solid var(--qap-border);
    color: rgba(0, 0, 0, 0.55);
    font-weight: 400;
}
.qap-def-section { margin: 0 0 1rem; }
.qap-def-section h4 {
    margin: 0 0 0.2857rem;
    font-size: 0.9286rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.45);
}
.qap-def-section p {
    margin: 0;
    font-size: 1.1429rem;
    line-height: 1.5;
}
.qap-def-filters {
    margin: 0;
    padding-left: 1.1429rem;
    font-size: 1.0714rem;
    line-height: 1.6;
}
.qap-def-filters code {
    font-family: ui-monospace, monospace;
    background: var(--qap-secondary-light);
    border-radius: 0.2143rem;
    padding: 0 0.2857rem;
}
.qap-def-filter-type { color: rgba(0, 0, 0, 0.45); font-size: 0.9286rem; }
.qap-def-filter-desc { color: rgba(0, 0, 0, 0.7); }
.qap-def-empty { color: rgba(0, 0, 0, 0.5); font-family: 'Lato', sans-serif; }
.qap-def-key {
    margin-top: 0.8571rem;
    padding-top: 0.5714rem;
    border-top: 0.0714rem solid var(--qap-border);
    font-family: ui-monospace, monospace;
    font-size: 0.8571rem;
    color: rgba(0, 0, 0, 0.4);
    word-break: break-all;
}

/* Native HTML popover holding the full query definition (QapInfo click-through
   under static SSR — no JS, no circuit). Styled as a centered mini-dialog; the
   browser puts it in the top layer and handles ESC / click-outside dismiss. */
.qap-def-popover {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(42rem, calc(100vw - 4rem));
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    border: none;
    border-radius: 0.8571rem;
    box-shadow: 0 1.4286rem 4rem rgba(0, 0, 0, 0.28);
    background: #fff;
    color: var(--qap-text, #222);
    /* Popovers inherit through the DOM tree, not the visual top layer — the icon
       often lives in a bold, centred, enlarged chart title (.qap-card-title) or
       KPI tile, and the popover would inherit that weight/size/alignment. Reset
       typography to the base so the definition looks identical wherever opened. */
    text-align: left;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    letter-spacing: normal;
    text-transform: none;
}
.qap-def-popover::backdrop { background: rgba(0, 0, 0, 0.4); }
.qap-def-popover-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.qap-def-popover-title {
    margin: 0;
    font-size: 1.5714rem;
    font-weight: 700;
    color: var(--qap-primary);
}
.qap-def-popover-close {
    flex: none;
    background: none;
    border: none;
    padding: 0.2857rem;
    font-size: 1.4286rem;
    line-height: 1;
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.qap-def-popover-close:hover { color: var(--qap-primary); }

/* =======================================================================
   Filter lens tabs — "Facility filter / Assessment filter".
   The tab strip + "?" help button (FilterTabsPanel) and the "how it works"
   modal (funnel + explanation). Used by the page-filters panel; the tab-less
   QapFilterPanel (Home map drawer) doesn't pull these in.
   ======================================================================= */

.qap-filter-tabs {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: inherit;
}

/* Tab strip + inline "?" help button. The tabs centre themselves; the help
   button is pinned to the right edge so the tabs stay visually centred. */
.qap-filter-tabs-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    /* Reserve the help button's column on BOTH sides. The button is absolutely
       positioned so the tabs stay optically centred, which means nothing in
       flow accounts for its width — with English labels there was slack, but
       French ("Filtre établissements" is ~40% wider than "Facility Filter")
       ran straight underneath the "?". Symmetric padding keeps the centring
       honest while guaranteeing clearance. Matches the button's footprint:
       0.8571rem right inset + 1.2857rem icon + 2 × 0.2857rem padding. */
    padding: 0 2.7143rem;
}
.qap-filter-tabs-strip.qap-tabs-row {
    margin: 0.5714rem 0 0.4286rem;
    gap: 1.4286rem;
    /* .qap-tab is white-space:nowrap + flex-shrink:0, so a strip that can't fit
       would overflow its padding box and collide again rather than compress.
       Wrapping to a second line is the graceful degradation for any locale
       wordier than French. */
    flex-wrap: wrap;
    min-width: 0;
}
.qap-filter-tabs-help {
    position: absolute;
    /* Land the icon's right edge on the same 1.1429rem inset as the filter-row
       chevrons below it (row-head padding-right) minus this button's own
       padding-right, so the "?" sits in the chevron column. */
    right: 0.8571rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: none;
    cursor: pointer;
    padding: 0.2857rem;
    font-size: 1.2857rem;
    line-height: 1;
    color: var(--qap-tenant-primary, #0a6aa1);
    opacity: 0.7;
    transition: opacity 0.18s ease;
}
.qap-filter-tabs-help:hover { opacity: 1; }

/* Two-stage funnel: pick facilities -> trim assessments. Lives in the modal. */
.qap-filter-tabs-funnel {
    display: flex;
    align-items: stretch;
    gap: 0.5714rem;
    margin: 0 0 1.1429rem;
}
.qap-filter-tabs-funnel-stage {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.2143rem;
    padding: 0.7143rem 0.5714rem;
    border: 0.0714rem solid rgba(0, 0, 0, 0.12);
    border-radius: 0.5714rem;
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    opacity: 0.55;
}
.qap-filter-tabs-funnel-stage.active {
    opacity: 1;
    border-color: var(--qap-tenant-primary, #0a6aa1);
    box-shadow: 0 0.1429rem 0.4286rem rgba(10, 106, 161, 0.18);
}
.qap-filter-tabs-funnel-step {
    font-family: 'Lato', sans-serif;
    font-size: 0.8571rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--qap-tenant-primary, #0a6aa1);
}
.qap-filter-tabs-funnel-icon {
    font-size: 2rem;
    color: var(--qap-primary);
    margin: 0.2857rem 0;
}
.qap-filter-tabs-funnel-docs {
    display: inline-flex;
    gap: 0.1429rem;
}
.qap-filter-tabs-funnel-docs .is-dropped {
    opacity: 0.25;
    text-decoration: line-through;
}
.qap-filter-tabs-funnel-title {
    font-family: 'Lato', sans-serif;
    font-size: 1.2857rem;
    font-weight: 700;
    color: var(--qap-primary);
}
.qap-filter-tabs-funnel-sub {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    line-height: 1.3571rem;
    color: rgba(0, 0, 0, 0.55);
}
.qap-filter-tabs-funnel-arrow {
    align-self: center;
    font-size: 1.4286rem;
    color: rgba(0, 0, 0, 0.35);
    flex: 0 0 auto;
}

/* "How these filters work" modal. */
/* Type scale matches the Network-quality-performance card body (.qap-card-body):
   Lato 1.4286rem / 2.1429rem. Colour gives the hierarchy — body in a neutral ink
   so the blue is reserved for the title + the two key terms. */
.qap-filter-tabs-explain {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    font-weight: 400;
    line-height: 2.1429rem;
    color: #3f4b54;
}
.qap-filter-tabs-explain p { margin: 0 0 1.1429rem; }
.qap-filter-tabs-explain p:last-child { margin-bottom: 0; }
.qap-filter-tabs-explain strong { font-weight: 700; color: var(--qap-primary); }
.qap-filter-tabs-explain em { font-style: italic; }
.qap-filter-tabs-explain-note {
    padding: 1.0714rem 1.1429rem;
    background: var(--qap-secondary-light);
    border-radius: 0.5714rem;
    border-left: 0.2143rem solid var(--qap-tenant-primary, #0a6aa1);
}

/* Facility Numbers — patient-visits pictogram (pure HTML/CSS, static SSR). */
.qap-pictogram { display: flex; flex-direction: column; gap: 1.4286rem; }
.qap-pictogram-icons {
    display: grid;
    /* EQUAL fixed-width cells (wide enough for the 2-person children glyph) with
       each icon centred in its cell → columns line up regardless of icon width;
       justify-content centres the whole block instead of stretching edge-to-edge. */
    grid-template-columns: repeat(10, 2.5rem);
    grid-auto-flow: row;
    justify-content: center;
    place-items: center;
    gap: 0.7143rem;
    font-size: 1.8571rem;
}
.qap-pictogram-legend {
    display: flex; flex-wrap: wrap; gap: 2.2857rem;
    margin-top: 1.4286rem; padding-top: 1.1429rem; border-top: 0.0714rem solid rgba(0,0,0,0.08);
}
.qap-pictogram-legend-item { display: flex; flex-direction: column; }
.qap-pictogram-legend-value { font-family: 'Lato', sans-serif; font-weight: 700; font-size: 1.4286rem; }
.qap-pictogram-legend-label { font-family: 'Lato', sans-serif; font-weight: 700; font-size: 1rem; }

/* ======= Benchmarking ======= */
/* Three-step header: equal columns with a hairline between them (the
   .qap-kpi-group divider), each step a centred stack of title / text / control. */
.qap-bench-header { margin-bottom: 1.7143rem; }
.qap-bench-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1.1429rem;
}
.qap-bench-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.1429rem 1.7143rem;
}
.qap-bench-step + .qap-bench-step { border-left: 0.0714rem solid rgba(0,0,0,0.08); }
.qap-bench-step-title {
    font-family: 'Lato', sans-serif;
    font-weight: 700;
    font-size: 1.7143rem;
    line-height: 2.5714rem;
    color: var(--qap-primary);
    margin: 0 0 0.2857rem;
}
.qap-bench-step-text {
    font-family: 'Lato', sans-serif;
    font-size: 1.4286rem;
    line-height: 2.1429rem;
    color: var(--qap-primary);
    margin: 0;
    /* Reserve two lines so the three controls line up across the columns. */
    min-height: 4.2857rem;
}
.qap-bench-select { margin: 1.7143rem 0 0; }
.qap-bench-generate {
    flex: 0 0 auto;
    width: 24.2857rem;
    max-width: 100%;
    height: 4rem;
    margin: 1.7143rem 0 0;
    font-size: 1.2857rem;
    text-transform: uppercase;
}
.qap-bench-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Data Overview card */
.qap-bench-overview { margin-bottom: 1.7143rem; }
.qap-bench-overview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.1429rem;
    flex-wrap: wrap;
    margin-bottom: 1.4286rem;
}
.qap-bench-search { margin: 0; flex: 1 1 20rem; max-width: 30rem; }
.qap-bench-year { margin: 0; }
/* Yearly Performance: the year selector stands alone above the chart cards. */
.qap-yp-year { margin-bottom: 1.7143rem; }
/* Sticky column headers: ~100 rows is a long scroll. Sticks to the page (not
   an inner scroll box) so it behaves like the facility page's pinned title —
   same top offset (flush under .qap-page-filters) and layer. position:
   sticky needs the nearest scroll container to be the page, so the wrap's
   overflow-x is lifted on wide screens; the narrow breakpoint below restores
   horizontal scrolling (and gives up stickiness) where the table can't fit. */
.qap-bench-overview .qap-qip-table-wrap { overflow: visible; }
.qap-bench-table thead th {
    position: sticky;
    /* 2px UNDER the filters bar (which paints above at --z-sticky): the bar's
       bottom and the stuck header land on sub-pixel boundaries, and a 1px seam
       between them shows scrolling row text. */
    top: calc(3.5714rem - 0.1429rem);
    z-index: 1;
    white-space: normal;
    text-align: center;
    vertical-align: middle;
    min-width: 8.5714rem;
    /* The bg already set on .qap-qip-table thead th occludes rows scrolling
       underneath; the hairline marks the pinned edge. */
    box-shadow: 0 0.0714rem 0 rgba(0, 0, 0, 0.12);
}
.qap-bench-table thead th.qap-bench-th-name { text-align: left; min-width: 17.8571rem; }
/* Service-element pivot: a dozen score columns — narrower, wrapped headers. */
.qap-bench-se-table thead th { min-width: 11.4286rem; font-size: 1.1429rem; }
.qap-bench-se-table thead th.qap-bench-th-name { min-width: 14.2857rem; }
.qap-bench-se-table tbody td.num,
.qap-bench-se-table tfoot td.num { padding-left: 0.5714rem; padding-right: 0.5714rem; }
/* The pivot is wider than the card at every width, so it gets the scroll-box
   treatment on desktop too: the wrapper scrolls both ways inside the card,
   the header pins to the box's top and the group-name column to its left. */
#qap-bench-se .qap-qip-table-wrap { overflow: auto; max-height: 75dvh; }
.qap-bench-se-table thead th { top: 0; z-index: 2; box-shadow: 0 0.0714rem 0 rgba(0, 0, 0, 0.12); }
.qap-bench-se-table thead th.qap-bench-th-name { z-index: 3; }
.qap-bench-se-table th.qap-bench-th-name,
.qap-bench-se-table td.qap-bench-td-name {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    box-shadow: 0.0714rem 0 0 rgba(0,0,0,0.08);
}
.qap-bench-se-table thead th.qap-bench-th-name,
.qap-bench-se-table tfoot td.qap-bench-td-name { background: var(--qap-secondary-light); }
.qap-bench-se-table tbody tr:nth-child(even) td.qap-bench-td-name { background: #fafafa; }
.qap-bench-table td.num { text-align: center; }
.qap-bench-td-name { font-weight: 600; }
.qap-bench-table tfoot td {
    padding: 0.7143rem 1.1429rem;
    background: var(--qap-secondary-light);
    font-weight: 700;
    color: var(--qap-primary);
    white-space: nowrap;
}
.qap-bench-table tfoot tr:first-child td { border-top: 0.0714rem solid rgba(0,0,0,0.12); }
.qap-bench-table tfoot .qap-bench-td-name { font-weight: 700; }
.qap-bench-table tfoot .qap-tip { margin-left: 0.4286rem; }
.qap-bench-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.4286rem;
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: inherit;
    text-decoration: none;
    cursor: pointer;
}
.qap-bench-sort:hover { text-decoration: underline; color: inherit; }
.qap-bench-sort > i { font-size: 1rem; }

/* Charts: FetchedEnvelopeCard owns its grid cell here, so a card with no
   data drops out with its cell. With ~100 comparison groups charts.js flips
   the bars to horizontal rows (44px each) and the chart grows to several
   thousand px; cap the chart body at roughly the legacy 400px canvas and let
   it scroll inside the card instead of stretching the page. */
.qap-bench-charts { margin-bottom: 1.7143rem; }
.qap-bench-charts .qap-chart-wrap {
    max-height: 36rem;
    overflow-y: auto;
    overflow-x: hidden;
}
/* The wrap is a column flexbox; without this the capped wrap would shrink the
   chart to fit instead of scrolling it. */
.qap-bench-charts .qap-chart-wrap .qap-chart { flex-shrink: 0; }

@media (max-width: 991.98px) {
    /* Narrow: the wrapper must scroll sideways, and a scroll container is
       where sticky lands — so make it the vertical scroll box as well (capped
       height, table scrolls inside the card) and pin the header to ITS top. */
    .qap-bench-overview .qap-qip-table-wrap { overflow: auto; max-height: 75dvh; }
    .qap-bench-table thead th { top: 0; z-index: 2; }
    .qap-bench-table thead th.qap-bench-th-name { z-index: 3; }
    /* Narrow: the table scrolls sideways inside the card, so pin the group
       name column on the left — the numbers mean nothing without it. Each
       pinned cell repeats its row's background so the scrolled columns
       slide underneath. */
    .qap-bench-table th.qap-bench-th-name,
    .qap-bench-table td.qap-bench-td-name {
        position: sticky;
        left: 0;
        z-index: 1;                   /* header name cell overrides to 3 above */
        background: #fff;
        min-width: 10rem;
        max-width: 12rem;
        box-shadow: 0.0714rem 0 0 rgba(0,0,0,0.08);
    }
    .qap-bench-table thead th.qap-bench-th-name,
    .qap-bench-table tfoot td.qap-bench-td-name { background: var(--qap-secondary-light); }
    .qap-bench-table tbody tr:nth-child(even) td.qap-bench-td-name { background: #fafafa; }
    .qap-bench-steps { grid-template-columns: 1fr; }
    .qap-bench-step + .qap-bench-step { border-left: 0; border-top: 0.0714rem solid rgba(0,0,0,0.08); }
    .qap-bench-step-text { min-height: 0; }
}

/* Shown by MainLayout when a QAP.Pages.* permission is missing. */
.qap-page-not-allowed { max-width: 36rem; margin: 3rem auto; padding: 2.2857rem; text-align: center; }
.qap-page-not-allowed > i { font-size: 2rem; color: var(--qap-muted); margin-bottom: 0.5714rem; }
