/* ==========================================================================
   ci-components.css — first-party component layer on ci design tokens
   --------------------------------------------------------------------------
   PURPOSE
   Foundation for the Bootstrap → Tailwind + ci-components migration (Stage A).
   Every interactive/visual Bootstrap primitive the legacy pages use has a
   token-based .ci-* counterpart here. Converted markup (Stage B) swaps
   Bootstrap component classes for these + Tailwind utilities for layout;
   see docs/UI-CONVERSION-MAP.md — the authoritative mechanical map.

   PRINCIPLES
   - NO Bootstrap class names, NO Bootstrap selectors. First-party .ci-* only.
   - Every colour/surface/radius resolves through var(--ci-*), so html.dark
     token flips restyle every component automatically.
   - Sizing (padding/heights) mirrors Bootstrap 5.3 defaults so a class swap
     is visually calm; radii/colours follow the ci design language instead.
   - Modifiers use the existing double-dash convention (.ci-btn--primary),
     matching .ci-stat--success / .ci-card-body--flush in ci-theme.css.
   - Brand colour honours the 25-theme system: var(--theme-primary,
     var(--ci-brand-primary)) — never hardcode #e5461f.

   BEHAVIOURAL CONTRACT (assets/js/ci-bs.js — the first-party engine that
   replaced bootstrap.bundle.min.js in Stage C — drives elements via
   data-bs-* attributes and toggles .show / .fade / .collapsing classes,
   which these styles honour):
   - .ci-modal        → display:none → inline display + .show (Modal engine)
   - .ci-collapse     → :not(.show) hidden; .collapsing height transition
   - .ci-dropdown-menu→ display:none → .show (Dropdown engine)

   LOAD ORDER (must not drift)
   1. assets/vendor/fonts/fonts.css
   2. assets/css/ci-theme.css        ← tokens + shell
   3. assets/css/ci-components.css   ← THIS FILE
   Bootstrap was unlinked at Stage C: the legacy Bootstrap-name selectors it
   left behind (.modal/.alert/.fade/.btn-close/…) are owned by the Stage C
   compatibility layer at the bottom of this file — token-based, they render
   correctly in light AND dark mode.

   Sizes chosen against the Stage-A class audit (Nov 2026):
   btn family 2.9k uses · forms 3.4k · cards 2.5k · alerts 910 ·
   badges 679 · tables 449 · pagination 216 · modals 207 · accordions 54 ·
   dropdowns 54 · progress 78 · spinners 20 · list-groups 52.
   ========================================================================== */

/* ── Shared focus ring ────────────────────────────────────────────────────
   Used by buttons, form controls, checkboxes — one visual focus language. */
.ci-btn:focus-visible,
.ci-form-control:focus-visible,
.ci-form-select:focus-visible,
.ci-input-group-text:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 20%, transparent);
}

/* ==========================================================================
   Buttons (.btn 1161 · .btn-primary 277 · .btn-sm 280 · .btn-lg 92 …)
   Padding/typography mirror BS .btn so swaps are calm; radius is ci-md.
   ========================================================================== */
/* Export/download buttons authored as icon + bold label + <small class="block">
   subtitle. They were written for inline-block (children stack); under
   inline-flex they would line up in a row, so restore the stacked layout. */
.ci-btn:has(> small.block) {
    flex-direction: column;
    gap: 0.25rem;
    height: auto;
    text-align: center;
}

.ci-btn--stack {
    /* Icon-over-label "tile" buttons (cloud integration destinations).
       .ci-btn became inline-flex, which lays children out in a row and makes
       the icons' `block` class meaningless — this restores the stacked look. */
    flex-direction: column;
    gap: 0.5rem;
    height: auto;
    text-align: center;
}

.ci-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.5;
    color: var(--ci-text);
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ci-radius-md);
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
                border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.ci-btn:disabled, .ci-btn.disabled { pointer-events: none; opacity: 0.6; }

/* Heading icons: breathing room after the glyph (icons converted from FA
   carry no trailing whitespace in the markup). */
h1 .ci-icon, h2 .ci-icon, h3 .ci-icon,
h4 .ci-icon, h5 .ci-icon, h6 .ci-icon { margin-inline-end: 0.5rem; }

/* Inline icons ahead of a label in flow content (list items, paragraphs,
   table cells, small captions). The FA→lucide sweep dropped `me-2` from most
   of these and only headings/.ci-btn regained spacing, so glyphs sat flush
   against the text. Buttons and stacked tiles are excluded (they use gap). */
li > .ci-icon,
p > .ci-icon,
td > .ci-icon,
small > .ci-icon,
.ci-stat-label-row > .ci-icon,
label > .ci-icon {
    margin-inline-end: 0.35rem;
    vertical-align: -0.15em;
}

/* Sizes (BS parity) */
.ci-btn--sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: var(--ci-radius-sm); }
.ci-btn--lg { padding: 0.5rem 1rem;   font-size: 1.25rem;  border-radius: var(--ci-radius-md); }

/* Full-width (d-grid gap-2 pattern) */
.ci-btn--block { display: flex; width: 100%; }

/* Primary — solid brand */
.ci-btn--primary {
    background: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    color: #fff;
}
.ci-btn--primary:hover, .ci-btn--primary:focus, .ci-btn--primary:active {
    background: var(--theme-primary-dark, var(--ci-brand-dark));
    border-color: var(--theme-primary-dark, var(--ci-brand-dark));
    color: #fff;
}

/* Secondary — solid neutral (used for cancel/back affordances) */
.ci-btn--secondary {
    background: var(--ci-gray-600);
    border-color: var(--ci-gray-600);
    color: #fff;
}
.ci-btn--secondary:hover, .ci-btn--secondary:focus, .ci-btn--secondary:active {
    background: color-mix(in srgb, var(--ci-gray-600) 85%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-gray-600) 85%, var(--ci-text));
    color: #fff;
}

/* Status buttons — tinted surface + status border + status text.
   Text mixes toward --ci-text so it passes AA in light AND dark. */
