/* ════════════════════════════════════════════════════════════════════
   CFIB Toolbox — Design System
   Layer 1: tokens  ·  Layer 2: base/layout  ·  Layer 3: components
   Legacy classes are preserved at the bottom so unredesigned pages keep working.
   ════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600;700;800&display=swap');

/* ─── Tokens ──────────────────────────────────────────────────────── */
:root {
    color-scheme: light;

    /* Brand (CFIB red is the action colour; blue is the identity colour) */
    --color-primary: #C41230;
    --color-primary-hover: #9e0e26;
    --color-accent: #0076BB;
    --color-accent-hover: #005A8E;

    /* Neutrals — all text tokens meet WCAG AA (≥4.5:1) on white */
    --color-text: #1f2933;
    --color-text-muted: #52606d;
    --color-text-subtle: #6b7280;      /* 4.6:1 on white — smallest-print safe */
    --color-border: #d5dbe1;
    --color-border-soft: #e6e9ee;      /* hairline borders on surfaces */
    --color-surface: #ffffff;
    --color-bg: #f6f7f9;

    /* Feedback */
    --color-success: #1a7a42;
    --color-success-bg: #d4f5e2;
    --color-warning: #7a5b04;
    --color-warning-bg: #fff3cd;
    --color-danger: #9e0e26;
    --color-danger-bg: #fde0e5;
    --color-info-bg: #e3f0f8;

    /* Sidebar — bg darkened from brand blue so text passes AA contrast */
    --sidebar-width: 250px;
    --sidebar-bg: #005A8E;             /* white on this = 7.3:1 */
    --sidebar-text: rgba(255,255,255,0.95);
    --sidebar-active: #ffffff;
    --sidebar-section: rgba(255,255,255,0.78);
    --sidebar-hover-bg: rgba(255,255,255,0.10);

    /* Spacing scale (4px base) */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 48px;

    /* Type scale */
    /* CFIB standard: Source Sans 3 — 18px body, 16px helper. Nothing below 16. */
    --text-xs: 16px; --text-sm: 16px; --text-md: 18px;
    --text-lg: 18px; --text-xl: 22px; --text-2xl: 28px;

    /* Radii */
    --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-pill: 999px;

    /* Shadows — layered and low-alpha; surfaces lean on hairline borders instead */
    --shadow-sm: 0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.06);
    --shadow-md: 0 4px 8px -2px rgba(16,24,40,0.10), 0 2px 4px -2px rgba(16,24,40,0.06);
    --shadow-lg: 0 20px 40px -8px rgba(16,24,40,0.22);

    /* Focus ring — one treatment everywhere */
    --focus-ring: 2px solid #0076BB;
    --focus-ring-offset: 2px;

    /* Layout */
    --content-max-width: 1160px;
    --content-bg: var(--color-bg);

    /* Case pages — tabs, clickable-row hover, read-only detail panels */
    --case-tab-bg: #eee;
    --case-tab-border: #ccc;
    --case-tab-text: #333;
    --case-row-hover: #fbeaee;
    --case-panel-bg: #f6f6f6;
    --case-panel-border: #ddd;
    --case-issue-bg: #fff8f0;
    --case-issue-border: #e6c9a8;
    --case-menu-bg: #fff;
    --case-menu-hover: #f1f1f1;

    /* Legacy aliases (older pages reference these) */
    --cfib-red: #C41230;
    --cfib-red-dark: #9e0e26;
    --cfib-red-light: #e8192f;
    --cfib-blue: #0076BB;
}

/* ─── Dark theme ──────────────────────────────────────────────────────
   Driven entirely by the viewer's browser/OS preference (prefers-color-scheme)
   — the app keeps no theme setting of its own and follows the browser live,
   including when the OS theme is flipped. Same token contract as light, every
   value re-pointed for a dark canvas while preserving the WCAG 2.0 AA / AODA
   contrast commitment. The brand-blue sidebar is intentionally identical in
   both themes — it is the identity panel and already clears AA on its blue. */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        /* Brand — red still fills primary actions (white text stays AA on it);
           accent lightened so links/outlines read on a dark canvas. */
        --color-primary: #d81f3b;
        --color-primary-hover: #ec3350;
        --color-accent: #52b0ea;
        --color-accent-hover: #7cc4f0;

        /* Neutrals — text tokens meet AA (≥4.5:1) on --color-surface */
        --color-text: #e7ebf0;
        --color-text-muted: #b3bcc6;
        --color-text-subtle: #8d97a2;
        --color-border: #3a434e;
        --color-border-soft: #2b333d;
        --color-surface: #1c222a;
        --color-bg: #12161c;

        /* Feedback — dark tint backgrounds with lightened AA text */
        --color-success: #5ccf8b;
        --color-success-bg: #123021;
        --color-warning: #e6bd5a;
        --color-warning-bg: #322910;
        --color-danger: #f2879a;
        --color-danger-bg: #34161c;
        --color-info-bg: #123049;

        /* Shadows — deepened so elevation still reads against dark surfaces */
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.40), 0 1px 3px rgba(0,0,0,0.32);
        --shadow-md: 0 4px 8px -2px rgba(0,0,0,0.48), 0 2px 4px -2px rgba(0,0,0,0.40);
        --shadow-lg: 0 20px 40px -8px rgba(0,0,0,0.62);

        /* Sidebar — the identity panel joins the dark canvas as a deep,
           brand-tinted blue (still clears AA for white nav text). */
        --sidebar-bg: #0d1a26;

        /* Case pages — same roles on a dark canvas. The row hover keeps a
           faint brand tint (it signals a clickable row) but as a dark plate,
           so --color-text still clears AA on it (12.5:1). */
        --case-tab-bg: #2b333d;
        --case-tab-border: #3a434e;
        --case-tab-text: #e7ebf0;
        --case-row-hover: #33222a;
        --case-panel-bg: #232b34;
        --case-panel-border: #3a434e;
        --case-issue-bg: #2a2318;
        --case-issue-border: #4b3d26;
        --case-menu-bg: #232b34;
        --case-menu-hover: #2c353f;

        /* Legacy aliases follow the theme */
        --cfib-red: #d81f3b;
        --cfib-red-dark: #ec3350;
        --cfib-red-light: #f04155;
        --cfib-blue: #52b0ea;
    }
}

/* ─── Base ────────────────────────────────────────────────────────── */
html, body {
    height: 100%; margin: 0;
    font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
    font-size: var(--text-md);
    color: var(--color-text);
    overflow-x: hidden;
}

/* One visible focus treatment for every interactive element (keyboard only). */
:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    background: var(--color-surface);
    color: var(--color-accent);
    padding: var(--space-3) var(--space-4);
    border-radius: 0 0 var(--radius-md) 0;
    box-shadow: var(--shadow-md);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus { left: 0; }

#wrapper { min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.25s ease;
    overflow: hidden;
}

.sidebar-header {
    padding: var(--space-4) var(--space-5) var(--space-3);
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.sidebar-subtitle {
    font-size: var(--text-xs);
    color: var(--color-accent);
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-top: var(--space-1);
    text-align: center;
}

.sidebar-search {
    padding: var(--space-3) var(--space-4) var(--space-1);
    flex-shrink: 0;
}

.sidebar-search-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: var(--text-sm);
    padding: 7px var(--space-3);
}
.sidebar-search-input::placeholder { color: rgba(255,255,255,0.75); }
.sidebar-search-input:focus {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.6);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}

.sidebar-nav {
    list-style: none;
    padding: var(--space-2) 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.sidebar-nav li.nav-section {
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: var(--sidebar-section);
    padding: var(--space-5) var(--space-5) var(--space-1);
    font-weight: 700;
}

/* Rounded-pill nav items (inset, with breathing room) instead of full-bleed
   rows + left border strip. The active item is a solid highlight card. */
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 2px var(--space-3);
    /* Indent items so the (uppercase, bold) section headings clearly stand out to the left. */
    padding: 8px var(--space-3) 8px var(--space-6);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 18px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover-bg);
    color: #fff;
}

.sidebar-nav li a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
}

.sidebar-nav li a.active {
    background: rgba(255,255,255,0.16);
    color: var(--sidebar-active);
    font-weight: 600;
}