.ci-btn--success, .ci-btn--danger, .ci-btn--warning, .ci-btn--info {
    border-width: 1px;
}
.ci-btn--success {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 40%, transparent);
}
.ci-btn--success:hover, .ci-btn--success:active {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 20%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 55%, transparent);
}
.ci-btn--danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 40%, transparent);
}
.ci-btn--danger:hover, .ci-btn--danger:active {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 20%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 55%, transparent);
}
.ci-btn--warning {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 45%, transparent);
}
.ci-btn--warning:hover, .ci-btn--warning:active {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 22%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 60%, transparent);
}
.ci-btn--info {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 40%, transparent);
}
.ci-btn--info:hover, .ci-btn--info:active {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 20%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 55%, transparent);
}

/* Outline variants */
.ci-btn--outline-primary {
    color: var(--theme-primary, var(--ci-brand-primary));
    border-color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 55%, transparent);
}
.ci-btn--outline-primary:hover, .ci-btn--outline-primary:active {
    background: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    color: #fff;
}
.ci-btn--outline-secondary {
    color: var(--ci-text-muted);
    border-color: var(--ci-border);
}
.ci-btn--outline-secondary:hover, .ci-btn--outline-secondary:active {
    background: var(--ci-surface-hover);
    border-color: var(--ci-border);
    color: var(--ci-text);
}
/* Destructive action that must not dominate the page (schedules Delete,
   organisation delete confirmations). Mirrors outline-primary's fill-on-hover. */
.ci-btn--outline-danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-danger) 55%, transparent);
}
.ci-btn--outline-danger:hover, .ci-btn--outline-danger:active {
    background: var(--ci-danger);
    border-color: var(--ci-danger);
    color: #fff;
}

/* Quiet icon-button (toolbar/edit-table actions) */
.ci-btn--quiet {
    color: var(--ci-text-muted);
    border-color: transparent;
    padding: 0.25rem 0.5rem;
}
.ci-btn--quiet:hover {
    color: var(--ci-text);
    background: var(--ci-surface-hover);
}

/* Danger link (delete actions inside rows) */
.ci-btn--link-danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    padding: 0.25rem 0.5rem;
}
.ci-btn--link-danger:hover {
    background: color-mix(in srgb, var(--ci-danger) 12%, transparent);
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
}

/* Button group (visual only; join radii) */
.ci-btn-group {
    display: inline-flex;
    position: relative;
    vertical-align: middle;
}
.ci-btn-group > .ci-btn { position: relative; flex: 1 1 auto; }
.ci-btn-group > .ci-btn:not(:first-child) { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.ci-btn-group > .ci-btn:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ci-btn-group > .ci-btn:hover { z-index: 1; }

/* ==========================================================================
   Forms (.form-control 898 · .form-label 1184 · .form-select 312 …)
   ========================================================================== */
.ci-form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    color: var(--ci-text);
    font-weight: 500;
    font-size: 0.9rem;
}
.ci-form-control, .ci-form-select {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ci-text);
    background-color: var(--ci-surface-raised);
    background-clip: padding-box;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
    appearance: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.ci-form-control::placeholder { color: var(--ci-text-muted); opacity: 1; }
.ci-form-control:disabled, .ci-form-select:disabled {
    background-color: color-mix(in srgb, var(--ci-surface-hover) 60%, transparent);
    color: var(--ci-text-muted);
    cursor: not-allowed;
}
.ci-form-control:focus, .ci-form-select:focus {
    border-color: var(--theme-primary, var(--ci-brand-primary));
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 20%, transparent);
}
.ci-form-control--sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: var(--ci-radius-sm); }

/* Select: caret via inline SVG so it flips with the muted token in dark */
.ci-form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23666464' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem;
}
.dark .ci-form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b0b0b0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Textarea default feels like BS */
textarea.ci-form-control { min-height: calc(1.5em + 0.75rem + 2px); }

/* File inputs: keep the native control's behaviour but replace the browser's
   default "IE-era" button/filename look with the design-system button. Works
   for every upload in the app with no JS. */
input[type="file"] {
    color: var(--ci-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
}
input[type="file"].ci-form-control {
    padding: 0.3rem 0.5rem;
    min-height: 44px;
    line-height: 1.6;
}
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
    appearance: none;
    -webkit-appearance: none;
    margin: 0 0.75rem 0 0;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
    background: var(--ci-surface);
    color: var(--ci-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover {
    background: var(--ci-surface-hover);
    border-color: var(--theme-primary, var(--ci-brand-primary));
}
input[type="file"]:focus-visible {
    outline: 2px solid var(--theme-primary, var(--ci-brand-primary));
    outline-offset: 2px;
}
@media (max-width: 767.98px) {
    input[type="file"].ci-form-control { width: 100%; }
    input[type="file"]::file-selector-button,
    input[type="file"]::-webkit-file-upload-button { min-height: 40px; }
}

/* Enhanced control (assets/js/ci-files.js): the native input is visually
   hidden and a design-system button + filename readout drive it. Without JS
   the styles above keep the native control presentable. */
input[type="file"].ci-file-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    max-width: 1px !important;
    max-height: 1px !important;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ci-file-ui {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.ci-file-ui-name {
    font-size: 0.8rem;
    color: var(--ci-text-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .ci-file-ui .ci-btn {
        min-height: 44px;
    }
}

/* Check / radio (232 uses) */
.ci-form-check { display: block; min-height: 1.5rem; padding-left: 1.5em; margin-bottom: 0.125rem; }
.ci-form-check-input {
    float: left;
    margin-left: -1.5em;
    margin-top: 0.25em;
    width: 1em;
    height: 1em;
    vertical-align: top;
    background-color: var(--ci-surface-raised);
    border: 1px solid var(--ci-gray-300);
    appearance: none;
    print-color-adjust: exact;
}
.dark .ci-form-check-input { border-color: var(--ci-gray-600); }
.ci-form-check-input[type='checkbox'] { border-radius: var(--ci-radius-sm); }
.ci-form-check-input[type='radio'] { border-radius: 50%; }
.ci-form-check-input:checked {
    background-color: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
}
.ci-form-check-input:checked[type='checkbox'] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
.ci-form-check-input:checked[type='radio'] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
.ci-form-check-input:focus {
    border-color: var(--theme-primary, var(--ci-brand-primary));
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 20%, transparent);
}
.ci-form-check-label { display: inline; color: var(--ci-text); }

/* Validation (BS is-invalid pattern) */
.ci-form-control.ci-is-invalid, .ci-form-select.ci-is-invalid {
    border-color: var(--ci-danger);
}
.ci-form-control.ci-is-invalid:focus, .ci-form-select.ci-is-invalid:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--ci-danger) 20%, transparent);
}
.ci-invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
}
.ci-is-invalid ~ .ci-invalid-feedback,
.ci-form-control.ci-is-invalid ~ .ci-invalid-feedback { display: block; }
.ci-form-text { display: block; margin-top: 0.25rem; font-size: 0.875rem; color: var(--ci-text-muted); }

/* Input group (login page pattern: icon + input joined) */
.ci-input-group { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; width: 100%; }
.ci-input-group > .ci-form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}
.ci-input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ci-text-muted);
    text-align: center;
    white-space: nowrap;
    background-color: color-mix(in srgb, var(--ci-surface-raised) 88%, var(--ci-gray-100) 12%);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
}
.ci-input-group > .ci-input-group-text:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; }
.ci-input-group > .ci-form-control:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ==========================================================================
   Card extensions (base .ci-card/-header/-title/-body live in ci-theme.css)
   ========================================================================== */
.ci-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--ci-border);
    background: color-mix(in srgb, var(--ci-surface) 50%, transparent);
}
.ci-card-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: var(--ci-text-muted);
}

/* ==========================================================================
   Table extensions (base .ci-table lives in ci-theme.css)
   ========================================================================== */
.ci-table--sm th, .ci-table--sm td { padding: 0.45rem 0.75rem; }

.ci-table--striped tbody tr:nth-of-type(odd) {
    background: color-mix(in srgb, var(--ci-gray-400) 8%, transparent);
}
.ci-table--hover tbody tr:hover {
    background: color-mix(in srgb, var(--ci-gray-400) 10%, transparent);
}
/* Raised header variant (replaces .table-light thead pattern, 68 uses) */
.ci-table--head-raised thead th {
    background: color-mix(in srgb, var(--ci-surface-hover) 60%, transparent);
    color: var(--ci-text);
    font-size: 0.78rem;
}

/* Responsive wrapper: <div class="ci-table-responsive"><table class="ci-table …"> */
.ci-table-responsive { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Stacked card variant: <table class="ci-table ci-table--stack"> with a
   data-label="…" on every cell of a data row. Below the md breakpoint
   (768px) each row becomes a card and each cell a labelled block; an
   unlabelled cell (empty-state row) shows no caption. Desktop is untouched. */
@media (max-width: 767.98px) {
    .ci-table--stack thead { display: none; }

    .ci-table--stack tbody tr {
        display: block;
        border: 1px solid var(--ci-border);
        border-radius: var(--ci-radius-md);
        margin-bottom: 1rem;
        padding: 0.35rem 0.9rem 0.9rem;
        background: var(--ci-surface-raised);
    }

    .ci-table--stack tbody td {
        display: block;
        border: 0;
        padding: 0.45rem 0;
        width: auto;
        text-align: left;
    }

    .ci-table--stack tbody td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--ci-text-muted);
        margin-bottom: 0.15rem;
    }

    .ci-table--stack tbody td:not([data-label])::before { content: none; }

    /* Touch-sized controls fill the card width */
    .ci-table--stack tbody td select,
    .ci-table--stack tbody td input,
    .ci-table--stack tbody td .ci-form-control,
    .ci-table--stack tbody td .ci-form-control--sm {
        width: 100%;
        min-height: 44px;
    }

    .ci-table--stack tbody td .rating-display { font-size: 1rem; }

    /* A row card's action button (View/Open/…) is that row's touch control. */
    .ci-table--stack tbody td .ci-btn {
        min-height: 44px;
    }

    /* Edge-to-edge card bodies (API keys in settings/api.php, recent audits on
       the dashboard) need a gutter around the row cards the table turns into. */
    .ci-card-body.p-0 > .ci-table-responsive > .ci-table--stack,
    .ci-card-body--flush > .ci-table-responsive > .ci-table--stack {
        padding: 0.25rem 0.9rem 1rem;
    }
}

/* ==========================================================================
   Badges (679 uses) — tinted pills, AA text in both modes
   ========================================================================== */
.ci-badge {
    display: inline-block;
    padding: 0.28em 0.7em;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 999px;
    border: 1px solid transparent;
}
.ci-badge--primary {
    color: var(--theme-primary, var(--ci-brand-primary));
    background: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 12%, transparent);
    border-color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 30%, transparent);
}
.ci-badge--secondary {
    color: var(--ci-text-muted);
    background: color-mix(in srgb, var(--ci-gray-400) 14%, transparent);
    border-color: color-mix(in srgb, var(--ci-gray-400) 30%, transparent);
}
.ci-badge--success {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 32%, transparent);
}
.ci-badge--danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 32%, transparent);
}
.ci-badge--warning {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 14%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 35%, transparent);
}
.ci-badge--info {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 32%, transparent);
}

/* ==========================================================================
   Alerts (910 uses) — tinted, token-driven, dismissible pattern supported
   ========================================================================== */
.ci-alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--ci-radius-lg);
    font-size: 0.95rem;
}
.ci-alert--primary {
    color: var(--theme-primary, var(--ci-brand-primary));
    background: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 8%, transparent);
    border-color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 30%, transparent);
}
.ci-alert--success {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 32%, transparent);
}
.ci-alert--danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 32%, transparent);
}
.ci-alert--warning {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 35%, transparent);
}
.ci-alert--info {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 32%, transparent);
}
.ci-alert .ci-close { margin-left: auto; flex-shrink: 0; }

/* ==========================================================================
   Modal — full structural contract (ci-bs.js Modal engine)
   Wrapper: <div class="modal fade ci-modal" id="…" tabindex="-1">…
   The engine drives display/.show and creates a .ci-modal-backdrop element
   (styled below). Legacy `.modal`/`.modal-dialog` names stay grouped with
   the ci ones — they are the Stage-B structural contract.
   ========================================================================== */