.nav-icon { font-size: var(--text-md); width: 20px; text-align: center; flex-shrink: 0; opacity: 0.9; }
.sidebar-nav li a.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; min-width: 0; }
.nav-external { font-size: var(--text-xs); opacity: 0.8; }

/* ─── "In Development" section ────────────────────────────────────
   Amber, rule-separated and pilled, so an unreleased tool never reads as part of the
   Toolbox proper. Amber rather than the brand red: red is this app's ACTION colour
   (Save, Add), and a red section heading would say "important", which is the opposite
   of the message. Amber is the only hue here that means "provisional" without competing
   with a status badge.

   The colour is one of two signals, never the only one — the DEV pill carries the same
   meaning for anyone who cannot separate these hues against the blue sidebar. */
.sidebar-nav li.nav-section-dev {
    color: #FFD48A;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid rgba(255,255,255,0.18);
}

.sidebar-nav li.nav-item-dev a {
    color: #FFD48A;
}

.sidebar-nav li.nav-item-dev a:hover {
    background: rgba(255, 193, 105, 0.16);
    color: #FFE4B5;
}

.sidebar-nav li.nav-item-dev a.active {
    background: rgba(255, 193, 105, 0.22);
    color: #FFF1DA;
}

/* Sits at the end of the link, not the start: the tool's name is what people scan for. */
.nav-dev-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    line-height: 1;
    padding: 3px 7px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 212, 138, 0.55);
    color: #FFD48A;
    background: rgba(255, 193, 105, 0.14);
}

/* The in-page counterpart to the sidebar treatment, for pages under /Dev. Rides the
   existing warning tokens, so it flips with the dark theme like everything else rather
   than hard-coding a second amber. Kept beside the nav rules above so the whole
   "in development" treatment is in one place. */
.dev-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: var(--text-sm);
}

.dev-banner-pill {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-warning);
    background: transparent;
}

.nav-no-results {
    padding: var(--space-3) var(--space-5);
    color: rgba(255,255,255,0.85);
    font-size: var(--text-sm);
    font-style: italic;
}

/* ─── Sidebar footer: who am I, in what context ───────────────────── */
.sidebar-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.18);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.sidebar-user-block { display: flex; flex-direction: column; min-width: 0; }

.sidebar-user {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-roles {
    font-size: 16px;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.sidebar-action {
    font-size: var(--text-xs);
    color: rgba(255,255,255,0.92);
    /* Transparent so the <button> (Hide menu) matches the <a> (Sign out) instead of
       showing the browser's default button face under white text. */
    background: transparent;
    font-family: inherit;
    line-height: inherit;
    cursor: pointer;
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    transition: background 0.15s, border-color 0.15s;
}
.sidebar-action:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.5); }
.sidebar-action:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ─── Drawer toggle (tablet/mobile) ───────────────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px; right: 12px;
    z-index: 1100;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: 5px;
    width: 40px; height: 40px;
    font-size: 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    flex-direction: column;
    gap: 4px;
    padding: 8px 7px;
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

/* ─── Content frame ───────────────────────────────────────────────── */
#content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--content-bg);
    flex: 1;
    overflow-x: hidden;
}

.content-inner {
    padding: var(--space-7) 36px;
    max-width: var(--content-max-width);
    overflow-x: auto;
    box-sizing: border-box;
}
.content-inner:focus { outline: none; }  /* skip-link target; no ring on programmatic focus */

/* Wide data reports (many-column grids) opt out of the reading-width cap — 1160px is
   right for prose and forms, but it strands a 12-column table in half the window and
   forces it to scroll sideways while empty space sits to the right. Set
   ViewData["WidePage"] = true on the page to get this. */
.content-inner-wide { max-width: none; }

/* 1024px, not 991px: an iPad in landscape is exactly 1024 wide, and leaving the sidebar
   fixed there costs a quarter of the screen on the device these grids are actually used on. */
@media (max-width: 1024px) {
    :root { --sidebar-width: 260px; }
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .sidebar-overlay.open { display: block; }
    #content { margin-left: 0; }
    .content-inner { padding: 60px 20px 32px; }
}

@media (max-width: 575px) {
    .content-inner { padding: 56px 14px 24px; }
}

/* ─── Typography / page header ────────────────────────────────────── */
.page-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border-soft);
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin: 0;
}

.page-header p {
    margin: var(--space-1) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-md);
}

/* ─── Buttons: one hierarchy ──────────────────────────────────────────
   Primary  = filled CFIB red pill  (.btn-cfib) — ONE per screen
   Secondary= outlined              (.btn-secondary-cfib)
   Tertiary = text-only             (.btn-tertiary-cfib)                */
.btn-cfib {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    border: 2px solid var(--color-primary);
    padding: 9px 28px;
    font-size: var(--text-md);
    font-weight: 600;
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-cfib:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #fff;
    box-shadow: 0 4px 12px -2px rgba(196,18,48,0.35);
}
.btn-cfib:disabled { background: #9aa1a9; border-color: #9aa1a9; cursor: not-allowed; }

.btn-secondary-cfib {
    display: inline-block;
    background: transparent;
    color: var(--color-accent-hover);
    border: 2px solid var(--color-accent-hover);
    padding: 9px 24px;
    font-size: var(--text-md);
    font-weight: 600;
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.btn-secondary-cfib:hover { background: var(--color-accent-hover); color: #fff; }

.btn-tertiary-cfib {
    display: inline-block;
    background: none;
    color: var(--color-accent-hover);
    border: none;
    padding: 9px var(--space-3);
    font-size: var(--text-md);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-tertiary-cfib:hover { color: var(--color-text); }

/* Bootstrap buttons stay pill-shaped for consistency; btn-group keeps its own radii. */
.btn { border-radius: var(--radius-pill); }

.btn-cfib .btn-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* ─── Form controls: consistent size + focus ──────────────────────── */
.form-control, .form-select {
    font-size: var(--text-md);
    border-radius: var(--radius-md);
    border-color: var(--color-border);
    min-height: 40px;
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0,118,187,0.2);
}
.form-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }

/* ─── Filter toolbar + active-filter chips ────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.filter-field { display: flex; flex-direction: column; gap: var(--space-1); }
.filter-field > label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); margin: 0; }

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-info-bg);
    color: var(--color-accent-hover);
    border: 1px solid rgba(0,118,187,0.3);
    border-radius: var(--radius-pill);
    padding: 3px 6px 3px 12px;
    font-size: var(--text-sm);
    font-weight: 600;
}

.filter-chip a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 50%;
    color: var(--color-accent-hover);
    text-decoration: none;
    font-size: var(--text-sm);
    line-height: 1;
}
.filter-chip a:hover { background: rgba(0,118,187,0.15); }

/* Same remove control as the link version, for chips removed in-page rather than by URL. */
.filter-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-accent-hover);
    font-size: var(--text-sm);
    line-height: 1;
    cursor: pointer;
}
.filter-chip button:hover { background: rgba(0,118,187,0.15); }

/* ─── Multi-select combobox (Members Near a Location industry picker) ── */
.combo-multi { position: relative; }

.combo-multi-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: var(--space-1) 0;
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.combo-multi-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: 6px var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}
.combo-multi-option.is-group { font-weight: 600; }
.combo-multi-option.is-child { padding-left: calc(var(--space-3) + 24px); }
.combo-multi-option.is-active,
.combo-multi-option:hover { background: var(--color-info-bg); }