.ci-modal, .modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
.ci-modal-dialog, .modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
}
@media (min-width: 576px) {
    .ci-modal-dialog, .modal-dialog { max-width: 500px; margin: 1.75rem auto; }
    .ci-modal-dialog--lg, .modal-lg { max-width: 800px; }
    .ci-modal-dialog--xl { max-width: 1140px; }
}
.ci-modal.fade .ci-modal-dialog,
.modal.fade .modal-dialog { transition: transform 0.3s ease-out; transform: translate(0, -50px); }
.ci-modal.show .ci-modal-dialog,
.modal.show .modal-dialog { transform: none; }
/* Vertically centered variant (4 uses, always paired with ci-modal-dialog) */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}
.ci-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    color: var(--ci-text);
}
.dark .ci-modal-content { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.ci-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--ci-border);
}
.ci-modal-title {
    margin: 0;
    font-family: var(--ci-font-display);
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ci-text);
}
.ci-modal-body { position: relative; flex: 1 1 auto; padding: 1rem; }
.ci-modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--ci-border);
}
.ci-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}
.ci-modal-backdrop.fade { opacity: 0; }
.ci-modal-backdrop.show { opacity: 0.5; }

/* ==========================================================================
   Dropdown — menu hidden until .show (BS Dropdown JS compatible)
   ========================================================================== */
.ci-dropdown { position: relative; display: inline-block; }
.ci-dropdown-toggle {
    cursor: pointer;
}
.ci-dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.5em;
    vertical-align: middle;
    content: '';
    border-top: 0.32em solid;
    border-right: 0.32em solid transparent;
    border-bottom: 0;
    border-left: 0.32em solid transparent;
}
.ci-dropdown-menu {
    position: absolute;
    top: 100%;
    z-index: 1000;
    display: none;
    min-width: 11rem;
    padding: 0.4rem 0;
    margin: 0.125rem 0 0;
    font-size: 0.95rem;
    color: var(--ci-text);
    text-align: left;
    list-style: none;
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.dark .ci-dropdown-menu { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.ci-dropdown-menu.show { display: block; }
.ci-dropdown-menu--end { right: 0; }
.ci-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 1rem;
    clear: both;
    font-weight: 400;
    color: var(--ci-text);
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background: none;
    border: 0;
    cursor: pointer;
}
.ci-dropdown-item:hover, .ci-dropdown-item:focus { background: var(--ci-surface-hover); color: var(--ci-text); }
.ci-dropdown-item.active { background: var(--theme-primary, var(--ci-brand-primary)); color: #fff; }
.ci-dropdown-item--danger { color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text)); }
.ci-dropdown-item--danger:hover { background: color-mix(in srgb, var(--ci-danger) 12%, transparent); }
.ci-dropdown-divider { height: 0; margin: 0.4rem 0; overflow: hidden; border-top: 1px solid var(--ci-border); }
.ci-dropdown-header {
    display: block;
    padding: 0.45rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ci-text-muted);
    white-space: nowrap;
}

/* ==========================================================================
   Tabs / nav links (38 uses) — BS Tab JS toggles .active on .ci-tab
   ========================================================================== */
.ci-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-left: 0;
    margin-bottom: 1rem;
    list-style: none;
    border-bottom: 1px solid var(--ci-border);
}
.ci-tab {
    display: block;
    padding: 0.5rem 0.9rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ci-text-muted);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    box-shadow: inset 0 -2px 0 0 transparent;
    transition: color 0.15s ease, box-shadow 0.15s ease;
}
.ci-tab:hover { color: var(--ci-text); }
.ci-tab.active, .ci-tab--active {
    color: var(--ci-text);
    box-shadow: inset 0 -2px 0 0 var(--theme-primary, var(--ci-brand-primary));
}
.ci-tab-pane { display: none; }
.ci-tab-pane.active { display: block; }

/* Generic nav link (sidebar-adjacent in-page nav, 22 uses) */
.ci-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: var(--ci-radius-md);
    color: var(--ci-text-muted);
    text-decoration: none;
}
.ci-nav-link:hover { background: var(--ci-surface-hover); color: var(--ci-text); }
.ci-nav-link.active { color: var(--theme-primary, var(--ci-brand-primary)); font-weight: 500; }

/* ==========================================================================
   Pagination (216 uses)
   ========================================================================== */
.ci-pagination {
    display: flex;
    list-style: none;
    padding-left: 0;
    gap: 0.3rem;
}
.ci-page-link {
    position: relative;
    display: block;
    padding: 0.375rem 0.75rem;
    font-size: 0.95rem;
    color: var(--ci-text);
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.ci-page-link:hover { background: var(--ci-surface-hover); color: var(--ci-text); }
.ci-page-item--active .ci-page-link {
    background: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    color: #fff;
}
.ci-page-item--disabled .ci-page-link {
    color: var(--ci-text-muted);
    pointer-events: none;
    opacity: 0.6;
}

/* ==========================================================================
   Progress (78 uses)
   ========================================================================== */
.ci-progress {
    display: flex;
    height: 0.85rem;
    overflow: hidden;
    font-size: 0.7rem;
    background: color-mix(in srgb, var(--ci-gray-400) 20%, transparent);
    border-radius: 999px;
}
.ci-progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    background: var(--theme-primary, var(--ci-brand-primary));
    border-radius: 999px;
    transition: width 0.4s ease;
}
.ci-progress-bar--success { background: var(--ci-success); }
.ci-progress-bar--danger  { background: var(--ci-danger); }
.ci-progress-bar--warning { background: var(--ci-warning); }
.ci-progress-bar--info    { background: var(--ci-info); }

/* ==========================================================================
   Spinner (20 uses) — border style, currentColor driven
   ========================================================================== */
.ci-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: -0.125em;
    border: 0.25em solid color-mix(in srgb, currentColor 25%, transparent);
    border-right-color: currentColor;
    border-radius: 50%;
    animation: ci-spinner-rotate 0.75s linear infinite;
}
.ci-spinner--sm { width: 1rem; height: 1rem; border-width: 0.2em; }
@keyframes ci-spinner-rotate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .ci-spinner { animation-duration: 1.5s; }
}

/* ==========================================================================
   List group (52 uses)
   ========================================================================== */
.ci-list-group {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    margin-bottom: 0;
    border-radius: var(--ci-radius-lg);
}
.ci-list-group-item {
    position: relative;
    display: block;
    padding: 0.7rem 1rem;
    color: var(--ci-text);
    text-decoration: none;
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
}
.ci-list-group-item:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.ci-list-group-item:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.ci-list-group-item + .ci-list-group-item { border-top-width: 0; }
/* Hover only recolours inactive rows. Without :not(.active) this selector
   outranks the .active rule (element + class + pseudo beats class + class)
   and paints a light hover surface under the active row's white text. */
a.ci-list-group-item:not(.active):hover,
button.ci-list-group-item:not(.active):hover { background: var(--ci-surface-hover); }
.ci-list-group-item.active {
    background: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    color: #fff;
}
/* Active rows keep the brand surface on hover, slightly deepened for feedback;
   the white text (and the category panel's small lines) stay readable. */
a.ci-list-group-item.active:hover,
button.ci-list-group-item.active:hover {
    background: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 88%, #000);
    border-color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 88%, #000);
    color: #fff;
}

/* ==========================================================================
   Breadcrumb (334 + 124 uses) — separators via ::before, muted trail
   ========================================================================== */
.ci-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    font-size: 0.875rem;
}
.ci-breadcrumb-item + .ci-breadcrumb-item { padding-left: 0.5rem; }
.ci-breadcrumb-item + .ci-breadcrumb-item::before {
    display: inline-block;
    padding-right: 0.5rem;
    color: var(--ci-text-muted);
    content: '/';
}
.ci-breadcrumb-item a { color: var(--theme-primary, var(--ci-brand-primary)); text-decoration: none; }
.ci-breadcrumb-item a:hover { text-decoration: underline; }
.ci-breadcrumb-item.active { color: var(--ci-text-muted); }

/* ==========================================================================
   Accordion (54 uses) — card + collapse contract; BS Collapse JS compatible
   ========================================================================== */
.ci-accordion-item {
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-lg);
}
.ci-accordion-item + .ci-accordion-item { margin-top: 0.5rem; }
.ci-accordion-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.9rem 1.25rem;
    font-family: var(--ci-font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ci-text);
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--ci-radius-lg);
    cursor: pointer;
}
.ci-accordion-button:hover { background: color-mix(in srgb, var(--ci-surface-hover) 50%, transparent); }
.ci-accordion-button::after {
    flex-shrink: 0;
    width: 1.15rem;
    height: 1.15rem;
    margin-left: auto;
    content: '';
    background-color: var(--ci-text-muted);
    mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") center/contain no-repeat;
    transition: transform 0.3s ease;
}
.ci-accordion-button.collapsed::after { transform: rotate(-90deg); }
.ci-accordion-body { padding: 0.5rem 1.25rem 1rem; color: var(--ci-text); }

/* ==========================================================================
   Collapse — behavioural contract (BS Collapse JS compatible)
   JS swaps .collapsing → .show and sets inline height during the transition.
   ========================================================================== */
.ci-collapse:not(.show):not(.collapsing) { display: none; }
.ci-collapse.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
    .ci-collapse.collapsing { transition: none; }
    .ci-modal.fade .ci-modal-dialog { transition: none; }
}

/* ==========================================================================
   Close button (.btn-close replacement, 203 uses) — mask + currentColor
   ========================================================================== */
.ci-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    font-size: 0;
    color: var(--ci-text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--ci-radius-sm);
    cursor: pointer;
}
.ci-close::before {
    content: '';
    width: 1rem;
    height: 1rem;
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-width='2' d='M3 3l10 10M13 3L3 13'/%3e%3c/svg%3e") center/contain no-repeat;
}
.ci-close:hover { color: var(--ci-text); background: var(--ci-surface-hover); }

/* ==========================================================================
   STAGE C COMPATIBILITY LAYER — Bootstrap-name contracts, first-party CSS
   --------------------------------------------------------------------------
   Bootstrap 5.3 was unlinked in Stage C. The legacy class names below are
   still live markup contracts (docs/BOOTSTRAP-REMOVAL-AUDIT.md §a): every
   rule here is token-based and dark-mode correct. No vendored CSS remains.
   ========================================================================== */

/* ── Reboot base — element styles the vendored sheet used to supply ──────
   Values mirror Bootstrap 5.3 reboot so unlinked pages do not shift.
   themes.css loads after this file and keeps overriding body/label/etc. via
   its --theme-* variables on the pages that load it. */