.combo-multi-option .combo-multi-code {
    margin-left: auto;
    padding-left: var(--space-2);
    color: var(--color-text-subtle);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* A drawn checkbox rather than an <input>, so focus never leaves the combobox input. The
   tick and dash are CSS shapes: the Toolbox ships no icon font (CFIB design standards). */
.combo-multi-check {
    flex: 0 0 18px;
    width: 18px; height: 18px;
    margin-top: 3px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.combo-multi-option[aria-selected="true"] .combo-multi-check,
.combo-multi-option[data-state="mixed"] .combo-multi-check {
    background: var(--color-accent);
    border-color: var(--color-accent);
}
.combo-multi-option[aria-selected="true"] .combo-multi-check::after {
    content: "";
    width: 5px; height: 10px;
    margin-top: -2px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.combo-multi-option[data-state="mixed"] .combo-multi-check::after {
    content: "";
    width: 9px; height: 2px;
    background: #fff;
}

.combo-multi-empty {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-subtle);
}

.combo-multi-status {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
    margin-top: 4px;
}

.filter-clear-all { font-size: var(--text-sm); }

/* ─── Segmented control (status selector) ─────────────────────────── */
.segmented {
    display: inline-flex;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 3px;
}

.segmented input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented label {
    padding: 6px 16px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin: 0;
}

.segmented input:checked + label {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + label {
    outline: var(--focus-ring);
    outline-offset: 1px;
}

/* ─── Data table (sortable, selectable) ───────────────────────────── */
.data-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* The Download CSV button sits above its grid, right-aligned so it does not
   compete with the heading that names what is being downloaded. */
.grid-export-bar { display: flex; justify-content: flex-end; padding: 8px 12px 0; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-md);
    margin: 0;
    min-width: 480px;
}

/* Muted uppercase header band — the red rule was pulling brand colour into a
   purely structural element; red now stays reserved for actions and status. */
.data-table thead tr { background: #f8f9fb; border-bottom: 1px solid var(--color-border-soft); }

/* Headers stay put when a long list scrolls. The background is not optional: a transparent
   sticky header lets rows slide underneath it and become unreadable. Set on th rather than
   thead because Safari ignores position:sticky on thead and tr. */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fb;
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    font-weight: 700;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.data-table th a.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.data-table th a.sort-link:hover { color: var(--color-accent-hover); }
.data-table th a.sort-link .bi { font-size: var(--text-xs); color: var(--color-accent-hover); }

.data-table td {
    padding: var(--space-3) var(--space-4);
    color: var(--color-text);
    vertical-align: middle;
}

.data-table tbody tr { border-bottom: 1px solid #eee; transition: background 0.1s; }
.data-table tbody tr:hover { background: #f9f9fb; }
.data-table tbody tr.row-selected { background: var(--color-info-bg); }
.data-table tbody tr.row-deactivated td { color: var(--color-text-subtle); }

.data-table .text-center { text-align: center; }
.data-table .text-end    { text-align: right; }
.data-table .text-bold   { font-weight: 600; }
.data-table .col-mono    { font-weight: 500; }
.data-table .col-action  { white-space: nowrap; text-align: right; padding: var(--space-3) var(--space-4); width: 1%; }
.data-table .col-select  { width: 36px; text-align: center; }

/* Content lists: Preview / Edit / Deactivate (or Reactivate / Delete) on one line made the
   table wider than its card, so the Actions column was cut off and the grid scrolled sideways
   while titles were squeezed to three lines (Chantal, 2026-10-03: "the scroll is weird").
   They wrap to two short lines instead, right-aligned, and the title gets the room. */
.data-table .row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 170px;
    margin-left: auto;
    white-space: normal;
}
.data-table .row-actions form { margin: 0; }

.data-table .empty-row td { text-align: center; color: var(--color-text-subtle); padding: var(--space-6) var(--space-4); }

/* ─── Tab nav (link-based) ────────────────────────────────────────────
   Server-rendered tabs: each tab is a real link to the same page with a
   different ?tab= value, so the choice is deep-linkable, survives a POST
   redirect and works with the back button — none of which a JS-only tab
   strip gives you. Shares the --case-tab-* tokens, so it is themed for
   dark mode already. */
.tab-nav {
    display: flex;
    gap: var(--space-2);
    border-bottom: 1px solid var(--color-border-soft);
}

.tab-nav-item {
    background: var(--case-tab-bg);
    border: 1px solid var(--case-tab-border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 8px 20px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--case-tab-text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.tab-nav-item:hover { color: var(--color-accent-hover); }
.tab-nav-item.active,
.tab-nav-item.active:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.tab-nav-item:focus-visible { outline: var(--focus-ring); outline-offset: -2px; }

/* ─── Case pages ──────────────────────────────────────────────────────
   Finance Member Payments Cases and Campaigns render the same list + detail
   shape, so their treatment lives here once instead of inline. Every
   surface goes through a token so the dark block can re-point it — the read
   panels and the row hover used to be pinned light, which left light text on
   a light plate once the viewer's browser was in dark mode. */
.case-tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--color-border-soft); }
/* Member Payments Cases on a phone: four tabs do not fit 390px. Without this they shrank
   until each label broke over two lines and the last ran past the card edge, cut off.
   They wrap onto a second line instead, each label whole. No effect where they fit. */
.case-tabs.case-tabs-wrap { flex-wrap: wrap; }
.case-tabs.case-tabs-wrap .case-tab { white-space: nowrap; }
.case-tab {
    background: var(--case-tab-bg);
    border: 1px solid var(--case-tab-border);
    color: var(--case-tab-text);
    border-radius: var(--radius-sm);
    padding: 6px 16px;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}
.case-tab.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.case-table tbody tr { cursor: pointer; }
/* Doubled class deliberately: this has to out-specify the .data-table hover
   override in the dark block further down the file. */
.data-table.case-table tbody tr:hover { background: var(--case-row-hover); }

/* Read-only panels in the detail card */
.case-panel {
    white-space: pre-wrap;
    border: 1px solid var(--case-panel-border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    max-height: 280px;
    overflow: auto;
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--color-text);
    background: var(--case-panel-bg);
}
.case-panel-issue { background: var(--case-issue-bg); border-color: var(--case-issue-border); }

/* Assignee type-ahead menu */
.assignee-menu {
    max-width: 360px;
    border: 1px solid var(--case-panel-border);
    border-radius: var(--radius-sm);
    margin-top: 2px;
    max-height: 180px;
    overflow: auto;
    background: var(--case-menu-bg);
}
.assignee-item { padding: 6px 10px; cursor: pointer; font-size: var(--text-sm); }
.assignee-item:hover { background: var(--case-menu-hover); }

/* ─── Bulk-action bar ─────────────────────────────────────────────── */
.bulk-bar {
    display: flex;
    /* Wrap, or a bar with several actions cannot shrink and drags the whole
       content area into a horizontal scroll instead of stacking. */
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    background: var(--color-accent-hover);
    color: #fff;
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-md);
}

.bulk-bar .bulk-count { font-weight: 700; font-size: var(--text-sm); }

.bulk-bar button {
    background: rgba(255,255,255,0.14);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: var(--radius-pill);
    padding: 4px 14px;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}
.bulk-bar button:hover { background: rgba(255,255,255,0.28); }
.bulk-bar .bulk-dismiss { margin-left: auto; border: none; background: none; font-size: var(--text-md); }

/* ─── Status badges — soft pills with a dot indicator ─────────────── */
/* .badge-info only on its own: "badge badge-info" (Campaigns) is a Bootstrap badge and keeps that shape. */
.badge-ok, .badge-fail, .badge-skip, .badge-warn, .badge-info:not(.badge) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    padding: 2px 10px;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-ok::before, .badge-fail::before, .badge-skip::before, .badge-warn::before, .badge-info:not(.badge)::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-ok   { background: var(--color-success-bg); color: var(--color-success); }
.badge-fail { background: var(--color-danger-bg);  color: var(--color-danger);  }
.badge-skip { background: #f0f0f0; color: #595959; }
.badge-warn { background: var(--color-warning-bg); color: var(--color-warning); }
/* Info severity (e.g. non-blocking sign-in diagnostics verdicts). Both halves are
   tokens, so this already re-points itself in dark mode — no override needed below. */
.badge-info { background: var(--color-info-bg); color: var(--color-accent-hover); }

/* ─── Designed states: empty, error, skeleton ─────────────────────── */
.empty-state {
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-8) var(--space-6);
    text-align: center;
}

.empty-state .empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px; height: 72px;
    border-radius: 50%;
    background: #eef1f5;
    font-size: 30px;
    color: #8896a6;
    margin-bottom: var(--space-4);
}

.empty-state h2 { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); margin: 0 0 var(--space-2); }
.empty-state p  { color: var(--color-text-muted); margin: 0 0 var(--space-4); }

.error-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-danger-bg);
    border-left: 4px solid var(--color-danger);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.error-panel h2 { font-size: var(--text-md); font-weight: 700; color: var(--color-danger); margin: 0 0 var(--space-1); }