*, *::before, *::after { box-sizing: border-box; }
html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
    margin: 0;
    font-family: var(--ci-font-sans);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ci-text);
    text-align: left;
    background-color: var(--ci-surface);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 500;
    line-height: 1.2;
}
h1 { font-size: calc(1.375rem + 1.5vw); }
h2 { font-size: calc(1.325rem + 0.9vw); }
h3 { font-size: calc(1.3rem + 0.6vw); }
h4 { font-size: calc(1.275rem + 0.3vw); }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }
@media (min-width: 1200px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
}
p { margin-top: 0; margin-bottom: 1rem; }
small { font-size: 0.875em; }
hr {
    margin: 1rem 0;
    color: inherit;
    border: 0;
    border-top: 1px solid;
    opacity: 0.25;
}
a { color: #0d6efd; text-decoration: underline; }
a:hover { color: #0a58ca; }
img, svg { vertical-align: middle; }
ol, ul { padding-left: 2rem; }
ol, ul, dl { margin-top: 0; margin-bottom: 1rem; }
ol ol, ul ul, ol ul, ul ol { margin-bottom: 0; }
button, input, optgroup, select, textarea {
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}
button { text-transform: none; }
textarea { resize: vertical; }
fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
table { caption-side: top; border-collapse: collapse; }
[hidden] { display: none !important; }
code, kbd, pre, samp { font-family: var(--ci-font-mono); }
code { font-size: 0.875em; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
sub, sup { position: relative; font-size: 0.75em; line-height: 0; vertical-align: baseline; }
sub { bottom: -0.25em; }
sup { top: -0.5em; }

/* ── Generic engine state classes (ci-bs.js toggles these) ────────────── */
.fade { transition: opacity 0.15s linear; }
@media (prefers-reduced-motion: reduce) {
    .fade { transition: none; }
}
.fade:not(.show) { opacity: 0; }
.collapse:not(.show):not(.collapsing),
.ci-collapse:not(.show):not(.collapsing) { display: none; }
.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
    .collapsing { transition: none; }
}

/* ── Dropdown wrapper (header user menu, org switcher) ─────────────────── */
.dropdown, .dropup, .dropstart, .dropend { position: relative; }

/* ── Tab panes (tab-content/tab-pane structural contract) ─────────────── */
.tab-content > .tab-pane { display: none; }
.tab-content > .active { display: block; }

/* Warning-tinted headings/stat figures (text-ci-warning on h1–h6): the raw
   --ci-warning yellow fails contrast on light surfaces, so heading usage
   mixes toward the text token — same AA recipe as .ci-btn--warning. */
:is(h1, h2, h3, h4, h5, h6).text-ci-warning {
    color: color-mix(in srgb, var(--ci-warning) 65%, var(--ci-text));
}

/* ── .btn-close (89 dismiss buttons; legacy name, ci visuals) ──────────── */
.btn-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    font-size: 0;
    color: var(--ci-text-muted);
    background: transparent;
    border: 0;
    border-radius: var(--ci-radius-sm);
    cursor: pointer;
}
.btn-close::before {
    content: '';
    width: 1rem;
    height: 1rem;
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-width='2' d='M3 3l10 10M13 3L3 13'/%3e%3c/svg%3e") center/contain no-repeat;
}
.btn-close:hover { color: var(--ci-text); background: var(--ci-surface-hover); }
.btn-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 20%, transparent);
}
.btn-close-white, .dark .btn-close { color: #fff; }
.btn-close-white:hover { color: rgba(255, 255, 255, 0.75); background: transparent; }

/* ── Dismissible alert contract (88 alerts: alert alert-* + btn-close) ──
   Same tint recipe as .ci-alert--* so the two treatments read identically. */
.alert {
    position: relative;
    display: block;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--ci-radius-lg);
    font-size: 0.95rem;
    color: var(--ci-text);
}
.alert-primary {
    color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 8%, transparent);
    border-color: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 30%, transparent);
}
.alert-success {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 32%, transparent);
}
.alert-danger {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 32%, transparent);
}
.alert-warning {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 35%, transparent);
}
.alert-info {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 10%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 32%, transparent);
}
.alert-dismissible { padding-right: 3.5rem; }
.alert-dismissible .btn-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    z-index: 2;
}

/* ── btn-check segmented buttons (whatsapp/send ×5, dashboards/builder ×2)
   — consolidated here from the page-local rule in whatsapp/send.php ───── */
.btn-check {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}
.btn-check:checked + .ci-btn {
    background: var(--theme-primary, var(--ci-brand-primary));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    /* !important: the labels are <label> elements, and themes.css paints
       `label { color: … !important }` — without this the checked segment
       keeps dark text on the brand fill */
    color: #fff !important;
}
.btn-check:checked + .ci-btn:hover,
.btn-check:checked + .ci-btn:active {
    background: var(--theme-primary-dark, var(--ci-brand-dark));
    border-color: var(--theme-primary-dark, var(--ci-brand-dark));
    color: #fff !important;
}
.btn-check:focus-visible + .ci-btn {
    outline: none;
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 20%, transparent);
}

/* ── needs-validation (settings/whatsapp.php form; .was-validated is
   applied by JS — :invalid/:valid pseudo styling on ci form controls) ─── */
.was-validated .ci-form-control:invalid,
.was-validated .ci-form-select:invalid { border-color: var(--ci-danger); }
.was-validated .ci-form-control:invalid:focus,
.was-validated .ci-form-select:invalid:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--ci-danger) 20%, transparent);
}
.was-validated .ci-form-control:valid,
.was-validated .ci-form-select:valid { border-color: var(--ci-success); }
.was-validated :invalid ~ .ci-invalid-feedback { display: block; }

/* ── .table-dark (imports/upload.php preview table thead) ─────────────── */
.table-dark {
    background-color: var(--ci-gray-950);
    color: var(--ci-gray-100);
}
.table-dark th, .table-dark td { color: inherit; }
.dark .table-dark { background-color: var(--ci-gray-800); }

/* ── .visually-hidden (a11y parity; zero uses today) ───────────────────── */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── Toast (offline-manager.js notification; ci-bs.js Toast engine) ───── */
.toast {
    position: relative;
    width: 350px;
    max-width: 100%;
    font-size: 0.875rem;
    pointer-events: auto;
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.15s linear;
}
@media (prefers-reduced-motion: reduce) {
    .toast { transition: none; }
}
.toast.showing { opacity: 0.5; }
.toast.show:not(.hiding) { opacity: 1; }
.toast-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--ci-text);
    border-bottom: 1px solid var(--ci-border);
}
.toast-header .btn-close { margin-left: auto; }
.toast-body {
    padding: 0.75rem;
    color: var(--ci-text);
    word-wrap: break-word;
}
.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
/* Type tints (offline-manager showNotification) — token-based, both modes.
   Tinted surface + full-perimeter border (no one-side accent bars). */
.toast.ci-toast--success {
    background: color-mix(in srgb, var(--ci-success) 10%, var(--ci-surface-raised));
    border-color: color-mix(in srgb, var(--ci-success) 35%, var(--ci-border));
}
.toast.ci-toast--warning {
    background: color-mix(in srgb, var(--ci-warning) 12%, var(--ci-surface-raised));
    border-color: color-mix(in srgb, var(--ci-warning) 38%, var(--ci-border));
}
.toast.ci-toast--error,
.toast.ci-toast--danger {
    background: color-mix(in srgb, var(--ci-danger) 10%, var(--ci-surface-raised));
    border-color: color-mix(in srgb, var(--ci-danger) 35%, var(--ci-border));
}
.toast.ci-toast--info {
    background: color-mix(in srgb, var(--ci-info) 10%, var(--ci-surface-raised));
    border-color: color-mix(in srgb, var(--ci-info) 35%, var(--ci-border));
}