.error-panel p  { color: var(--color-text-muted); margin: 0 0 var(--space-3); font-size: var(--text-sm); }

.error-panel details { font-size: var(--text-sm); color: var(--color-text-subtle); margin-top: var(--space-3); }
.error-panel details summary { cursor: pointer; font-weight: 600; }
.error-panel details pre {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin: var(--space-2) 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: var(--text-xs);
}

.skeleton {
    display: inline-block;
    background: linear-gradient(90deg, #e8eaee 25%, #f4f5f7 50%, #e8eaee 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
    height: 14px;
    width: 100%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Verdict list — Sign-in Diagnostics + the Unlock pre-flight gate ─────── */
.verdict-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.verdict-row {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-soft);
}
.verdict-row:last-child { border-bottom: none; }
.verdict-row-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}
.verdict-code {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}
.verdict-detail {
    margin: 0 0 var(--space-1);
    color: var(--color-text);
}
.verdict-action {
    margin: 0;
    color: var(--color-text-muted);
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
    #sidebar { transition: none; }
}

/* ─── Pagination ──────────────────────────────────────────────────── */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.pager-links { display: flex; gap: var(--space-1); }

.pager-links a, .pager-links span.current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-accent-hover);
    font-weight: 600;
}
.pager-links a:hover { background: var(--color-info-bg); }
.pager-links span.current { background: var(--color-accent-hover); color: #fff; }
.pager-links span.disabled { color: var(--color-border); display: inline-flex; align-items: center; padding: 0 8px; }

/* The GM grids are wider than any viewport -- Pipeline alone is fourteen columns
   and about 2,000px -- and three rules between them made the right-hand ones
   unreachable rather than merely off-screen: the wrapper's own scroll was removed
   so the page would be the only scroller (which is right, and keeps the sticky
   headings measuring the viewport), but html and body clip horizontal overflow, so
   the page could never pan. Measured before the fix: document scrollWidth equal to
   clientWidth, no scrollbar painted, and window.scrollTo(9999,0) moving nothing,
   with the card running 676px past the right edge.

   Lifted only on the GM pages, and only on the horizontal axis. */
html.gm-page,
html.gm-page body { overflow-x: visible; }

/* And the card must stop clipping what the page now pans to. Its overflow:hidden is
   there to clip a table's corners to the card radius; on these grids that came at
   the price of the columns past the card's edge. */
html.gm-page .gm-section .card { overflow: visible; }

/* Lifting the clip only gets a mouse to the right-hand columns. On a touch
   device the document does not pan sideways at all -- verified with a
   synthesized finger drag at 820 and 390: window.scrollX and
   visualViewport.pageLeft both stay at 0 while the last column sits 75px past
   the edge. So on a coarse pointer the wrapper takes the horizontal scroll
   back and a finger swipes the grid itself.

   max-height stays none, so there is nothing to scroll vertically inside the
   wrapper and the page is still the only vertical scroller -- which is what the
   two-scrollbars-fighting-the-finger complaint was actually about. The cost is
   the sticky heading on touch only, and a heading that follows you down is
   worth less than a column you can reach at all. */
/* #content is a flex item, so its min-width: auto floor is min-content -- it grows
   to fit the table, and every max-width: 100% below it then resolves against the
   grown width. Constraining the card alone therefore changed nothing; this is the
   rule the whole chain binds to. */
html.gm-page #content,
html.gm-page .gm-section.content-inner { min-width: 0; max-width: 100%; }
html.gm-page .gm-section .card,
html.gm-page .gm-section .data-table-wrapper { max-width: 100%; min-width: 0; }

/* The grid is the horizontal scroller, on every pointer type.
   Lifting the page clip was tried first and only panned part of the way on a wide
   desktop -- 523px of the 690px needed at 1600, leaving 167px still unreachable,
   and 39px short at 1920 -- so the document is not a dependable horizontal
   scroller here, and the wrapper takes the job back. Which is also what the inline
   overflow-x:auto these pages already carry always intended. */
html.gm-page .gm-section .data-table-wrapper { overflow-x: auto !important; }

/* ─── Cards ───────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
    overflow: hidden;   /* clips table corners to the card radius */
}
.card-header { background: #fff; border-bottom: 1px solid var(--color-border-soft); font-weight: 600; font-size: var(--text-md); border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; padding: 14px 20px; }

/* ─── Login page ──────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent);
}

.login-box {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 44px;
    width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 4px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 16px;
    color: var(--color-text-subtle);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.login-box label { font-size: 16px; font-weight: 600; color: var(--color-text-muted); }
.login-box input { border-radius: 5px; font-size: 16px; }
.login-box input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(196,18,48,0.12); }

.login-error {
    background: #fff0f2;
    border: 1px solid #f5c0c8;
    color: var(--color-danger);
    border-radius: 5px;
    padding: 10px 14px;
    font-size: 16px;
    margin-bottom: 16px;
}

/* ─── Summary stats ───────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
    margin-bottom: var(--space-6);
}

.stat-box {
    background: #fff;
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-box .stat-value { font-size: var(--text-2xl); font-weight: 700; color: var(--color-text); line-height: 1; }

.stat-box .stat-label {
    font-size: 16px;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.stat-box.ok .stat-value   { color: var(--color-success); }
.stat-box.fail .stat-value { color: var(--color-primary); }
.stat-box.warn .stat-value { color: #a36407; }

/* ─── Legacy (kept for unredesigned pages) ────────────────────────── */
.results-table { font-size: 16px; }
.results-table th { background: #f0f0f3; font-size: 16px; text-transform: uppercase; letter-spacing: 0.5px; color: #555; font-weight: 600; }
.members-table { min-width: 1280px; }
.members-table td { vertical-align: middle; white-space: nowrap; }

.issue-list { font-size: 16px; color: var(--color-danger); margin: 0; padding-left: 16px; }

.log-box {
    background: #1e1e2d;
    color: #c4c4d0;
    border-radius: 6px;
    padding: 16px 18px;
    font-family: 'Consolas', monospace;
    font-size: 16px;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

#loadingOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    gap: 16px;
}

.spinner {
    width: 48px; height: 48px;
    border: 5px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Invoice table fit ───────────────────────────────────────────────
   The Generate-an-Invoice table packs 8 columns; the default nowrap header
   band pushed it past the content width and forced a horizontal scrollbar.
   Let the headers wrap and tighten spacing so the statement fits on screen. */
#invoiceTable { min-width: 0; }
#invoiceTable th { white-space: normal; letter-spacing: 0.02em; }
#invoiceTable th,
#invoiceTable td { padding: var(--space-2) var(--space-3); }

/* ─── Dark theme: component overrides for non-token colours ───────────
   Same trigger as the token block — the viewer's browser preference. These
   components pin light values (white plates, a near-white table band, a light
   shimmer gradient, Bootstrap's white form controls) that the token layer
   above cannot reach on its own. */
@media (prefers-color-scheme: dark) {
    body { background: var(--color-bg); }

    /* Sidebar identity panel joins the dark theme (header plate + hairline) */
    .sidebar-header { background: var(--sidebar-bg); border-bottom-color: rgba(255,255,255,0.10); }

    /* Surfaces that were pinned to #fff */
    .card,
    .card-header,
    .stat-box,
    .filter-bar,
    .empty-state,
    .error-panel { background: var(--color-surface); }

    /* Bootstrap form controls default to white — bring them onto the dark canvas */
    .form-control,
    .form-select {
        background-color: #232b34;
        color: var(--color-text);
        border-color: var(--color-border);
    }
    .form-control::placeholder { color: var(--color-text-subtle); }
    /* The override above also painted disabled controls, so they looked editable; recess them
       onto the canvas as Bootstrap's grey does in light. */
    .form-control:disabled,
    .form-select:disabled {
        background-color: var(--color-bg);
        color: var(--color-text-muted);
    }

    /* Table bands and rows */
    .data-table thead tr { background: #232b34; }
    .data-table thead th { background: #232b34; }
    .data-table tbody tr { border-bottom-color: var(--color-border-soft); }
    .data-table tbody tr:hover { background: #232b34; }

    /* Bootstrap's contextual row classes (.table-warning on an urgent cancellation,
       .table-danger on an overdue one, .table-secondary on a retired template) are
       compiled once against a light canvas and are NOT re-pointed by data-bs-theme.
       Left alone they keep a cream or pink plate in dark mode while everything
       inside the row — the member link, every .text-muted second line, the sort
       headings — has already flipped to light: the cancellation queue rendered as
       pale grey on cream. Re-point the same custom properties onto the app's own
       tinted-surface tokens, hover and striped states included, so the tint still
       separates the row and --color-text clears AA on it. */
    .table-warning {
        --bs-table-color: var(--color-text);
        --bs-table-bg: var(--color-warning-bg);
        --bs-table-border-color: var(--color-border);
        --bs-table-striped-color: var(--color-text);
        --bs-table-striped-bg: #3a3014;
        --bs-table-active-color: var(--color-text);
        --bs-table-active-bg: #423718;
        --bs-table-hover-color: var(--color-text);
        --bs-table-hover-bg: #3d3316;
    }
    .table-danger {
        --bs-table-color: var(--color-text);
        --bs-table-bg: var(--color-danger-bg);
        --bs-table-border-color: var(--color-border);
        --bs-table-striped-color: var(--color-text);
        --bs-table-striped-bg: #3c1a21;
        --bs-table-active-color: var(--color-text);
        --bs-table-active-bg: #452027;
        --bs-table-hover-color: var(--color-text);
        --bs-table-hover-bg: #401d24;
    }
    .table-success {
        --bs-table-color: var(--color-text);
        --bs-table-bg: var(--color-success-bg);
        --bs-table-border-color: var(--color-border);
        --bs-table-striped-color: var(--color-text);
        --bs-table-striped-bg: #163827;
        --bs-table-active-color: var(--color-text);
        --bs-table-active-bg: #1b422e;
        --bs-table-hover-color: var(--color-text);
        --bs-table-hover-bg: #183d2a;
    }
    .table-info {
        --bs-table-color: var(--color-text);
        --bs-table-bg: var(--color-info-bg);
        --bs-table-border-color: var(--color-border);
        --bs-table-striped-color: var(--color-text);
        --bs-table-striped-bg: #163854;
        --bs-table-active-color: var(--color-text);
        --bs-table-active-bg: #1b4060;
        --bs-table-hover-color: var(--color-text);
        --bs-table-hover-bg: #183c5a;
    }
    .table-secondary {
        --bs-table-color: var(--color-text);
        --bs-table-bg: #262e38;
        --bs-table-border-color: var(--color-border);
        --bs-table-striped-color: var(--color-text);
        --bs-table-striped-bg: #2b333d;
        --bs-table-active-color: var(--color-text);
        --bs-table-active-bg: #323b46;
        --bs-table-hover-color: var(--color-text);
        --bs-table-hover-bg: #2e3742;
    }

    /* Same gap, two more components: Bootstrap keeps .bg-dark and .btn-outline-dark
       at their near-black light-theme values in dark mode, so the "group — …" badge
       on a cancellation row and the "Show all reasons" button inside the filtered
       alert both sank into the plate behind them. Lift them to the neutral border
       grey instead of black. */
    .badge.bg-dark {
        background-color: #3a434e !important;
        color: var(--color-text) !important;
    }
    .btn-outline-dark {
        --bs-btn-color: var(--color-text);
        --bs-btn-border-color: var(--color-border);
        --bs-btn-hover-color: #0b1116;
        --bs-btn-hover-bg: var(--color-text);
        --bs-btn-hover-border-color: var(--color-text);
        --bs-btn-active-color: #0b1116;
        --bs-btn-active-bg: var(--color-text);
        --bs-btn-active-border-color: var(--color-text);
    }

    /* Bootstrap's accordion is pinned to a white plate with a pale-blue open
       header — it only self-themes under data-bs-theme, which this app does not
       set (it follows prefers-color-scheme instead). Left alone, the petition
       body panels render as light rectangles on the dark canvas, with the
       already-dark .case-panel inside them. Only the two petition pages use it. */
    .accordion {
        --bs-accordion-color: var(--color-text);
        --bs-accordion-bg: var(--color-surface);
        --bs-accordion-border-color: var(--color-border);
        --bs-accordion-btn-color: var(--color-text);
        --bs-accordion-btn-bg: var(--color-surface);
        --bs-accordion-active-color: var(--color-accent-hover);
        --bs-accordion-active-bg: #232b34;
        --bs-accordion-btn-focus-border-color: var(--color-accent);
    }
    /* The chevron is a dark inline SVG in a custom property; flip it to read on the plate. */
    .accordion-button::after { filter: invert(1) grayscale(1) brightness(1.8); }

    /* Bootstrap's modal has the same problem: a white plate while its title and
       headings inherit the light body text, so they vanish (Email events details,
       Invoice schedule edit). Its tables are re-pointed too, or they stay a white
       block inside the dark plate. */
    .modal {
        --bs-modal-color: var(--color-text);
        --bs-modal-bg: var(--color-surface);
        --bs-modal-border-color: var(--color-border);
        --bs-modal-header-border-color: var(--color-border);
        --bs-modal-footer-border-color: var(--color-border);
    }
    .modal .table {
        --bs-table-color: var(--color-text);
        --bs-table-bg: transparent;
        --bs-table-border-color: var(--color-border);
    }
    .modal .btn-close { filter: invert(1) grayscale(1) brightness(2); }

    /* Fills that carry white text — a readable mid-blue, not the light link blue */
    .bulk-bar,
    .pager-links span.current { background: #1f6fa5; }

    /* Secondary button hover flips to a dark label on the light-blue fill */
    .btn-secondary-cfib:hover { background: var(--color-accent-hover); color: #0b1116; }

    /* Neutral chip / plate greys */
    .badge-skip { background: #2b333d; color: #c2cad3; }
    .empty-state .empty-icon { background: #262e38; color: #8d97a2; }

    /* Warning stat value (hard-coded orange fails on dark) */
    .stat-box.warn .stat-value { color: var(--color-warning); }

    /* Skeleton shimmer on a dark canvas */
    .skeleton {
        background: linear-gradient(90deg, #232b34 25%, #2c353f 50%, #232b34 75%);
        background-size: 200% 100%;
    }

    /* Legacy tables */
    .results-table th { background: #232b34; color: var(--color-text-muted); }

    /* DataTables 2 chrome (search box, page-length select, info line, pager).
       Its stylesheet loads from the CDN inside each page's Scripts section, so
       it lands after this file — the :root prefix wins the cascade on its own.
       The pager buttons are the one exception: DataTables pins their colour
       with !important, so matching it is the only way to reach them. */
    :root div.dt-container div.dt-search input,
    :root div.dt-container div.dt-length select {
        background-color: #232b34;
        color: var(--color-text);
        border-color: var(--color-border);
    }
    :root div.dt-container div.dt-search label,
    :root div.dt-container div.dt-length label,
    :root div.dt-container div.dt-info { color: var(--color-text-muted); }

    :root div.dt-container div.dt-paging button.dt-paging-button {
        color: var(--color-text) !important;
        border-color: transparent;
    }
    :root div.dt-container div.dt-paging button.dt-paging-button:hover:not(.disabled):not(.current) {
        background: #2c353f;
        border-color: var(--color-border);
    }
    :root div.dt-container div.dt-paging button.dt-paging-button.current,
    :root div.dt-container div.dt-paging button.dt-paging-button.current:hover {
        background: #1f6fa5;
        border-color: #1f6fa5;
        color: #fff !important;
    }
    :root div.dt-container div.dt-paging button.dt-paging-button.disabled {
        color: var(--color-text-subtle) !important;
    }

    /* Login page */
    .login-page { background: var(--color-bg); }
    .login-box { background: var(--color-surface); }
    .login-error { background: var(--color-danger-bg); border-color: #5a2530; color: var(--color-danger); }
}

/* ─── iPad and touch ──────────────────────────────────────────────────
   The GM section is used on an iPad in the field, where the constraints are different
   from a desk: the screen is 1024px at best, the pointer is a finger, and a grid can run
   to eleven columns. These rules are about those two facts. */

/* The GM tab strip is eleven items. Wrapping it into three rows pushes the data below the
   fold before anything has loaded; scrolling it sideways keeps the page shape stable and is
   a familiar gesture on a touch screen. */
.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.nav-tabs .nav-item { flex: 0 0 auto; }
.nav-tabs .nav-link { white-space: nowrap; }

/* A long grid scrolls inside its own box, so the column headings have to stay put — reading
   row 400 of a member list is useless if you cannot see which column you are in. */
.data-table-wrapper thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fb;
}

@media (prefers-color-scheme: dark) {
    .data-table-wrapper thead th { background: #23262d; }
}

/* Touch, rather than screen width: a mouse is precise at 13px, a finger is not. Keyboard and
   mouse users keep the tighter grid. */
@media (pointer: coarse) {
    /* Give the grid its own scroll box so the sticky headings above have something to stick
       to — otherwise the whole page scrolls and the column names leave the screen. */
    .data-table-wrapper { max-height: 70vh; overflow: auto; }

    .data-table td,
    .data-table th { padding-top: 12px; padding-bottom: 12px; }

    /* A checkbox that selects a member for reassignment is worth hitting first time. */
    .data-table input[type="checkbox"],
    .form-check-input { width: 22px; height: 22px; }

    /* 44px is the smallest comfortable target on iOS; several of these buttons sat under it. */
    .btn, .btn-cfib, .btn-secondary-cfib, .btn-tertiary-cfib { min-height: 44px; }
    .btn-sm { min-height: 40px; }

    /* Filter controls sit shoulder to shoulder in a row of col-md-2s; on a touch screen they
       need room between them so the wrong one is not caught. */
    .filter-bar, .card-body > .row { row-gap: var(--space-3); }
}

/* Landscape iPad: the filter row is built from col-md-*, which Bootstrap keeps on one line
   from 768px up. Six controls on one line at this width leaves each too narrow to read, so
   let them share two lines instead. */
@media (min-width: 768px) and (max-width: 1024px) {
    .card-body > .row > [class*="col-md-2"] { flex: 0 0 auto; width: 33.333%; }
    .card-body > .row > [class*="col-md-3"] { flex: 0 0 auto; width: 50%; }
}


/* ─── GM section: filter bars ─────────────────────────────────────────
   These screens carry far more filters than the rest of the Toolbox — Leads has
   fifteen controls, Oppos thirteen — and they were assembled a control at a time. The
   result reads as ragged: labels at three different sizes, columns at four different
   widths, and a select with a checkbox under it sitting taller than its neighbours so
   the row loses its baseline. This is presentation only; no markup or behaviour changes,
   which is why it can be a stylesheet rule rather than an edit to twelve pages. */

/* Bottom-align every control in a filter row. A select with a checkbox beneath it is
   taller than a bare select, and without this the shorter ones float to the top. */
.gm-section .card-body > .row > [class*="col-md"],
.gm-section .card-body > .row > [class*="col-lg"] {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* One label treatment. Fifty-two of these carry the same three properties inline; this
   makes the handful that do not match the rest, and lets the inline ones fall away over
   time without a flag-day edit. */
.gm-section .form-label {
    font-size: var(--text-md);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

/* Equal heights, so a row of selects and inputs sits on one line rather than stepping. */
.gm-section .form-select,
.gm-section .form-control { min-height: 44px; }

/* A checkbox under a control belongs to it: close enough to read as one unit, and never
   pushing the row taller than it needs to be. */
.gm-section .card-body > .row .form-check {
    margin-top: var(--space-2);
    margin-bottom: 0;
    min-height: 0;
}
.gm-section .card-body > .row .form-check-label { font-size: var(--text-sm); }

/* Filter rows breathe vertically when they wrap onto two lines, which they now do on an
   iPad and on any laptop below about 1400px. */
.gm-section .card-body > .row.g-3 { row-gap: var(--space-4); }

/* Buttons that sit at the end of a filter row line up with the inputs, not above them. */
.gm-section .card-body > .row > .col-md-auto { justify-content: flex-end; }
.gm-section .card-body > .row > .col-md-auto .btn { margin-bottom: 0; }

/* Card headers carry a title on the left and actions on the right; keep them centred on
   each other rather than top-aligned, and let a long tally wrap without shoving the
   buttons off the edge. */
.gm-section .card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

/* The badges these grids lean on — Parent, Orphan, via territory, inactive — were reading
   as loud as the data. Same size as the row, quieter weight. */
.gm-section .data-table .badge,
.gm-section .data-table .badge-ok,
.gm-section .data-table .badge-skip,
.gm-section .data-table .badge-fail { font-weight: 600; font-size: var(--text-xs); vertical-align: middle; }


/* ─── Drawer mode ─────────────────────────────────────────────────────
   The 1024px query above covers a base iPad and nothing newer: an Air is
   1180 CSS px in landscape, a Pro 11" is 1194 and a Pro 13" is 1366, so on
   the devices the GMs actually carry the sidebar was still pinned and still
   taking 250px off a grid that needs 1280. Rather than push the breakpoint
   up again and unpin every 1366px laptop for good, drawer mode is a class:
   the width only decides the default, and the sidebar footer carries a
   control to pin or unpin it. The media query above keeps the drawer
   working with JavaScript off. */
html.nav-drawer { --sidebar-width: 260px; }
html.nav-drawer #sidebar { transform: translateX(-100%); }
html.nav-drawer #sidebar.open { transform: translateX(0); }
html.nav-drawer .sidebar-toggle { display: flex; }
html.nav-drawer .sidebar-overlay.open { display: block; }
html.nav-drawer #content { margin-left: 0; }
html.nav-drawer .content-inner { padding: 60px 20px 32px; }

/* Pinning is a real choice only above the forced-drawer breakpoint; below it
   the control would be a dead end, so it is not rendered as one. */
.js-nav-mode { display: none; }
html.nav-mode-available .js-nav-mode { display: inline-block; }

/* ─── Collapsible filter panels and page notes ────────────────────────
   These screens carry more filters than anything else in the Toolbox, and
   on a tablet the filter bar plus the page note push the grid below the
   fold — so a GM who has already chosen their filters is scrolling to reach
   the data they asked for. Folding the bar away gives that room back. The
   selection is not hidden with it: a collapsed panel prints it in the
   header, so the grid never shows a filtered view with no visible reason. */
.panel-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.panel-toggle:focus-visible { outline: 2px solid var(--cfib-red); outline-offset: 2px; }

.panel-toggle-label { font-weight: 700; flex-shrink: 0; }

.panel-toggle-summary {
    flex: 1;
    min-width: 0;
    font-weight: 400;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Points right when folded, down when open. */
.panel-toggle-caret {
    flex-shrink: 0;
    width: 0; height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transform: rotate(-90deg);
    transition: transform 0.15s ease;
}
.panel-toggle[aria-expanded="true"] .panel-toggle-caret { transform: rotate(0deg); }

/* A finger-sized target, matching the 44px controls in the filter rows. */
.panel-toggle-header { min-height: 44px; }

.panel-collapsed { display: none !important; }

/* The note under each page title is worth reading once and then costs a
   third of a tablet screen for good. */
.page-note-toggle {
    background: none;
    border: none;
    padding: 2px 0;
    margin: var(--space-1) 0 0;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--cfib-red);
    cursor: pointer;
    text-decoration: underline;
}
.page-note-toggle:focus-visible { outline: 2px solid var(--cfib-red); outline-offset: 2px; }

@media (prefers-color-scheme: dark) {
    /* --cfib-red (#d81f3b) is 3.61:1 on the dark canvas; the lighter danger token clears AA. */
    .page-note-toggle { color: var(--color-danger); }
    .page-note-toggle:focus-visible { outline-color: var(--color-accent); }
}

@media (prefers-reduced-motion: reduce) {
    .panel-toggle-caret { transition: none; }
}


/* ─── GM section: fitting the grid on the device ──────────────────────
   Oppos carries eleven columns. Headers were nowrap, and every cell paid
   16px of padding on each side, so the narrowest the table could be drawn
   was about 1100px before a single business name was measured -- against
   roughly 980px of usable width on a 1024px iPad. Hence the sideways
   scroll, on the one device these screens are actually used on.

   Three things buy that width back, in the order they matter: headers
   wrap ("Renewal Period" over two lines instead of one long one), cell
   padding halves, and the table drops to 16px. 16px is the floor across
   this stylesheet -- iOS zooms anything smaller -- so the type stops
   there and the rest comes from layout.

   min-width: 0 is what makes it a guarantee rather than an improvement:
   with nothing forcing a minimum and every cell free to wrap, the table
   cannot be wider than the space it is given. */
/* ─── GM grids: one scroll context, at every width ──────────────────
   These three rules were written for iPads and lived inside
   @media (max-width: 1366px). That was the bug, not the fix: five GM pages
   carry an inline max-height:60vh;overflow:auto on .data-table-wrapper, so
   above 1366px the wrapper stayed a scroll container. The consequence is
   visible on any desktop wider than that -- the table header scrolls away
   instead of sticking, because position:sticky measures against the nearest
   scrolling ancestor, and the vertical scrollbar sits inside the card rather
   than on the page. Reported on Opportunities at 2182px.

   Nothing about the reasoning was ever width-dependent, so none of it is
   gated now.

   One scroll, not two: the grids sat in a 60vh box with its own scrollbar
   inside a page that also scrolled, so a drag did whichever of the two the
   finger or wheel happened to land on. Let the page be the only thing that
   scrolls, and the headers stick to the viewport where they are useful. The
   inline max-height needs !important to beat it. */
.gm-section .data-table-wrapper {
    max-height: none !important;
    overflow: visible !important;
}

/* #content must then stop clipping what the wrapper no longer scrolls.
   overflow-x: hidden there silently cut the right-hand columns off --
   unreachable rather than merely off-screen, which is worse than the
   sideways scroll it was avoiding.
   Deliberately not a new scroll container: CSS computes overflow-x:auto with
   overflow-y:visible as auto on BOTH axes, which would put the vertical
   scroll back inside a box and unstick the headers all over again. Letting
   the document scroll keeps one scroll context and keeps position:sticky
   measuring against the viewport. */
#content { overflow-x: visible; }

/* That lift had a cost on every OTHER page. #content is a flex item of #wrapper, and
   overflow-x: hidden was what made it a scroll container, whose automatic minimum
   width is 0. Without it the minimum is its min-content, so any data table (480px
   minimum plus unwrapped cells) widened the whole content column past a phone's
   viewport: the filter bar, the bulk bar and the page header ran off the right edge
   and the document panned sideways, instead of the table scrolling inside its
   .data-table-wrapper. min-width: 0 gives the column back to the viewport. The GM
   pages already set it (html.gm-page above) and still pan the document by design. */
#content { min-width: 0; }

/* And .content-inner, for the same reason plus a worse one: overflow-x:auto
   there makes it a scroll container, so sticky headings measure against that
   box instead of the viewport and stop sticking mid-page-scroll. Nothing
   between the table and the document may scroll. */
.gm-section.content-inner { overflow-x: visible; }

@media (max-width: 1366px) {
    .gm-section .data-table {
        min-width: 0;
        font-size: var(--text-sm);
    }

    /* The long ones -- Renewal Period, Open Oppos, Assign to Opp -- are
       most of the excess. Let them stack. */
    .gm-section .data-table th {
        white-space: normal;
        padding: var(--space-2) var(--space-3);
    }

    /* Wrap at spaces, and only at spaces. overflow-wrap: anywhere was here
       and was far too blunt: it let a column's minimum width fall to one
       character, so a DM name came out three letters wide and five lines
       tall, and a money figure broke mid-number -- which is what made NRG
       unreadable. A name has spaces to break at; a number has none and now
       stays whole. */
    .gm-section .data-table td {
        white-space: normal;
        padding: var(--space-2) var(--space-3);
    }

    /* Buttons and checkboxes are the exception: wrapping those reads as
       breakage, not as density. */
    .gm-section .data-table .col-action,
    .gm-section .data-table .col-select {
        white-space: nowrap;
    }


    /* A city or a status is short enough to sit on one line, and wrapping
       them buys nothing while making a row two lines tall. */
    .gm-section .data-table .col-tight { white-space: nowrap; }

    /* Leads sets its own 15px, under the 16px floor the rest of the app
       holds to, which is what makes iOS zoom the page on a tap. */
    .gm-section #leadsTable { font-size: var(--text-sm); }
}

/* The two-line filter row was capped at 1024px, so an iPad Air (1180) or a
   Pro (1194/1366) put six controls on one line and made each unreadable.
   Same range as drawer mode, for one rule about what "a tablet" is. */
@media (min-width: 768px) and (max-width: 1366px) {
    .gm-section .card-body > .row > [class*="col-md-2"] { flex: 0 0 auto; width: 33.333%; }
    .gm-section .card-body > .row > [class*="col-md-3"] { flex: 0 0 auto; width: 50%; }
}


/* ─── The search that was hiding inside a folded filter bar ───────────
   Every one of these screens already had a search box; folding the filter
   bar by default is what hid it, and "710 of 7290" with no visible way to
   search is worse than the space the bar was costing. The script lifts the
   search input into the panel header, so it stays put whether the bar is
   folded or open -- one control that is always there. */
.panel-toggle-header .panel-search {
    flex: 0 1 260px;
    min-width: 0;
    margin-left: auto;
}

.panel-toggle-header .panel-search input {
    width: 100%;
    min-height: 40px;
    font-size: var(--text-sm);
    padding: 4px var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface, #fff);
    color: inherit;
}

/* The header is a flex row holding the toggle button and now the search, so
   the button must stop claiming the whole width. */
.panel-toggle-header .panel-toggle { width: auto; flex: 1 1 auto; min-width: 0; }

@media (max-width: 575px) {
    /* Too narrow to sit beside the label; give it its own line. */
    .panel-toggle-header { flex-wrap: wrap; }
    .panel-toggle-header .panel-search { flex: 1 1 100%; margin-left: 0; }
}


/* ─── Column filter row ───────────────────────────────────────────────
   Sits under the headings on the dense grids. Deliberately NOT sticky:
   the heading row above it is, and two sticky rows in one thead need a
   hard-coded offset for the second, which a wrapped two-line heading
   immediately makes wrong. So the headings follow you down and the
   controls stay where they were put -- scroll up to change them. */
.grid-filter-row th {
    position: static;
    padding: var(--space-1) var(--space-2) var(--space-2);
    background: #f8f9fb;
    border-bottom: 1px solid var(--color-border-soft);
}

.grid-filter-input {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    font-size: var(--text-xs);
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    padding: 2px var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
}

.grid-filter-input:focus-visible {
    outline: 2px solid var(--cfib-red);
    outline-offset: 1px;
}

/* Says so when a column filter is hiding rows, because the card header
   above counts the rows the page loaded, not the ones left after this. */
.grid-filter-count {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    padding: var(--space-2) var(--space-4) 0;
}
.grid-filter-count:empty { display: none; }

/* A promoted search box leaves its own label behind in the folded body.
   Harmless while the bar was folded; a caption with nothing under it once
   the bars started open. */
.panel-search-orphan { display: none !important; }

/* GM filter bars are Bootstrap rows of col-md-*, and they wrap and misalign:
   the widths add up to more than twelve, and align-items-end measures a
   column's whole height, so one tick box hanging off a picker drops that
   column's label below its neighbours'. Point the row at an auto-fitting grid
   and let the col-* widths go: every cell becomes one track, the labels start
   at a common top, and the track count follows the width. Leads wraps its row
   in a form, hence the second selector. */
.gm-section .js-filter-panel .card-body > .row,
.gm-section .js-filter-panel .card-body > form > .row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-4);
    /* !important beats Bootstrap.s own .align-items-end utility, which is what
       bottom-aligned these cells: a column carrying a tick box under its control
       is taller than its neighbours, so bottom-aligning it pushed its label a row
       higher than the rest. That is the misalignment, and start is the fix. */
    align-items: start !important;
    margin: 0;
}
.gm-section .js-filter-panel .card-body > .row > [class*="col-"],
.gm-section .js-filter-panel .card-body > form > .row > [class*="col-"] {
    /* Bootstrap sizes columns with flex-basis and max-width; as grid items
       those fight the track sizing, so they are handed back. */
    flex: none;
    width: auto;
    max-width: none;
    padding: 0;
    min-width: 0;
}
.gm-section .js-filter-panel .card-body .row .form-label { font-size: var(--text-md); margin-bottom: var(--space-2); }
.gm-section .js-filter-panel .card-body .row .form-select,
.gm-section .js-filter-panel .card-body .row .form-control { width: 100%; font-size: var(--text-md); }

/* A tick box still declared under its filter: kept there, but given air so it
   reads as attached to that control rather than colliding with the next row. */
.gm-section .js-filter-panel .card-body .row .form-check { margin-top: var(--space-2); }

/* Action groups (Select all / Clear, Search / Export) and the odd loose tick
   box ride in that row as col-md-auto, content-sized by Bootstrap. Dropped into
   a fixed 190px track they either wrap a three-button group into a column or
   sink to the bottom of it. Give them the whole width instead, below the
   filters and laid out inline -- the shape the options strip has on
   Opportunities, arrived at from the other direction. */
.gm-section .js-filter-panel .card-body .row > .col-md-auto {
    grid-column: 1 / -1;
    display: flex;
    /* Explicit: the GM tidy block above sets flex-direction column on every
       filter cell, which turned align-items into the horizontal axis and
       centred this whole strip on the panel. */
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    /* An older GM rule right-aligns these; on a full-width line that strands
       them opposite the filters they belong to. */
    justify-content: flex-start;
}
.gm-section .js-filter-panel .card-body .row > .col-md-auto .ms-2 { margin-left: 0 !important; }


@media (prefers-color-scheme: dark) {
    .grid-filter-row th { background: #23262d; }
    .grid-filter-input { background: #1b1e24; border-color: #3a3f47; }
}


/* ─── Stacked grids on a phone ──────────────────────────────────────
   "I love using this new tool on my computer VS on my phone, because it's much
   more readable" -- with the group sales referral list given as the example. Ten
   columns is not a table anyone reads on a 390px screen, and sideways scrolling
   only makes it reachable, not readable.

   Below 576px each row becomes its own block and each cell carries its heading,
   from the data-label the page writes onto every td. Opt in with .stacked-sm.

   thead is clipped rather than display:none on purpose: display:none takes it
   out of the accessibility tree with it, and a screen reader then loses the
   header/cell association that makes the table navigable at any width. */
@media (max-width: 575px) {
    .data-table.stacked-sm thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .data-table.stacked-sm tr {
        display: block;
        border: 1px solid var(--color-border, #dee2e6);
        border-radius: 8px;
        margin: 0 12px 12px;
        padding: 4px 0;
        background: var(--color-surface, #fff);
    }

    .data-table.stacked-sm td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 16px;
        border: 0;
        padding: 6px 12px;
        text-align: right;
    }

    .data-table.stacked-sm td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        color: var(--color-text-muted, #6c757d);
        flex: 0 0 auto;
    }

    /* An empty cell stacked is a labelled blank line -- noise on the axis where
       there is least room. A row with nothing in it says nothing. */
    .data-table.stacked-sm td:empty { display: none; }

    /* The empty-state row spans the table and has no label of its own. */
    .data-table.stacked-sm td[colspan] { display: block; text-align: center; }
    .data-table.stacked-sm td[colspan]::before { content: none; }
}

/* ---------- Coach launcher ----------
   The same button as MXRD and the Legislative Lens: 56px CFIB Red disc, white chat bubble.
   #D31145 on purpose rather than --color-primary (#C41230): it is the coach's mark across three
   apps, not this app's action colour, and it stays the same in dark mode. White on it is 5.14:1. */
.coach-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1040;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    color: #fff;
    background: #D31145;
    border-radius: 50%;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    text-decoration: none;
}

.coach-fab:hover,
.coach-fab:focus-visible {
    color: #fff;
    background: #B80E3A;
}

.coach-fab:focus-visible {
    outline: 2px solid #0076BB;
    outline-offset: 3px;
}

/* Room under the last row for it (56px + 24px inset), so it never sits on a pager or a Save
   button. Keyed on #main so it outranks the responsive padding shorthands above, which would
   otherwise reset the bottom on tablet and phone. */
#main.content-inner { padding-bottom: 104px; }

@media print {
    .coach-fab { display: none; }
}

/* ─── List screens with a request (Rebuild a Briefcase) ───────────────
   A section heading and note, a status panel for what a request came to,
   and a second line in a cell. Tokens only, so the dark block needs
   nothing extra. */
.section-title { font-size: var(--text-xl); font-weight: 700; color: var(--color-text); margin: 0 0 var(--space-1); }
.section-note  { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-3); }
.cell-note     { color: var(--color-text-subtle); font-size: var(--text-sm); margin-top: 2px; }

/* An error that belongs to one field, shown under it (WCAG 3.3.1). */
.field-error { color: var(--color-danger); font-size: var(--text-sm); font-weight: 600; margin-top: var(--space-1); max-width: 34ch; }
.form-control[aria-invalid="true"] { border-color: var(--color-danger); }

.status-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
    color: var(--color-text);
}
.status-panel-ok { border-left-color: var(--color-success); }

/* The bulk bar of a screen whose ONE primary action lives in it. Always shown, on a
   surface plate rather than the blue band: the band's button rules (.bulk-bar button)
   would turn the red primary into a ghost button, and a primary nobody can find until
   they tick something is the problem the Content list already had. */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-2) var(--space-4);
    margin-bottom: var(--space-3);
}
.action-bar .bulk-count { font-weight: 700; font-size: var(--text-sm); color: var(--color-text); margin-right: auto; }

/* A status badge whose wording is a sentence ("Failed - the build timed out") wraps
   inside its cell instead of widening the table past its card. A pill radius on two
   lines reads as a blob, so it takes the control radius, and the dot sits on line one.
   Scoped to .data-table so it outranks .badge-info:not(.badge), which would keep that one
   pill on a single line and hold a stacked card wider than the phone. */
.data-table .badge-wrap { white-space: normal; border-radius: var(--radius-md); align-items: flex-start; padding-top: 3px; padding-bottom: 3px; }
.data-table .badge-wrap::before { margin-top: calc((1lh - 6px) / 2); }

/* A row checkbox with a 44px target (our touch-target standard); the label is the target. */
.pick-target {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: calc(-1 * var(--space-2)) 0;
    cursor: pointer;
}

/* A cell's content in one block, so a name and the notes under it stay one thing. */
.cell-stack { min-width: 0; }

/* Stacked on a phone (.stacked-sm, above), with .stacked-start: the labels form one
   column and the values another, both left-aligned. Right-aligned values suit one-word
   cells; a name with a two-line note under it reads as a paragraph only from the left.
   Only tables that opt in with .stacked-start get these, so the GM grids are untouched. */
@media (max-width: 575px) {
    /* A stacked table is still display: table, so it is never narrower than its widest
       unbreakable content, whatever its width says. The 480px floor goes, and a fixed
       layout makes 100% mean the card: what does not fit wraps inside the row instead. */
    .data-table.stacked-sm.stacked-start { min-width: 0; table-layout: fixed; }
    .data-table.stacked-sm.stacked-start td {
        justify-content: flex-start;
        gap: var(--space-3);
        text-align: left;
        overflow-wrap: break-word;
    }
    /* Labels wrap ("Briefcase / built") rather than push the value column off the card. */
    .data-table.stacked-sm.stacked-start td::before { flex: 0 0 6.5em; white-space: normal; }
    .data-table.stacked-sm.stacked-start .cell-stack { flex: 1 1 0; }
    /* The rows are cards with 12px at the sides and below; the first had none above, so it
       sat on the card's top edge, or on the bottom of a Download CSV pill above the table. */
    .data-table.stacked-sm.stacked-start tbody tr:first-child { margin-top: var(--space-3); }
    /* The second part of a value (a group's acronym) inline on a desktop, below it here. */
    .data-table.stacked-sm.stacked-start .cell-sub { display: block; }
    /* The checkbox column's 36px would squeeze the whole stacked row; the target keeps 44px. */
    .data-table.stacked-sm.stacked-start .col-select { width: auto; align-items: center; }
}

/* The narrowest phones (320px): beside a label column, a value has about 70px, less than
   one badge or one long word. Each label goes above its value instead. */
@media (max-width: 359px) {
    .data-table.stacked-sm.stacked-start td { display: block; }
    .data-table.stacked-sm.stacked-start td::before { display: block; }
}