/* ==========================================================================
   Audit quick entry (modules/audits/edit.php + assets/js/ci-audit-quick.js)
   --------------------------------------------------------------------------
   One-tap status buttons mirror the compliance <select>; the same controls
   render on desktop and phones. Answered cards collapse on phones only —
   desktop keeps the full table. Colours stay on var(--ci-*) tokens so dark
   mode and the theme system restyle everything.
   ========================================================================== */

/* The quick buttons are the only visible control; the native select stays in
   the DOM (1px, focusable programmatically) as the single data carrier for
   autosave, rating, finding-type enabling and form submission. Same pattern
   as input[type="file"].ci-file-native — never display:none. */
.ci-quick-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 1px !important;  /* beats the stacked-card 44px control rule */
    min-height: 1px !important;
    max-width: 1px !important;
    max-height: 1px !important;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ci-quick-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.85rem;
}
.ci-quick-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.ci-quick-toolbar-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ci-text-muted);
}
.ci-quick-toolbar .ci-btn { min-height: 40px; }

/* Bulk buttons carry their status colour, matching the quick row below. */
.ci-quick-toolbar [data-bulk-status="conformity"] {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-success) 45%, transparent);
}
.ci-quick-toolbar [data-bulk-status="conformity"]:hover,
.ci-quick-toolbar [data-bulk-status="conformity"]:active {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 14%, var(--ci-surface-raised));
    border-color: var(--ci-success);
}
.ci-quick-toolbar [data-bulk-status="observation"] {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-info) 45%, transparent);
}
.ci-quick-toolbar [data-bulk-status="observation"]:hover,
.ci-quick-toolbar [data-bulk-status="observation"]:active {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 14%, var(--ci-surface-raised));
    border-color: var(--ci-info);
}
.ci-quick-toolbar [data-bulk-status="not_applicable"] {
    color: var(--ci-text-muted);
    border-color: var(--ci-border);
}
.ci-quick-toolbar [data-bulk-status="not_applicable"]:hover,
.ci-quick-toolbar [data-bulk-status="not_applicable"]:active {
    color: var(--ci-text);
    background: var(--ci-surface-hover);
    border-color: var(--ci-gray-500);
}

/* Per-item one-tap row (above the compliance select). Two columns at every
   width: four labels stay a 2×2 block inside the narrow Compliance column. */
.ci-quick-status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}
/* Desktop: borrow part of the cell's 20px side padding so "Observation" fits
   a 2-up track at a readable size. Phones keep the card padding untouched. */
@media (min-width: 768px) {
    .ci-quick-status { margin-left: -0.35rem; margin-right: -0.35rem; }
}
.ci-quick-status button,
.ci-quick-nc button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 40px;
    padding: 0.3rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.1;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-sm);
    background: var(--ci-surface-raised);
    color: var(--ci-text);
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.ci-quick-status button:hover,
.ci-quick-nc button:hover { background: var(--ci-surface-hover); }

/* Checklist quick responses (ci-checklist-quick.js) reuse the row with
   arbitrary option values (ratings 1–5, choice text), which have no
   status-specific palette of their own. One neutral brand-tinted pressed
   state covers them; the audit rows below keep their severity colours. */
.ci-quick-status button.is-active {
    background: color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 16%, var(--ci-surface-raised));
    border-color: var(--theme-primary, var(--ci-brand-primary));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-primary, var(--ci-brand-primary)) 18%, transparent);
}

.ci-quick-status button:focus-visible,
.ci-quick-nc button:focus-visible,
.ci-item-toggle:focus-visible {
    outline: 2px solid var(--theme-primary, var(--ci-brand-primary));
    outline-offset: 2px;
}

.ci-quick-status button[data-status="conformity"] {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-success) 45%, transparent);
}
.ci-quick-status button[data-status="conformity"].is-active {
    background: color-mix(in srgb, var(--ci-success) 22%, var(--ci-surface-raised));
    border-color: var(--ci-success);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-success) 22%, transparent);
}
.ci-quick-status button[data-status="observation"] {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-info) 45%, transparent);
}
.ci-quick-status button[data-status="observation"].is-active {
    background: color-mix(in srgb, var(--ci-info) 22%, var(--ci-surface-raised));
    border-color: var(--ci-info);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-info) 22%, transparent);
}
.ci-quick-status button[data-status="not_applicable"] {
    color: var(--ci-text-muted);
}
.ci-quick-status button[data-status="not_applicable"].is-active {
    background: color-mix(in srgb, var(--ci-gray-500) 18%, var(--ci-surface-raised));
    border-color: var(--ci-gray-500);
    color: var(--ci-text);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-gray-500) 22%, transparent);
}
.ci-quick-status button[data-status="nc"] {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-danger) 45%, transparent);
}
.ci-quick-status button[data-status="nc"].is-active {
    background: color-mix(in srgb, var(--ci-danger) 18%, var(--ci-surface-raised));
    border-color: var(--ci-danger);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-danger) 20%, transparent);
}

/* NC severity row — revealed by the NC button, hidden by [hidden]. */
.ci-quick-nc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}
.ci-quick-nc[hidden] { display: none; }
.ci-quick-nc button[data-status="minor_non_conformity"] {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-warning) 50%, transparent);
}
.ci-quick-nc button[data-status="minor_non_conformity"].is-active {
    background: color-mix(in srgb, var(--ci-warning) 24%, var(--ci-surface-raised));
    border-color: var(--ci-warning);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-warning) 22%, transparent);
}
.ci-quick-nc button[data-status="major_non_conformity"] {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-danger) 45%, transparent);
}
.ci-quick-nc button[data-status="major_non_conformity"].is-active {
    background: color-mix(in srgb, var(--ci-danger) 20%, var(--ci-surface-raised));
    border-color: var(--ci-danger);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-danger) 20%, transparent);
}
.ci-quick-nc button[data-status="critical_non_conformity"] {
    color: color-mix(in srgb, var(--ci-danger) 80%, var(--ci-text));
    border-color: color-mix(in srgb, var(--ci-danger) 60%, transparent);
}
.ci-quick-nc button[data-status="critical_non_conformity"].is-active {
    background: color-mix(in srgb, var(--ci-danger) 32%, var(--ci-surface-raised));
    border-color: var(--ci-danger);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ci-danger) 28%, transparent);
}

/* Status chip in the checkpoint cell (filled by JS; hidden until then). */
.ci-item-status {
    display: inline-block;
    margin-left: 0.45rem;
    padding: 0.14em 0.55em;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
    border: 1px solid var(--ci-border);
    border-radius: 999px;
    color: var(--ci-text-muted);
    background: var(--ci-surface-hover);
}
.ci-item-status:empty { display: none; }
.ci-item-status--conformity {
    color: color-mix(in srgb, var(--ci-success) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-success) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-success) 40%, transparent);
}
.ci-item-status--observation {
    color: color-mix(in srgb, var(--ci-info) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-info) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-info) 40%, transparent);
}
.ci-item-status--minor-nc {
    color: color-mix(in srgb, var(--ci-warning) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-warning) 14%, transparent);
    border-color: color-mix(in srgb, var(--ci-warning) 45%, transparent);
}
.ci-item-status--major-nc {
    color: color-mix(in srgb, var(--ci-danger) 70%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 12%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 40%, transparent);
}
.ci-item-status--critical-nc {
    color: color-mix(in srgb, var(--ci-danger) 80%, var(--ci-text));
    background: color-mix(in srgb, var(--ci-danger) 22%, transparent);
    border-color: color-mix(in srgb, var(--ci-danger) 55%, transparent);
}
.ci-item-status--na {
    color: var(--ci-text-muted);
    background: color-mix(in srgb, var(--ci-gray-500) 12%, transparent);
    border-color: var(--ci-border);
}

/* Details toggle: phone-only (desktop keeps every cell visible). */
.ci-item-toggle {
    display: none;
    margin-top: 0.45rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-sm);
    background: var(--ci-surface-raised);
    color: var(--ci-text);
    cursor: pointer;
}

/* Submit validation message (created by ci-audit-quick.js). Fixed so it stays
   visible while the flagged row is scrolled into view; on phones it clears the
   sticky action bar + bottom navigation. */
.ci-quick-alert {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    z-index: 1300;
    max-width: min(92vw, 460px);
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: var(--ci-text);
    background: color-mix(in srgb, var(--ci-danger) 12%, var(--ci-surface-raised));
    border: 1px solid color-mix(in srgb, var(--ci-danger) 45%, transparent);
    border-radius: var(--ci-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.ci-quick-alert[hidden] { display: none; }

@media (max-width: 767.98px) {
    .ci-quick-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .ci-quick-toolbar .ci-btn { min-height: 44px; }

    .ci-quick-status button { min-height: 44px; font-size: 0.8rem; }
    .ci-quick-nc button { flex: 1 1 auto; min-height: 44px; font-size: 0.8rem; }

    .ci-item-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
    }

    /* Clear the sticky save bar + phone bottom navigation. */
    .ci-quick-alert { bottom: 150px; }

    /* Collapse only hides the optional fields — item #, checkpoint, type,
       rating, compliance and the quick row stay visible. */
    tr.is-collapsed .item-detail { display: none; }

    /* Checklist cards (execute.php): the response control, remarks and photos
       collapse; the item text, summary chip and Details toggle stay. */
    [data-checklist-item].is-collapsed .checklist-item-detail { display: none; }
}

/* ==========================================================================
   Continue where you left off (audits list) — one column on phones,
   three-up on desktop; surface/border/radius resolve through ci tokens.
   ========================================================================== */
.ci-resume-section { margin-bottom: 1.5rem; }
.ci-resume-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ci-text);
}
.ci-resume-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}
.ci-resume-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
    padding: 1rem 1.1rem;
    background: var(--ci-surface-raised);
    border: 1px solid var(--ci-border);
    border-radius: var(--ci-radius-lg);
}
.ci-resume-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.ci-resume-card-name {
    font-weight: 600;
    color: var(--ci-text);
    overflow-wrap: anywhere;
}
.ci-resume-card-code {
    font-size: 0.8rem;
    color: var(--ci-text-muted);
}
.ci-resume-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    font-size: 0.85rem;
    color: var(--ci-text-muted);
}
.ci-resume-card-meta > span { white-space: nowrap; }
.ci-resume-card-actions { margin-top: auto; }

@media (min-width: 1024px) {
    .ci-resume-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .ci-resume-card .ci-btn {
        width: 100%;
        min-height: 44px;
    }
}

/* "Use last audit's setup" (create audit) — phone-sized tap target; the
   button is only rendered visible when a previous audit of the type exists. */
@media (max-width: 767.98px) {
    .ci-last-setup .ci-btn { min-height: 44px; }
}

/* ── Long <code> strings on phones ────────────────────────────────────────
   OAuth callback URLs, API base URLs and identifiers have no spaces, so a
   single <code> token could widen the page (settings/google.php,
   settings/microsoft.php, settings/api.php, settings/webhooks.php). Give
   them a break opportunity below md; desktop keeps the unbroken rendering. */
@media (max-width: 767.98px) {
    code { overflow-wrap: anywhere; }
}

/* ── Backup table snapshot (settings/backup.php) ──────────────────────────
   The table list is capped and scrolls internally on desktop, where the page
   is wide enough for a nested region; phones keep the natural page scroll. */
@media (min-width: 768px) {
    .ci-backup-table-scroll {
        max-height: 420px;
        overflow: auto;
    }
}

/* ── Appearance (settings/theme.php) ──────────────────────────────────────
   Light/Dark mode toggles are the page's primary controls on phones. */
@media (max-width: 767.98px) {
    #ciModeLight,
    #ciModeDark { min-height: 44px; }
}
