/*
 * Neo Elite UI — Bootstrap 5.3 theme
 *
 * Load after bootstrap.min.css. Pages keep using the standard Bootstrap
 * classes; this sheet only re-themes them (white / vivid cyan, light and dark).
 * The theme follows the `data-bs-theme` attribute set on <html>.
 *
 * Principles: frosted-glass surfaces over a fixed ambient cyan/blue backdrop,
 * translucent tints for semantic colours, hairline borders. Nested surfaces
 * are never blurred twice (readability and rendering cost).
 *
 * Sections
 *   1. Tokens (light, dark, shared)
 *   2. Base
 *   3. Bootstrap components
 *   4. Additions: .btn-ghost, .btn-icon, segmented control, app shell,
 *      stepper, timeline, avatar, empty state, entry page, calendar, dropzone,
 *      signature, chat, heatmap, charts, ID card
 *   5. Third-party libraries: Leaflet (+ markercluster), Select2,
 *      Flatpickr, Quill, SortableJS, driver.js (guided tours)
 */

/* 1. TOKENS
-------------------------------------------------- */
:root,
[data-bs-theme="light"] {
    color-scheme: light;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: 0.875rem;
    --bs-body-line-height: 1.5;

    --bs-body-color: #3f3f46;
    --bs-body-color-rgb: 63, 63, 70;
    --bs-body-bg: #ffffff;
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-emphasis-color: #09090b;
    --bs-emphasis-color-rgb: 9, 9, 11;
    --bs-heading-color: var(--bs-emphasis-color);
    --bs-secondary-color: #71717a;
    --bs-secondary-color-rgb: 113, 113, 122;
    --bs-secondary-bg: #f4f4f5;
    --bs-secondary-bg-rgb: 244, 244, 245;
    --bs-tertiary-color: #a1a1aa;
    --bs-tertiary-color-rgb: 161, 161, 170;
    --bs-tertiary-bg: #fafafa;
    --bs-tertiary-bg-rgb: 250, 250, 250;
    --bs-border-color: rgba(9, 9, 11, 0.08);
    --bs-border-color-translucent: rgba(9, 9, 11, 0.08);

    --bs-primary: #06b6d4;
    --bs-primary-rgb: 6, 182, 212;
    --bs-primary-text-emphasis: #0e7490;
    --bs-secondary: #71717a;
    --bs-secondary-rgb: 113, 113, 122;
    --bs-secondary-text-emphasis: #3f3f46;
    --bs-success: #15803d;
    --bs-success-rgb: 21, 128, 61;
    --bs-success-text-emphasis: #166534;
    --bs-info: #4f46e5;
    --bs-info-rgb: 79, 70, 229;
    --bs-info-text-emphasis: #4338ca;
    --bs-warning: #f59e0b;
    --bs-warning-rgb: 245, 158, 11;
    --bs-warning-text-emphasis: #b45309;
    --bs-danger: #dc2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-danger-text-emphasis: #b91c1c;
    --bs-light: #fafafa;
    --bs-light-rgb: 250, 250, 250;
    --bs-light-text-emphasis: #3f3f46;
    --bs-dark: #09090b;
    --bs-dark-rgb: 9, 9, 11;
    --bs-dark-text-emphasis: #09090b;

    --bs-link-color: #0e7490;
    --bs-link-color-rgb: 14, 116, 144;
    --bs-link-hover-color: #155e75;
    --bs-link-hover-color-rgb: 21, 94, 117;
    --bs-code-color: #0e7490;
    --bs-highlight-color: #09090b;
    --bs-highlight-bg: #fef3c7;

    --bs-form-valid-color: #15803d;
    --bs-form-valid-border-color: #16a34a;
    --bs-form-invalid-color: #dc2626;
    --bs-form-invalid-border-color: #ef4444;

    --bs-box-shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
    --bs-box-shadow: 0 12px 32px -8px rgba(9, 9, 11, 0.14), 0 2px 6px -2px rgba(9, 9, 11, 0.06);
    --bs-box-shadow-lg: 0 32px 64px -16px rgba(9, 9, 11, 0.28), 0 4px 12px -4px rgba(9, 9, 11, 0.08);
    --bs-box-shadow-inset: inset 0 1px 2px rgba(9, 9, 11, 0.06);

    /* Neo Elite additions */
    --ui-page-bg: #eef2f6;
    --ui-ambient-1: rgba(34, 211, 238, 0.42);
    --ui-ambient-2: rgba(59, 130, 246, 0.24);
    --ui-ambient-3: rgba(45, 212, 191, 0.26);
    --ui-glass-surface: rgba(255, 255, 255, 0.84);
    --ui-glass-chrome: rgba(255, 255, 255, 0.6);
    --ui-glass-bg: rgba(255, 255, 255, 0.8);
    --ui-glass-border: rgba(255, 255, 255, 0.75);
    --ui-glass-shadow: 0 0 0 1px rgba(9, 9, 11, 0.05), 0 10px 30px -16px rgba(8, 51, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    --ui-nav-active-bg: rgba(255, 255, 255, 0.8);
    --ui-surface-raised: #ffffff;
    --ui-input-bg: rgba(255, 255, 255, 0.5);
    --ui-input-bg-focus: rgba(255, 255, 255, 0.92);
    --ui-input-border: rgba(9, 9, 11, 0.12);
    --ui-scroll-thumb: rgba(63, 63, 70, 0.42);
    --ui-control-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --ui-control-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.05));
    --ui-hover: rgba(9, 9, 11, 0.04);
    --ui-active: rgba(9, 9, 11, 0.07);
    --ui-hover-mix: #000000;
    --ui-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    --ui-glow: 0 0 0 0 transparent;
    --ui-backdrop: rgba(15, 23, 42, 0.22);
    --ui-tint: 10%;
    --ui-tint-border: 20%;

    --ui-on-primary: #083344;
    --ui-on-secondary: #ffffff;
    --ui-on-success: #ffffff;
    --ui-on-info: #ffffff;
    --ui-on-warning: #1c1917;
    --ui-on-danger: #ffffff;
    --ui-on-light: #09090b;
    --ui-on-dark: #ffffff;

    /* Data viz: validated categorical order (all pairs, CVD-safe) and a
       single-hue sequential cyan ramp, lightest = lowest */
    --ui-chart-1: #0891b2;
    --ui-chart-2: #eb6834;
    --ui-chart-3: #4a3aa7;
    --ui-seq-1: #cffafe;
    --ui-seq-2: #67e8f9;
    --ui-seq-3: #06b6d4;
    --ui-seq-4: #0e7490;
    --ui-seq-5: #164e63;
    --ui-map-tiles-filter: saturate(0.65) contrast(1.02);

    /* Status marks (map pins, calendar, charts): validated for colour-vision
       deficiency in both modes; always paired with the status icon */
    --ui-status-done: #15803d;
    --ui-status-done-ink: #ffffff;
    --ui-status-progress: #0891b2;
    --ui-status-progress-ink: #ffffff;
    --ui-status-planned: #4f46e5;
    --ui-status-planned-ink: #ffffff;
    --ui-status-fix: #d4a017;
    --ui-status-fix-ink: #1c1407;
    --ui-status-cancel: #71717a;
    --ui-status-cancel-ink: #ffffff;

    /* Fiche tones: a categorical palette telling fiches (report types) apart. Validated
       (dataviz validate_palette.js) on the light surface: lightness band, chroma floor,
       CVD and normal-vision separation of neighbouring slots, >= 3:1 contrast. Eight hues
       cannot all be told apart pairwise: always shown beside the fiche code. */
    --ui-fiche-1: #2a78d6;
    --ui-fiche-2: #d4561f;
    --ui-fiche-3: #16936a;
    --ui-fiche-4: #b98000;
    --ui-fiche-5: #d6538a;
    --ui-fiche-6: #3f7f00;
    --ui-fiche-7: #6250d6;
    --ui-fiche-8: #c93a39;

    --ui-sidebar-width: 15.5rem;
    --ui-topbar-height: 3.5rem;
    --ui-shell-gap: 0.5rem;
}

[data-bs-theme="dark"] {
    color-scheme: dark;

    --bs-body-color: #edf2f6;
    --bs-body-color-rgb: 237, 242, 246;
    --bs-body-bg: #303740;
    --bs-body-bg-rgb: 48, 55, 64;
    --bs-emphasis-color: #f8fafc;
    --bs-emphasis-color-rgb: 248, 250, 252;
    --bs-secondary-color: #d4dde6;
    --bs-secondary-color-rgb: 212, 221, 230;
    --bs-secondary-bg: #3a424c;
    --bs-secondary-bg-rgb: 58, 66, 76;
    --bs-tertiary-color: #c1cbd5;
    --bs-tertiary-color-rgb: 193, 203, 213;
    --bs-tertiary-bg: #363e47;
    --bs-tertiary-bg-rgb: 54, 62, 71;
    --bs-border-color: #4d5863;
    --bs-border-color-translucent: #4d5863;

    --bs-primary: #22d3ee;
    --bs-primary-rgb: 34, 211, 238;
    --bs-primary-text-emphasis: #67e8f9;
    --bs-secondary: #a1a1aa;
    --bs-secondary-rgb: 161, 161, 170;
    --bs-secondary-text-emphasis: #e4e4e7;
    --bs-success: #4ade80;
    --bs-success-rgb: 74, 222, 128;
    --bs-success-text-emphasis: #86efac;
    --bs-info: #818cf8;
    --bs-info-rgb: 129, 140, 248;
    --bs-info-text-emphasis: #a5b4fc;
    --bs-warning: #fbbf24;
    --bs-warning-rgb: 251, 191, 36;
    --bs-warning-text-emphasis: #fcd34d;
    --bs-danger: #f87171;
    --bs-danger-rgb: 248, 113, 113;
    --bs-danger-text-emphasis: #fca5a5;
    --bs-light: #46515c;
    --bs-light-rgb: 70, 81, 92;
    --bs-light-text-emphasis: #e4e4e7;
    --bs-dark: #fafafa;
    --bs-dark-rgb: 250, 250, 250;
    --bs-dark-text-emphasis: #fafafa;

    --bs-link-color: #22d3ee;
    --bs-link-color-rgb: 34, 211, 238;
    --bs-link-hover-color: #67e8f9;
    --bs-link-hover-color-rgb: 103, 232, 249;
    --bs-code-color: #67e8f9;
    --bs-highlight-color: #fafafa;
    --bs-highlight-bg: #713f12;

    --bs-form-valid-color: #4ade80;
    --bs-form-valid-border-color: #4ade80;
    --bs-form-invalid-color: #f87171;
    --bs-form-invalid-border-color: #f87171;

    --bs-box-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.22);
    --bs-box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.38), 0 2px 6px -2px rgba(0, 0, 0, 0.24);
    --bs-box-shadow-lg: 0 32px 72px -16px rgba(0, 0, 0, 0.54);

    /* Dark surface hierarchy: canvas, chrome, content, then controls. */
    --ui-page-bg: #1c2025;
    --ui-ambient-1: rgba(34, 211, 238, 0.055);
    --ui-ambient-2: rgba(59, 130, 246, 0.04);
    --ui-ambient-3: rgba(45, 212, 191, 0.03);
    --ui-glass-surface: rgba(48, 55, 64, 0.98);
    --ui-glass-chrome: rgba(39, 45, 52, 0.97);
    --ui-glass-bg: rgba(56, 64, 74, 0.98);
    --ui-scroll-thumb: #75818d;
    --ui-glass-border: #52606d;
    --ui-glass-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 12px 32px -14px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --ui-nav-active-bg: #424c57;
    --ui-surface-raised: #404a55;
    --ui-input-bg: #3c4550;
    --ui-input-bg-focus: #46515d;
    --ui-input-border: #75818d;
    --ui-control-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --ui-control-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0));
    --ui-hover: rgba(255, 255, 255, 0.07);
    --ui-active: rgba(255, 255, 255, 0.12);
    --ui-hover-mix: #ffffff;
    --ui-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --ui-glow: 0 0 20px -4px rgba(34, 211, 238, 0.55);
    --ui-backdrop: rgba(0, 0, 0, 0.45);
    --ui-tint: 15%;
    --ui-tint-border: 30%;

    --ui-chart-1: #06a3c2;
    --ui-chart-2: #d95926;
    --ui-chart-3: #7c6ee0;
    --ui-seq-1: #10343d;
    --ui-seq-2: #0e5a6b;
    --ui-seq-3: #0891b2;
    --ui-seq-4: #22d3ee;
    --ui-seq-5: #a5f3fc;
    --ui-map-tiles-filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.45);

    --ui-status-done: #1f7f45;
    --ui-status-done-ink: #ffffff;
    --ui-status-progress: #06a3c2;
    --ui-status-progress-ink: #042f38;
    --ui-status-planned: #6366f1;
    --ui-status-planned-ink: #ffffff;
    --ui-status-fix: #b58900;
    --ui-status-fix-ink: #1c1407;
    --ui-status-cancel: #71717a;
    --ui-status-cancel-ink: #ffffff;

    /* Same hues stepped for the dark surface (#303740), validated as a set. */
    --ui-fiche-1: #4d8fe6;
    --ui-fiche-2: #e0682f;
    --ui-fiche-3: #1fa775;
    --ui-fiche-4: #be8700;
    --ui-fiche-5: #e0638f;
    --ui-fiche-6: #3f9a1a;
    --ui-fiche-7: #8f84ea;
    --ui-fiche-8: #e65c5c;

    --ui-on-primary: #083344;
    --ui-on-secondary: #09090b;
    --ui-on-success: #052e16;
    --ui-on-info: #1e1b4b;
    --ui-on-warning: #1c1407;
    --ui-on-danger: #2b0707;
    --ui-on-light: #fafafa;
    --ui-on-dark: #09090b;
}

/* Shared: translucent tints derived from the tones above */
:root,
[data-bs-theme] {
    --bs-primary-bg-subtle: color-mix(in srgb, var(--bs-primary) var(--ui-tint), transparent);
    --bs-primary-border-subtle: color-mix(in srgb, var(--bs-primary) var(--ui-tint-border), transparent);
    --bs-secondary-bg-subtle: color-mix(in srgb, var(--bs-secondary) var(--ui-tint), transparent);
    --bs-secondary-border-subtle: color-mix(in srgb, var(--bs-secondary) var(--ui-tint-border), transparent);
    --bs-success-bg-subtle: color-mix(in srgb, var(--bs-success) var(--ui-tint), transparent);
    --bs-success-border-subtle: color-mix(in srgb, var(--bs-success) var(--ui-tint-border), transparent);
    --bs-info-bg-subtle: color-mix(in srgb, var(--bs-info) var(--ui-tint), transparent);
    --bs-info-border-subtle: color-mix(in srgb, var(--bs-info) var(--ui-tint-border), transparent);
    --bs-warning-bg-subtle: color-mix(in srgb, var(--bs-warning) var(--ui-tint), transparent);
    --bs-warning-border-subtle: color-mix(in srgb, var(--bs-warning) var(--ui-tint-border), transparent);
    --bs-danger-bg-subtle: color-mix(in srgb, var(--bs-danger) var(--ui-tint), transparent);
    --bs-danger-border-subtle: color-mix(in srgb, var(--bs-danger) var(--ui-tint-border), transparent);
    --bs-light-bg-subtle: var(--ui-hover);
    --bs-light-border-subtle: var(--bs-border-color);
    --bs-dark-bg-subtle: var(--ui-active);
    --bs-dark-border-subtle: var(--ui-input-border);

    /* Radius scale: sm = items inside containers, default = every control
       (all sizes), lg = every container, xl = modals and side panels */
    --bs-border-radius-sm: 0.375rem;
    --bs-border-radius: 0.5rem;
    --bs-border-radius-lg: 0.75rem;
    --bs-border-radius-xl: 1rem;
    --bs-border-radius-xxl: 1.25rem;
    --bs-border-radius-2xl: 1.25rem;
    --bs-border-radius-pill: 50rem;

    --bs-focus-ring-width: 3px;
    --bs-focus-ring-opacity: 0.25;
    --bs-focus-ring-color: rgba(var(--bs-primary-rgb), 0.3);

    --ui-focus-border: var(--bs-primary);
    --ui-focus-ring: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.28);
    --ui-glass-filter: saturate(150%) blur(16px);

    --ui-check-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23083344' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
    --ui-indeterminate-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23083344' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e");
    --ui-radio-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23083344'/%3e%3c/svg%3e");
    --ui-switch-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    --ui-chevron-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M3 6l5 5 5-5'/%3e%3c/svg%3e");
    --ui-chevron-mask: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M3 6l5 5 5-5'/%3e%3c/svg%3e");
}

/* 2. BASE
-------------------------------------------------- */
body {
    background-color: var(--ui-page-bg);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fixed ambient backdrop seen (blurred) through every glass surface */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    transform: translateZ(0);
    background:
        radial-gradient(42rem 32rem at 8% -5%, var(--ui-ambient-1), transparent 62%),
        radial-gradient(38rem 30rem at 95% 8%, var(--ui-ambient-2), transparent 62%),
        radial-gradient(44rem 34rem at 55% 105%, var(--ui-ambient-3), transparent 62%),
        var(--ui-page-bg);
    pointer-events: none;
}

::selection {
    background-color: rgba(var(--bs-primary-rgb), 0.25);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

h1, .h1 { font-size: 1.75rem; letter-spacing: -0.03em; }
h2, .h2 { font-size: 1.375rem; }
h3, .h3 { font-size: 1.125rem; }
h4, .h4 { font-size: 1rem; }
h5, .h5 { font-size: 0.9375rem; letter-spacing: -0.01em; }
h6, .h6 { font-size: 0.875rem; letter-spacing: -0.01em; }

.lead {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--bs-secondary-color);
}

a {
    text-decoration: none;
    text-underline-offset: 0.2em;
}

a:hover {
    text-decoration: underline;
}

/* Links inside running text are underlined: colour alone is not enough */
a:not([class]) {
    text-decoration: underline;
    text-decoration-color: rgba(var(--bs-link-color-rgb), 0.4);
}

a:not([class]):hover {
    text-decoration-color: currentColor;
}

code {
    padding: 0.125rem 0.375rem;
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--ui-active);
    font-size: 0.8125em;
}

kbd {
    padding: 0.0625rem 0.375rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--ui-hover);
    box-shadow: none;
    color: var(--bs-secondary-color);
    font-family: inherit;
    font-size: 0.75rem;
}

hr {
    border-color: var(--bs-border-color);
    opacity: 1;
}

.text-tabular {
    font-variant-numeric: tabular-nums;
}

/* Text typed on several lines (e.g. in the report builder) keeps its line breaks. Report form
   fields apply it to their hints only: field titles flow on one line, since most of them come
   from PDF imports whose line breaks only follow the original page layout. */
.ui-text-lines,
.rapport-field .form-text {
    white-space: pre-line;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--ui-input-border) transparent;
}

/* The enhanced thumb sits above a scrollport. Native scrolling stays active
   while its painted bar no longer changes content or neighboring widths. */
[data-ui-overlay-active] {
    scrollbar-width: none !important;
}

[data-ui-overlay-active]::-webkit-scrollbar {
    display: none;
}

/* Scrollport whose bar would only add noise (e.g. a planning grid scrolled with the
   wheel or trackpad): no native bar and no painted thumb, scrolling still works. */
[data-ui-scroll-hidden] {
    scrollbar-width: none !important;
}

[data-ui-scroll-hidden]::-webkit-scrollbar {
    display: none;
}

.ui-overlay-scroll-host-static {
    position: relative;
}

.ui-overlay-scroll-rail {
    position: absolute;
    z-index: 3;
    width: 10px;
    border-radius: 999px;
    opacity: 0.5;
    touch-action: none;
    transition: opacity 0.15s ease;
}

.ui-overlay-scroll-rail[hidden] {
    display: none;
}

.ui-overlay-scroll-host:hover > .ui-overlay-scroll-rail,
.ui-overlay-scroll-host:focus-within > .ui-overlay-scroll-rail,
.ui-overlay-scroll-rail:hover,
.ui-overlay-scroll-rail[data-dragging] {
    opacity: 1;
}

.ui-overlay-scroll-thumb {
    position: absolute;
    right: 2px;
    left: 2px;
    border-radius: 999px;
    background: var(--ui-scroll-thumb);
}

@media (prefers-reduced-motion: reduce) {
    .ui-overlay-scroll-rail {
        transition: none;
    }
}

/* 3. BOOTSTRAP COMPONENTS
-------------------------------------------------- */

/* Buttons */
.btn {
    --bs-btn-font-size: 0.875rem;
    --bs-btn-font-weight: 500;
    --bs-btn-padding-x: 0.875rem;
    --bs-btn-padding-y: 0.4375rem;
    --bs-btn-border-radius: var(--bs-border-radius);
    --bs-btn-focus-box-shadow: var(--ui-focus-ring);
    --bs-btn-disabled-opacity: 0.45;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    letter-spacing: -0.005em;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

.btn-sm,
.btn-group-sm > .btn {
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-padding-x: 0.625rem;
    --bs-btn-padding-y: 0.3125rem;
    --bs-btn-border-radius: var(--bs-border-radius);
    gap: 0.375rem;
}

.btn-lg,
.btn-group-lg > .btn {
    --bs-btn-font-size: 0.9375rem;
    --bs-btn-padding-x: 1.25rem;
    --bs-btn-padding-y: 0.625rem;
    --bs-btn-border-radius: var(--bs-border-radius);
}

/* Solid */
.btn-primary,
.btn-success,
.btn-info,
.btn-warning,
.btn-danger {
    --ui-btn-tone: var(--bs-primary);
    --ui-btn-on: var(--ui-on-primary);
    --bs-btn-color: var(--ui-btn-on);
    --bs-btn-bg: var(--ui-btn-tone);
    --bs-btn-border-color: var(--ui-btn-tone);
    --bs-btn-hover-color: var(--ui-btn-on);
    --bs-btn-hover-bg: color-mix(in srgb, var(--ui-btn-tone) 92%, var(--ui-hover-mix));
    --bs-btn-hover-border-color: var(--bs-btn-hover-bg);
    --bs-btn-active-color: var(--ui-btn-on);
    --bs-btn-active-bg: color-mix(in srgb, var(--ui-btn-tone) 85%, var(--ui-hover-mix));
    --bs-btn-active-border-color: var(--bs-btn-active-bg);
    --bs-btn-disabled-color: var(--ui-btn-on);
    --bs-btn-disabled-bg: var(--ui-btn-tone);
    --bs-btn-disabled-border-color: var(--bs-btn-border-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), var(--bs-box-shadow-sm);
}

.btn-primary:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), var(--bs-box-shadow-sm), var(--ui-glow);
}

.btn-success { --ui-btn-tone: var(--bs-success); --ui-btn-on: var(--ui-on-success); }
.btn-info { --ui-btn-tone: var(--bs-info); --ui-btn-on: var(--ui-on-info); }
.btn-warning { --ui-btn-tone: var(--bs-warning); --ui-btn-on: var(--ui-on-warning); }
.btn-danger { --ui-btn-tone: var(--bs-danger); --ui-btn-on: var(--ui-on-danger); }

/* Soft (outline-*): translucent tint */
.btn-outline-primary,
.btn-outline-success,
.btn-outline-info,
.btn-outline-warning,
.btn-outline-danger {
    --ui-btn-tone: var(--bs-primary);
    --ui-btn-on: var(--ui-on-primary);
    --ui-btn-text: var(--bs-primary-text-emphasis);
    --bs-btn-color: var(--ui-btn-text);
    --bs-btn-bg: color-mix(in srgb, var(--ui-btn-tone) 8%, transparent);
    --bs-btn-border-color: color-mix(in srgb, var(--ui-btn-tone) 22%, transparent);
    --bs-btn-hover-color: var(--ui-btn-text);
    --bs-btn-hover-bg: color-mix(in srgb, var(--ui-btn-tone) 15%, transparent);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--ui-btn-tone) 35%, transparent);
    --bs-btn-active-color: var(--ui-btn-on);
    --bs-btn-active-bg: var(--ui-btn-tone);
    --bs-btn-active-border-color: var(--ui-btn-tone);
    --bs-btn-disabled-color: var(--ui-btn-text);
    --bs-btn-disabled-bg: color-mix(in srgb, var(--ui-btn-tone) 8%, transparent);
    --bs-btn-disabled-border-color: transparent;
    background-image: var(--ui-control-sheen);
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm);
}

.btn-outline-success { --ui-btn-tone: var(--bs-success); --ui-btn-on: var(--ui-on-success); --ui-btn-text: var(--bs-success-text-emphasis); }
.btn-outline-info { --ui-btn-tone: var(--bs-info); --ui-btn-on: var(--ui-on-info); --ui-btn-text: var(--bs-info-text-emphasis); }
.btn-outline-warning { --ui-btn-tone: var(--bs-warning); --ui-btn-on: var(--ui-on-warning); --ui-btn-text: var(--bs-warning-text-emphasis); }
.btn-outline-danger { --ui-btn-tone: var(--bs-danger); --ui-btn-on: var(--ui-on-danger); --ui-btn-text: var(--bs-danger-text-emphasis); }

/* Neutral default button */
.btn-outline-secondary {
    --bs-btn-color: var(--bs-emphasis-color);
    --bs-btn-bg: var(--ui-input-bg);
    --bs-btn-border-color: var(--ui-input-border);
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-bg: var(--ui-input-bg-focus);
    --bs-btn-hover-border-color: var(--ui-input-border);
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: var(--ui-active);
    --bs-btn-active-border-color: var(--ui-input-border);
    --bs-btn-disabled-color: var(--bs-secondary-color);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: var(--bs-border-color);
    background-image: var(--ui-control-sheen);
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm);
}

.btn-secondary {
    --bs-btn-color: var(--bs-emphasis-color);
    --bs-btn-bg: var(--ui-active);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-bg: color-mix(in srgb, var(--bs-emphasis-color) 11%, transparent);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: color-mix(in srgb, var(--bs-emphasis-color) 15%, transparent);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--bs-secondary-color);
    --bs-btn-disabled-bg: var(--ui-hover);
    --bs-btn-disabled-border-color: transparent;
}

.btn-light {
    --bs-btn-color: var(--bs-emphasis-color);
    --bs-btn-bg: var(--ui-hover);
    --bs-btn-border-color: var(--bs-border-color);
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-bg: var(--ui-active);
    --bs-btn-hover-border-color: var(--bs-border-color);
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: var(--ui-active);
    --bs-btn-active-border-color: var(--ui-input-border);
}

.btn-dark {
    --bs-btn-color: var(--bs-body-bg);
    --bs-btn-bg: var(--bs-emphasis-color);
    --bs-btn-border-color: var(--bs-emphasis-color);
    --bs-btn-hover-color: var(--bs-body-bg);
    --bs-btn-hover-bg: color-mix(in srgb, var(--bs-emphasis-color) 85%, var(--bs-body-bg));
    --bs-btn-hover-border-color: var(--bs-btn-hover-bg);
    --bs-btn-active-color: var(--bs-body-bg);
    --bs-btn-active-bg: color-mix(in srgb, var(--bs-emphasis-color) 75%, var(--bs-body-bg));
    --bs-btn-active-border-color: var(--bs-btn-active-bg);
    box-shadow: var(--ui-highlight), var(--bs-box-shadow-sm);
}

.btn-link {
    --bs-btn-color: var(--bs-link-color);
    --bs-btn-hover-color: var(--bs-link-hover-color);
    --bs-btn-active-color: var(--bs-link-hover-color);
    --bs-btn-disabled-color: var(--bs-secondary-color);
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* A checked neutral toggle stays neutral: grey fill, no colour (pair it with a check mark) */
.btn-check:checked + .btn-outline-secondary,
.btn-check:active + .btn-outline-secondary {
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: var(--ui-active);
    --bs-btn-active-border-color: var(--ui-input-border);
    position: relative;
    z-index: 2;
}

.btn-group > .btn {
    box-shadow: none;
}

.btn-group {
    border-radius: var(--bs-border-radius);
}

.btn-close {
    --bs-btn-close-focus-shadow: var(--ui-focus-ring);
    --bs-btn-close-opacity: 0.45;
    --bs-btn-close-hover-opacity: 0.85;
    border-radius: var(--bs-border-radius-sm);
}

/* Forms */
.form-label,
.col-form-label {
    margin-bottom: 0.375rem;
    color: var(--bs-emphasis-color);
    font-size: 0.8125rem;
    font-weight: 500;
}

.form-text {
    margin-top: 0.375rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

/* Text area that starts as tall as an input and grows with its content (up to ~8 lines),
   so it lines up with the inputs of the same row: <textarea class="form-control ui-textarea-auto" rows="1">.
   Browsers without field-sizing keep the one-line height and scroll inside. */
.ui-textarea-auto {
    min-height: calc(1.5em + 0.875rem + calc(var(--bs-border-width) * 2));
    max-height: 12.5rem;
    resize: none;
    field-sizing: content;
}

.form-control,
.form-select {
    --ui-autofill-bg: var(--ui-input-bg);
    --ui-autofill-text: var(--bs-emphasis-color);
    --ui-autofill-shadow: 0 0 transparent;
    padding: 0.4375rem 0.75rem;
    border-color: var(--ui-input-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    color: var(--bs-emphasis-color);
    font-size: 0.875rem;
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm), var(--ui-autofill-shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* Browsers force their autofill background. Clip it to the text, then paint the
   field with its current theme fill, including translucent light-mode surfaces.
   Keep the inset fill separate so focus, validation and grouped-field shadows survive. */
.form-control:is(:autofill, :-webkit-autofill) {
    --ui-autofill-shadow: inset 0 0 0 1000px var(--ui-autofill-bg);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: var(--ui-autofill-text);
    caret-color: var(--ui-autofill-text);
}

.form-select {
    padding-right: 2.25rem;
    background-position: right 0.625rem center;
}

.form-select option {
    background-color: var(--ui-surface-raised);
}

.form-control::placeholder {
    color: var(--bs-tertiary-color);
}

.form-control:hover:not(:disabled):not(:focus):not(.is-valid):not(.is-invalid),
.form-select:hover:not(:disabled):not(:focus):not(.is-valid):not(.is-invalid) {
    border-color: color-mix(in srgb, var(--bs-emphasis-color) 22%, transparent);
}

.form-control:focus,
.form-select:focus {
    --ui-autofill-bg: var(--ui-input-bg-focus);
    border-color: var(--ui-focus-border);
    background-color: var(--ui-input-bg-focus);
    color: var(--bs-emphasis-color);
    box-shadow: var(--ui-focus-ring), var(--ui-autofill-shadow);
}

/* A date range field (Flatpickr range, x-neo.analytics-date-range) keeps room for both dates
   ("01/06/2026 au 30/06/2026") when it sits in a crowded row such as the topbar. */
[data-analytics-date-range] .form-control,
[data-kit-flatpickr="range"] {
    min-width: 13.5rem;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly]:not(.flatpickr-input) {
    --ui-autofill-bg: var(--ui-hover);
    --ui-autofill-text: var(--bs-secondary-color);
    background-color: var(--ui-hover);
    color: var(--bs-secondary-color);
    box-shadow: var(--ui-autofill-shadow);
}

.form-control-sm,
.form-select-sm {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    font-size: 0.8125rem;
    border-radius: var(--bs-border-radius);
}

.form-control-lg,
.form-select-lg {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    font-size: 0.9375rem;
    border-radius: var(--bs-border-radius);
}

.form-control::file-selector-button {
    padding: 0.4375rem 0.75rem;
    margin: -0.4375rem -0.75rem;
    margin-inline-end: 0.75rem;
    border-inline-end-color: var(--ui-input-border);
    background-color: var(--ui-hover);
    color: var(--bs-emphasis-color);
    font-weight: 500;
}

.form-control:hover:not(:disabled):not([readonly])::file-selector-button {
    background-color: var(--ui-active);
}

.form-control.is-valid:focus,
.was-validated .form-control:valid:focus,
.form-select.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(var(--bs-success-rgb), 0.2), var(--ui-autofill-shadow);
}

.form-control.is-invalid:focus,
.was-validated .form-control:invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(var(--bs-danger-rgb), 0.2), var(--ui-autofill-shadow);
}

.valid-feedback,
.invalid-feedback {
    margin-top: 0.375rem;
    font-size: 0.75rem;
}

.input-group {
    --ui-input-group-radius: var(--bs-border-radius);
    border-radius: var(--ui-input-group-radius);
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm);
}

.input-group-lg {
    --ui-input-group-radius: var(--bs-border-radius-lg);
}

.input-group > .form-control,
.input-group > .form-select,
.input-group > .btn {
    box-shadow: var(--ui-autofill-shadow, none);
}

.input-group-text {
    padding: 0.4375rem 0.75rem;
    border-color: var(--ui-input-border);
    background-color: var(--ui-input-bg);
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

.input-group:focus-within {
    box-shadow: var(--ui-focus-ring);
}

.input-group:focus-within > .form-control:focus,
.input-group:focus-within > .form-select:focus {
    box-shadow: var(--ui-autofill-shadow);
}

/* Fields follow the group's focus state, like the addon text: :focus can lag behind
   :focus-within (autofocus in a background window), which split the group in two tones */
.input-group:focus-within > .form-control:not(.is-valid):not(.is-invalid),
.input-group:focus-within > .form-select:not(.is-valid):not(.is-invalid) {
    --ui-autofill-bg: var(--ui-input-bg-focus);
    border-color: var(--ui-focus-border);
    background-color: var(--ui-input-bg-focus);
}

/* Leading icon sits inside the field. Reserve Bootstrap's shared-border overlap
   so the focused control cannot cover the icon's right edge. */
.input-group > .input-group-text:first-child:has(> .bi) {
    padding-right: var(--bs-border-width);
    border-right: 0;
}

/* Trailing hint (e.g. a <kbd> shortcut) sits inside the field too */
.input-group > .form-control + .input-group-text:last-child:has(> kbd) {
    padding-left: 0;
    border-left: 0;
}

.input-group > .form-control:has(+ .input-group-text:last-child > kbd) {
    border-right: 0;
}

.input-group:focus-within > .input-group-text {
    border-color: var(--ui-focus-border);
    background-color: var(--ui-input-bg-focus);
}

.input-group > .input-group-text:first-child:has(> .bi) + .form-control {
    border-left: 0;
}

.input-group-sm {
    border-radius: var(--bs-border-radius);
}

.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    font-size: 0.8125rem;
    border-radius: var(--bs-border-radius);
}

/* Only visible controls define the ends; loading indicators, feedback and
 * dropdown menus must not leave the exposed end of a field square. */
.input-group > :is(.form-control, .form-select, .input-group-text, .btn, .form-floating),
.input-group > .form-floating > :is(.form-control, .form-select) {
    border-radius: 0;
}

.input-group > :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):nth-child(1 of :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):not([hidden], [type="hidden"]):not([x-cloak], .d-none):not([style*="display: none"], [style*="display:none"])),
.input-group > .form-floating:nth-child(1 of :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):not([hidden], [type="hidden"]):not([x-cloak], .d-none):not([style*="display: none"], [style*="display:none"])) > :is(.form-control, .form-select) {
    border-top-left-radius: var(--ui-input-group-radius);
    border-bottom-left-radius: var(--ui-input-group-radius);
    margin-left: 0;
}

.input-group > :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):nth-last-child(1 of :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):not([hidden], [type="hidden"]):not([x-cloak], .d-none):not([style*="display: none"], [style*="display:none"])),
.input-group > .form-floating:nth-last-child(1 of :is(.form-control, .form-select, .input-group-text, .btn, .form-floating):not([hidden], [type="hidden"]):not([x-cloak], .d-none):not([style*="display: none"], [style*="display:none"])) > :is(.form-control, .form-select) {
    border-top-right-radius: var(--ui-input-group-radius);
    border-bottom-right-radius: var(--ui-input-group-radius);
}

/* Searchable picker (client-selects.js) in a group: its toggle joins the addon like a
   .form-select. --ui-picker-width sets the closed width, --ui-picker-menu-width the menu's. */
.input-group > [data-ui-client-picker] {
    position: relative;
    flex: 0 1 auto;
    width: var(--ui-picker-width, 14rem);
    min-width: 0;
    margin-left: calc(-1 * var(--bs-border-width));
}

.input-group > [data-ui-client-picker] > .form-select {
    width: 100%;
    border-radius: 0;
    box-shadow: var(--ui-autofill-shadow, none);
}

.input-group > [data-ui-client-picker]:last-child > .form-select {
    border-top-right-radius: var(--ui-input-group-radius);
    border-bottom-right-radius: var(--ui-input-group-radius);
}

.input-group-sm > [data-ui-client-picker] > .form-select {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    font-size: 0.8125rem;
}

.input-group:focus-within > [data-ui-client-picker] > .form-select {
    --ui-autofill-bg: var(--ui-input-bg-focus);
    border-color: var(--ui-focus-border);
    background-color: var(--ui-input-bg-focus);
}

/* Wider than its toggle, also once lifted to the top layer (sized to the toggle by ui.js). */
.input-group > [data-ui-client-picker] > .dropdown-menu {
    min-width: min(max(var(--ui-floating-width, 0px), var(--ui-picker-menu-width, 20rem)), calc(100vw - 1rem)) !important;
}

.form-check {
    min-height: 1.25rem;
}

.form-check-label {
    color: var(--bs-body-color);
}

.form-check-input {
    --bs-form-check-bg: var(--ui-input-bg);
    width: 1rem;
    height: 1rem;
    margin-top: 0.15em;
    border-color: color-mix(in srgb, var(--bs-emphasis-color) 22%, transparent);
    box-shadow: var(--bs-box-shadow-sm);
}

.form-check-input[type="checkbox"] {
    border-radius: var(--bs-border-radius-sm);
}

.form-check-input:focus {
    border-color: var(--ui-focus-border);
    box-shadow: var(--ui-focus-ring);
}

.form-check-input:checked {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
}

.form-check-input:checked[type="checkbox"] {
    --bs-form-check-bg-image: var(--ui-check-icon);
}

.form-check-input:checked[type="radio"] {
    --bs-form-check-bg-image: var(--ui-radio-icon);
}

.form-check-input[type="checkbox"]:indeterminate {
    --bs-form-check-bg-image: var(--ui-indeterminate-icon);
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
}

/* Switch: filled track, white knob */
.form-switch .form-check-input,
.form-switch .form-check-input:focus,
.form-switch .form-check-input:checked {
    --bs-form-switch-bg: var(--ui-switch-icon);
}

[data-bs-theme] .form-switch .form-check-input:not(:checked):not(:focus) {
    --bs-form-switch-bg: var(--ui-switch-icon);
}

.form-switch .form-check-input {
    border-color: transparent;
    background-color: color-mix(in srgb, var(--bs-emphasis-color) 18%, transparent);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.form-switch .form-check-input:checked {
    background-color: var(--bs-primary);
}

.form-switch .form-check-input:focus {
    box-shadow: var(--ui-focus-ring);
}

.form-range::-webkit-slider-runnable-track {
    height: 0.375rem;
    background-color: var(--ui-active);
}

.form-range::-webkit-slider-thumb {
    margin-top: -0.3125rem;
    background-color: var(--bs-primary);
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), 0.18);
}

.form-range::-moz-range-track {
    height: 0.375rem;
    background-color: var(--ui-active);
}

.form-range::-moz-range-thumb {
    background-color: var(--bs-primary);
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), 0.18);
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: var(--ui-focus-ring);
}

.form-range:focus::-moz-range-thumb {
    box-shadow: var(--ui-focus-ring);
}

/*
 * Content surfaces (cards, lists, accordions) are translucent but NOT blurred:
 * a live backdrop-filter on every card is recomputed while scrolling and makes
 * long pages lag. Blur is reserved for the few chrome and floating layers.
 */

/* Cards */
.card {
    --bs-card-bg: var(--ui-glass-surface);
    --bs-card-border-color: var(--ui-glass-border);
    --bs-card-border-radius: var(--bs-border-radius-lg);
    --bs-card-inner-border-radius: calc(var(--bs-border-radius-lg) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-padding-x: 1.25rem;
    --bs-card-cap-padding-y: 0.875rem;
    --bs-card-spacer-x: 1.25rem;
    --bs-card-spacer-y: 1.25rem;
    --bs-card-title-spacer-y: 0.375rem;
    --bs-card-subtitle-color: var(--bs-secondary-color);
    box-shadow: var(--ui-glass-shadow);
}

.card .card {
    --bs-card-bg: var(--ui-input-bg);
    --bs-card-border-color: var(--bs-border-color);
    box-shadow: none;
}

.card-header,
.card-footer {
    border-color: var(--bs-border-color);
}

.card-title {
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 0.8125rem;
    font-weight: 400;
}

.card-footer {
    background-color: color-mix(in srgb, var(--bs-emphasis-color) 2%, transparent);
}

/* Containing block for absolutely positioned cell content (.visually-hidden labels):
   without it they escape the horizontal scroll and widen the page scrollport. */
.table-responsive {
    position: relative;
}

.card > .table,
.card > .table-responsive > .table {
    margin-bottom: 0;
}

.card > .table > :not(caption) > * > :first-child,
.card > .table-responsive > .table > :not(caption) > * > :first-child {
    padding-left: var(--bs-card-spacer-x);
}

.card > .table > :not(caption) > * > :last-child,
.card > .table-responsive > .table > :not(caption) > * > :last-child {
    padding-right: var(--bs-card-spacer-x);
}

.card > .table > :last-child > tr:last-child > *,
.card > .table-responsive > .table > :last-child > tr:last-child > * {
    border-bottom-width: 0;
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--bs-body-color);
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-striped-bg: color-mix(in srgb, var(--bs-emphasis-color) 2.5%, transparent);
    --bs-table-hover-bg: var(--ui-hover);
    --bs-table-hover-color: var(--bs-body-color);
    --bs-table-active-bg: color-mix(in srgb, var(--bs-primary) 7%, transparent);
    --bs-table-active-color: var(--bs-body-color);
    font-size: 0.875rem;
}

.table > :not(caption) > * > * {
    padding: 0.75rem;
}

.table-sm > :not(caption) > * > * {
    padding: 0.5rem 0.625rem;
}

/* Wide data table read on a phone: each row becomes a record card, one field per line with
   its column name above the value. Cells carry their column name in data-label.
   <table class="table ui-table-stack">…<td data-label="Ville">Paris</td>… */
@media (max-width: 575.98px) {
    .ui-table-stack,
    .ui-table-stack > tbody,
    .ui-table-stack > tbody > tr,
    .ui-table-stack > tbody > tr > td {
        display: block;
        width: 100%;
    }

    .ui-table-stack > thead {
        display: none;
    }

    .ui-table-stack.text-nowrap,
    .ui-table-stack > tbody > tr > td {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .ui-table-stack > tbody > tr {
        padding: 0.5rem var(--bs-card-spacer-x, 1rem);
    }

    /* Separator above each following record: a hidden trailing row (empty state) adds none */
    .ui-table-stack > tbody > tr ~ tr {
        border-top: 0.375rem solid color-mix(in srgb, var(--bs-emphasis-color) 7%, transparent);
    }

    /* Beats the card table edge paddings and the last row's border reset (.card > .table…) */
    .ui-table-stack.table > tbody > tr > td:nth-child(n),
    .card > .table-responsive > .ui-table-stack.table > tbody > tr > td:nth-child(n) {
        padding: 0.375rem 0;
        border-bottom: 1px solid var(--bs-border-color);
    }

    .ui-table-stack.table > tbody > tr > td:last-child:nth-child(n),
    .card > .table-responsive > .ui-table-stack.table > tbody > tr > td:last-child:nth-child(n) {
        border-bottom: 0;
    }

    .ui-table-stack > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.125rem;
        color: var(--bs-secondary-color);
        font-size: 0.75rem;
        font-weight: 500;
    }
}

/* Bootstrap's .table-light keeps a white fill and black text in dark mode: follow the theme */
[data-bs-theme="dark"] .table-light {
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: var(--bs-tertiary-bg);
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-striped-bg: var(--bs-tertiary-bg);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-active-bg: var(--bs-secondary-bg);
    --bs-table-active-color: var(--bs-body-color);
    --bs-table-hover-bg: var(--bs-secondary-bg);
    --bs-table-hover-color: var(--bs-body-color);
    color: var(--bs-table-color);
    border-color: var(--bs-table-border-color);
}

.ui-row-clickable {
    cursor: pointer;
}

.table > thead {
    vertical-align: middle;
}

.table > thead > tr > th {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.table > thead > tr > th a,
.table > thead > tr > th .btn-link {
    color: inherit;
    font: inherit;
    text-decoration: none;
}

.table > thead > tr > th .btn-link {
    --bs-btn-padding-x: 0;
    --bs-btn-padding-y: 0;
    gap: 0.25rem;
}

.table > thead > tr > th a:hover,
.table > thead > tr > th .btn-link:hover,
.table > thead > tr > th[aria-sort] {
    color: var(--bs-emphasis-color);
}

/* Header row kept visible while the rows scroll inside their container (e.g. an
   .overflow-auto .table-responsive); the header is painted with the card surface. */
.ui-table-sticky-head > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(var(--bs-card-bg, var(--ui-surface-raised)), var(--bs-card-bg, var(--ui-surface-raised))) var(--bs-body-bg);
}

/* Column header written vertically (read bottom to top) so many narrow columns fit side
   by side, e.g. one column per person in a matrix. Long labels are cut; keep the full
   text in a title: <th class="ui-th-vertical" title="Name"><span>Name</span></th> */
.table > thead > tr > th.ui-th-vertical {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    vertical-align: bottom;
}

.ui-th-vertical > span {
    display: inline-block;
    max-height: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* Grouped table: one collapsible summary row per group ([data-ui-group-toggle]), its rows
   hidden until opened. Group heads and their rows stay neutral (grey head, plain rows, a
   stronger rule closing the group): colour is kept for the row priority edge and the status
   badges, so it always means something. Rows without a group stay plain rows. */
.ui-table-group-row {
    --bs-table-bg: var(--bs-tertiary-bg);
}

/* The columns of an Excel file listed one per row: the column letter as row head
   (<th scope="row">), then its cells side by side, under a sticky header.
   A row edited and not saved yet carries .is-changed (with a written state, not colour alone). */
.ui-sheet {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.ui-sheet th,
.ui-sheet td {
    padding: 0.5rem 0.625rem;
    border-bottom: var(--bs-border-width) solid var(--bs-border-color);
    vertical-align: top;
    background: var(--bs-card-bg, var(--ui-surface-raised));
}

.ui-sheet > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-block: 0.375rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.ui-sheet th[scope="row"] {
    width: 3rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-emphasis-color);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Cells and section rows filled with the colour of the Excel header (--ui-sheet-fill),
   black text as in the file; the section label says what the colour means. */
.ui-sheet td.ui-sheet-fill,
.ui-sheet tr.is-changed > td.ui-sheet-fill,
.ui-sheet tr.ui-sheet-section > th {
    background: var(--ui-sheet-fill);
    color: #000;
}

.ui-sheet td.ui-sheet-fill {
    text-align: center;
    border-bottom-color: rgba(0, 0, 0, 0.25);
}

.ui-sheet tr.ui-sheet-section > th {
    padding-block: 0.375rem;
    font-weight: 600;
    border-bottom-color: rgba(0, 0, 0, 0.35);
}

.ui-sheet tr.is-changed > td {
    background: color-mix(in srgb, var(--bs-primary) 8%, var(--bs-card-bg, var(--ui-surface-raised)));
}

/* Long headers are cut after a few lines; the full text stays in a title */
.ui-sheet-clamp {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow-wrap: anywhere;
}

.ui-table-group-item.is-last > * {
    border-bottom-color: var(--bs-border-color);
    border-bottom-width: 2px;
}

.ui-table-group-item > :nth-child(2) {
    padding-left: 1.75rem;
}

/* Detail row: one line of secondary facts under the whole row it belongs to; the pair reads,
   hovers and clicks as a single row.
   <tr class="ui-row-has-detail">…</tr><tr class="ui-row-detail"><td></td><td colspan="…">…</td></tr> */
.table > tbody > .ui-row-has-detail > * {
    border-bottom-width: 0;
}

.table > tbody > .ui-row-detail > * {
    padding-top: 0;
}

.table-hover > tbody > .ui-row-has-detail:has(+ .ui-row-detail:hover) > *,
.table-hover > tbody > .ui-row-has-detail:hover + .ui-row-detail > * {
    --bs-table-color-state: var(--bs-table-hover-color);
    --bs-table-bg-state: var(--bs-table-hover-bg);
}

/* Priority rows: a coloured edge on the row, always paired with a worded badge in the row
   (e.g. "Urgent") so the urgency never relies on colour alone.
   <tr class="ui-row-urgent">…<span class="badge bg-danger"><i class="bi bi-exclamation-triangle-fill"></i>Urgent · statut</span>…</tr> */
.ui-row-urgent { --ui-row-edge: var(--bs-danger); --bs-table-bg: color-mix(in srgb, var(--bs-danger) 5%, var(--bs-body-bg)); }
.ui-row-attention { --ui-row-edge: var(--bs-warning); }

.ui-row-urgent > :first-child,
.ui-row-attention > :first-child {
    position: relative;
}

.ui-row-urgent > :first-child::before,
.ui-row-attention > :first-child::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background-color: var(--ui-row-edge);
}

/* Arrival highlight: the element the user was just taken to (e.g. "next changed field") lights up
   for a moment, then fades. Set with NeoUi.flash(element); a still outline replaces the fade when
   reduced motion is requested. */
@keyframes ui-flash {
    from {
        background-color: var(--bs-highlight-bg);
        box-shadow: 0 0 0 0.5rem var(--bs-highlight-bg);
    }

    to {
        background-color: transparent;
        box-shadow: 0 0 0 0.5rem transparent;
    }
}

.ui-flash {
    border-radius: var(--bs-border-radius);
    animation: ui-flash 2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .ui-flash {
        animation: none;
        outline: 2px solid var(--bs-warning);
        outline-offset: 0.375rem;
    }
}

/* Secondary action of an item (e.g. a field's history) shown when the item is hovered or holds
   the keyboard focus. Mouse devices only: always visible on touch screens. Opacity (not
   visibility) keeps the action in the tab order.
   <div class="ui-hover-host">…<button class="btn btn-ghost btn-icon ui-hover-reveal">…</button></div> */
@media (hover: hover) {
    .ui-hover-host:not(:hover, :focus-within, :has(.dropdown-menu.show)) .ui-hover-reveal {
        opacity: 0;
    }
}

/* A resting label (time, age badge) and the action that takes its place on hover or focus, as in
   T3 Code's thread rows. Touch screens show both side by side. With .ui-hover-swap-keep the label
   stays (e.g. a signal the user can dismiss) and the action appears beside it.
   <span class="ui-hover-swap"><span class="badge">…</span><button class="btn … ui-hover-reveal">…</button></span> */
.ui-hover-swap {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
}

.ui-result-head > .ui-hover-swap {
    margin-left: auto;
}

@media (hover: hover) {
    .ui-hover-swap:not(.ui-hover-swap-keep) {
        display: inline-grid;
        justify-items: end;
    }

    .ui-hover-swap:not(.ui-hover-swap-keep) > * {
        grid-area: 1 / 1;
    }

    .ui-hover-host:is(:hover, :focus-within, :has(.dropdown-menu.show)) .ui-hover-swap:not(.ui-hover-swap-keep) > :not(.ui-hover-reveal, :has(.ui-hover-reveal)) {
        visibility: hidden;
    }

    .ui-hover-host:not(:hover, :focus-within, :has(.dropdown-menu.show)) .ui-hover-swap-keep > :is(.ui-hover-reveal, :has(.ui-hover-reveal)) {
        display: none;
    }
}

/* Same for an action carrying a display utility (the snooze menu wrapper is .d-inline-block). */
@media (hover: hover) {
    .ui-hover-host:not(:hover, :focus-within, :has(.dropdown-menu.show)) .ui-hover-swap-keep > .ui-hover-reveal[class*="d-inline"] {
        display: none !important;
    }
}

/* Collapsible shelf at the bottom of a list card (e.g. snoozed items): it keeps its size and the
   card's main list scrolls above it; once open, its own list scrolls past a few rows.
   <div class="card-footer p-0 ui-card-shelf"><button class="ui-group-toggle w-100 px-3 py-2">…</button><div class="list-group list-group-flush overflow-auto border-top">…</div></div> */
.ui-card-shelf {
    display: flex;
    flex: none;
    flex-direction: column;
}

.ui-card-shelf > .list-group {
    max-height: min(40vh, 22rem);
}

.ui-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bs-emphasis-color);
    font-weight: 600;
    text-align: start;
}

.ui-group-toggle > .bi-chevron-right {
    transition: transform 0.15s ease;
}

.ui-group-toggle[aria-expanded="true"] > .bi-chevron-right {
    transform: rotate(90deg);
}

/* Sub-groups of an open group: indented behind a rule so each level reads as part of its parent.
   <div class="ui-group-children">…nested group heads and rows…</div> */
.ui-group-children {
    margin-left: 1.25rem;
    border-left: 2px solid var(--bs-border-color);
}

@media (prefers-reduced-motion: reduce) {
    .ui-group-toggle > .bi-chevron-right {
        transition: none;
    }
}

/* Badges: pills with translucent tints */
.badge {
    --bs-badge-font-size: 0.75rem;
    --bs-badge-font-weight: 500;
    --bs-badge-padding-x: 0.5625rem;
    --bs-badge-padding-y: 0.25rem;
    --bs-badge-border-radius: var(--bs-border-radius-pill);
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    line-height: 1.15;
    vertical-align: 0.05em;
}

.badge.rounded-pill {
    --bs-badge-padding-x: 0.5rem;
}

/* Thin ring in the badge's own colour keeps tints legible on glass */
.badge[class*="-subtle"] {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
}

.badge.bg-primary, .text-bg-primary { color: var(--ui-on-primary) !important; }
.badge.bg-secondary, .text-bg-secondary { color: var(--ui-on-secondary) !important; }
.badge.bg-success, .text-bg-success { color: var(--ui-on-success) !important; }
.badge.bg-info, .text-bg-info { color: var(--ui-on-info) !important; }
.badge.bg-warning, .text-bg-warning { color: var(--ui-on-warning) !important; }
.badge.bg-danger, .text-bg-danger { color: var(--ui-on-danger) !important; }
.badge.bg-light, .text-bg-light { color: var(--ui-on-light) !important; }
.badge.bg-dark, .text-bg-dark { color: var(--ui-on-dark) !important; }

.btn .badge {
    top: 0;
}

/* Removable chip: <span class="badge …">Label <button class="btn-close"></button></span> */
.badge > .btn-close {
    margin-left: 0.125rem;
    font-size: 0.5rem;
}

/* Alerts */
.alert {
    --bs-alert-padding-x: 1rem;
    --bs-alert-padding-y: 0.875rem;
    --bs-alert-border-radius: var(--bs-border-radius-lg);
    font-size: 0.875rem;
}

.alert-heading {
    color: inherit;
    font-size: 0.875rem;
    font-weight: 600;
}

.alert-dismissible .btn-close {
    padding: 1.125rem 1rem;
}

/* Navs & tabs */
.nav {
    --bs-nav-link-color: var(--bs-secondary-color);
    --bs-nav-link-hover-color: var(--bs-emphasis-color);
    --bs-nav-link-disabled-color: var(--bs-tertiary-color);
    --bs-nav-link-font-size: 0.875rem;
    --bs-nav-link-font-weight: 500;
    --bs-nav-link-padding-x: 0.75rem;
    --bs-nav-link-padding-y: 0.4375rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-fill .nav-link,
.nav-justified .nav-link {
    justify-content: center;
}

.nav-link:hover {
    text-decoration: none;
}

.nav-link:focus-visible {
    box-shadow: var(--ui-focus-ring);
}

/* Underline tabs: keyboard focus shows as a soft tinted tab above the line, not a box over it. */
.nav-underline .nav-link:focus-visible {
    border-radius: var(--bs-border-radius-sm) var(--bs-border-radius-sm) 0 0;
    background: rgba(var(--bs-primary-rgb), 0.1);
    box-shadow: none;
    outline: 0;
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--bs-border-color);
    --bs-nav-tabs-border-radius: var(--bs-border-radius);
    --bs-nav-tabs-link-hover-border-color: transparent;
    --bs-nav-tabs-link-active-color: var(--bs-emphasis-color);
    --bs-nav-tabs-link-active-bg: var(--ui-glass-bg);
    --bs-nav-tabs-link-active-border-color: var(--bs-border-color) var(--bs-border-color) transparent;
}

.nav-underline {
    --bs-nav-underline-gap: 1.25rem;
    --bs-nav-underline-border-width: 2px;
    --bs-nav-underline-link-active-color: var(--bs-emphasis-color);
    border-bottom: 1px solid var(--bs-border-color);
}

.nav-underline .nav-link {
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    margin-bottom: -1px;
}

.nav-underline .nav-link:hover,
.nav-underline .nav-link:focus {
    border-bottom-color: var(--ui-input-border);
}

.nav-underline .nav-link.active,
.nav-underline .show > .nav-link {
    border-bottom-color: var(--bs-primary);
    font-weight: 500;
}

.nav-pills {
    --bs-nav-pills-border-radius: var(--bs-border-radius);
    --bs-nav-pills-link-active-color: var(--bs-emphasis-color);
    --bs-nav-pills-link-active-bg: var(--ui-active);
    gap: 0.25rem;
}

.nav-pills .nav-link:not(.active):hover {
    background-color: var(--ui-hover);
}

.nav .badge {
    font-size: 0.6875rem;
}

/* Breadcrumb */
.breadcrumb {
    --bs-breadcrumb-font-size: 0.8125rem;
    --bs-breadcrumb-margin-bottom: 0.5rem;
    --bs-breadcrumb-divider-color: var(--bs-tertiary-color);
    --bs-breadcrumb-item-active-color: var(--bs-emphasis-color);
    --bs-breadcrumb-item-padding-x: 0.5rem;
}

.breadcrumb-item a {
    color: var(--bs-secondary-color);
}

.breadcrumb-item a:hover {
    color: var(--bs-emphasis-color);
    text-decoration: none;
}

/* Pagination: separate rounded buttons */
.pagination {
    --bs-pagination-padding-x: 0.625rem;
    --bs-pagination-padding-y: 0.3125rem;
    --bs-pagination-font-size: 0.875rem;
    --bs-pagination-color: var(--bs-body-color);
    --bs-pagination-bg: transparent;
    --bs-pagination-border-color: transparent;
    --bs-pagination-border-radius: var(--bs-border-radius);
    --bs-pagination-hover-color: var(--bs-emphasis-color);
    --bs-pagination-hover-bg: var(--ui-hover);
    --bs-pagination-hover-border-color: transparent;
    --bs-pagination-focus-color: var(--bs-emphasis-color);
    --bs-pagination-focus-bg: var(--ui-hover);
    --bs-pagination-focus-box-shadow: var(--ui-focus-ring);
    --bs-pagination-active-color: var(--bs-emphasis-color);
    --bs-pagination-active-bg: var(--ui-input-bg);
    --bs-pagination-active-border-color: var(--ui-input-border);
    --bs-pagination-disabled-color: var(--bs-tertiary-color);
    --bs-pagination-disabled-bg: transparent;
    --bs-pagination-disabled-border-color: transparent;
    gap: 0.25rem;
    margin-bottom: 0;
}

/* Bootstrap's paginator keeps a paragraph margin beside the page buttons. */
.d-none.flex-sm-fill > div > p.small.text-muted {
    margin-bottom: 0;
}

.pagination-sm {
    --bs-pagination-padding-x: 0.5rem;
    --bs-pagination-padding-y: 0.1875rem;
    --bs-pagination-font-size: 0.8125rem;
    --bs-pagination-border-radius: var(--bs-border-radius);
}

.pagination > .page-item > .page-link {
    min-width: 2rem;
    margin-left: 0;
    border-radius: var(--bs-pagination-border-radius);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.pagination-sm > .page-item > .page-link {
    min-width: 1.75rem;
}

.pagination > .page-item.active > .page-link {
    box-shadow: var(--bs-box-shadow-sm);
    font-weight: 600;
}

.page-link:hover {
    text-decoration: none;
}

/* Floating layers: frosted glass */
.dropdown-menu {
    --bs-dropdown-min-width: 12rem;
    --bs-dropdown-padding-x: 0.3125rem;
    --bs-dropdown-padding-y: 0.3125rem;
    --bs-dropdown-font-size: 0.875rem;
    --bs-dropdown-color: var(--bs-body-color);
    --bs-dropdown-bg: var(--ui-glass-bg);
    --bs-dropdown-border-color: var(--bs-border-color);
    --bs-dropdown-border-radius: var(--bs-border-radius-lg);
    --bs-dropdown-inner-border-radius: var(--bs-border-radius);
    --bs-dropdown-box-shadow: var(--bs-box-shadow);
    --bs-dropdown-divider-bg: var(--bs-border-color);
    --bs-dropdown-divider-margin-y: 0.3125rem;
    --bs-dropdown-link-color: var(--bs-body-color);
    --bs-dropdown-link-hover-color: var(--bs-emphasis-color);
    --bs-dropdown-link-hover-bg: var(--ui-active);
    --bs-dropdown-link-active-color: var(--bs-emphasis-color);
    --bs-dropdown-link-active-bg: var(--ui-active);
    --bs-dropdown-link-disabled-color: var(--bs-tertiary-color);
    --bs-dropdown-item-padding-x: 0.625rem;
    --bs-dropdown-item-padding-y: 0.4375rem;
    --bs-dropdown-header-color: var(--bs-tertiary-color);
    --bs-dropdown-header-padding-x: 0.625rem;
    --bs-dropdown-header-padding-y: 0.375rem;
    box-shadow: var(--ui-highlight), var(--bs-dropdown-box-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

/* Native top-layer menus retain their DOM ancestry (Livewire and modal focus),
   but escape scrollable bodies and transformed/glass surfaces. */
[data-ui-floating][popover] {
    margin: 0;
    inset: auto;
    min-width: min(var(--ui-floating-min-width, 0px), calc(100vw - 1rem)) !important;
    max-width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

:is(.dropdown-menu, .popover, .flatpickr-calendar)[data-ui-floating] {
    background: var(--ui-surface-raised);
}

.tooltip[data-ui-floating] {
    border: 0;
    background: transparent;
    overflow: visible;
}

.flatpickr-calendar[data-ui-floating] {
    position: fixed !important;
    top: var(--ui-floating-top) !important;
    left: var(--ui-floating-left) !important;
    right: auto !important;
}

.flatpickr-calendar[data-ui-floating].animate.open {
    animation: none;
}

[data-ui-floating].w-100 {
    width: var(--ui-floating-width) !important;
    min-width: min(var(--ui-floating-width), calc(100vw - 1rem)) !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: var(--bs-border-radius-sm);
}

.dropdown-item:hover {
    text-decoration: none;
}

.dropdown-item > i {
    width: 1rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.dropdown-item.active > i,
.dropdown-item:active > i {
    color: var(--bs-primary-text-emphasis);
}

/* Type-ahead suggestions under a text field (.ui-suggest wrapper, .ui-suggest-menu list):
   a dropdown menu shown while typing, as wide as the field, scrolling past ~8 lines. */
.ui-suggest {
    position: relative;
}

.ui-suggest-menu {
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 22rem;
    margin-top: 0.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ui-suggest-menu .dropdown-item {
    align-items: flex-start;
    white-space: normal;
}

.dropdown-item.text-danger:hover,
.dropdown-item.text-danger:focus {
    background-color: var(--bs-danger-bg-subtle);
}

.dropdown-item.text-danger > i {
    color: inherit;
}

.dropdown-header {
    font-size: 0.75rem;
    font-weight: 500;
}

.dropdown-toggle::after {
    width: 0.625rem;
    height: 0.625rem;
    margin-left: 0;
    border: 0;
    background-color: currentColor;
    -webkit-mask: var(--ui-chevron-mask) center / contain no-repeat;
    mask: var(--ui-chevron-mask) center / contain no-repeat;
    opacity: 0.6;
    vertical-align: middle;
}

.toast {
    --bs-toast-padding-x: 1rem;
    --bs-toast-padding-y: 0.75rem;
    --bs-toast-font-size: 0.875rem;
    --bs-toast-color: var(--bs-body-color);
    --bs-toast-bg: var(--ui-glass-bg);
    --bs-toast-border-color: var(--bs-border-color);
    --bs-toast-border-radius: var(--bs-border-radius-lg);
    --bs-toast-box-shadow: var(--bs-box-shadow);
    --bs-toast-header-color: var(--bs-emphasis-color);
    --bs-toast-header-bg: transparent;
    --bs-toast-header-border-color: var(--bs-border-color);
    box-shadow: var(--ui-highlight), var(--bs-toast-box-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.tooltip {
    --bs-tooltip-bg: var(--bs-emphasis-color);
    --bs-tooltip-color: var(--bs-body-bg);
    --bs-tooltip-font-size: 0.75rem;
    --bs-tooltip-padding-x: 0.5rem;
    --bs-tooltip-padding-y: 0.3125rem;
    --bs-tooltip-border-radius: var(--bs-border-radius-sm);
    --bs-tooltip-opacity: 1;
}

.tooltip-inner {
    font-weight: 500;
}

.popover {
    --bs-popover-bg: var(--ui-glass-bg);
    --bs-popover-border-color: var(--bs-border-color);
    --bs-popover-border-radius: var(--bs-border-radius-lg);
    --bs-popover-inner-border-radius: calc(var(--bs-border-radius-lg) - 1px);
    --bs-popover-box-shadow: var(--bs-box-shadow);
    --bs-popover-font-size: 0.8125rem;
    --bs-popover-header-bg: transparent;
    --bs-popover-header-color: var(--bs-emphasis-color);
    --bs-popover-header-font-size: 0.875rem;
    --bs-popover-header-padding-x: 0.875rem;
    --bs-popover-header-padding-y: 0.625rem;
    --bs-popover-body-padding-x: 0.875rem;
    --bs-popover-body-padding-y: 0.75rem;
    box-shadow: var(--ui-highlight), var(--bs-popover-box-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.popover-header {
    padding-bottom: 0;
    border-bottom: 0;
    font-weight: 600;
}

/* Detail popover (hover card over dense content such as a planning): opaque
   surface, wider, title then a key line, then aligned icon + text rows. */
.ui-popover-detail {
    --bs-popover-max-width: 22rem;
    --bs-popover-header-font-size: 0.9375rem;
    --bs-popover-box-shadow: var(--bs-box-shadow-lg);
    background: linear-gradient(var(--bs-card-bg, var(--ui-surface-raised)), var(--bs-card-bg, var(--ui-surface-raised))) var(--bs-body-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Detail card carrying sentences (builder elements): wider */
.ui-popover-detail.ui-popover-detail-wide {
    --bs-popover-max-width: 26rem;
}

.ui-popover-detail .popover-body {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    color: var(--bs-body-color);
}

.ui-popover-detail-row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.ui-popover-detail-row > .bi {
    flex-shrink: 0;
    width: 1rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

/* Modals & offcanvas: glass over a blurred backdrop */
/* Native dialogs use the kit's modal layout while staying above open forms. */
dialog.modal[open] {
    display: block;
}

dialog.modal::backdrop {
    background: var(--ui-backdrop);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.modal {
    --bs-modal-bg: var(--ui-glass-bg);
    --bs-modal-border-color: var(--ui-glass-border);
    --bs-modal-border-radius: var(--bs-border-radius-xl);
    --bs-modal-inner-border-radius: calc(var(--bs-border-radius-xl) - 1px);
    --bs-modal-box-shadow: var(--bs-box-shadow-lg);
    --bs-modal-padding: 1.5rem;
    --bs-modal-header-padding: 1.25rem 1.5rem 0;
    --bs-modal-header-border-width: 0;
    --bs-modal-footer-border-width: 0;
    --bs-modal-footer-gap: 0.5rem;
    --bs-modal-title-line-height: 1.4;
}

.modal-content {
    box-shadow: var(--ui-highlight), var(--bs-modal-box-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.modal-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

/* Keep help and close together: two auto margins would split the free space. */
.modal-header:has(> [data-ui-tour-start]) {
    column-gap: 0.5rem;
}

.modal-header > [data-ui-tour-start] {
    margin-inline-start: auto;
    flex-shrink: 0;
}

.modal-header > [data-ui-tour-start] ~ .btn-close {
    margin-inline-start: 0;
    flex-shrink: 0;
}

.modal-header:not(.flex-column) > :has(> [data-ui-tour-start]):has(> .btn-close) {
    margin-inline-start: auto;
    flex-shrink: 0;
}

.modal-footer {
    gap: var(--bs-modal-footer-gap);
    padding: 0 1.5rem 1.25rem;
}

/* The gap replaces Bootstrap's per-button margins */
.modal-footer > * {
    margin: 0;
}

.modal-dialog-scrollable .modal-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.modal-dialog-scrollable .modal-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--bs-border-color);
}

/* Wider than modal-xl on desktop (document previews); phones keep their own size */
@media (min-width: 992px) {
    .modal-xxl {
        --bs-modal-width: min(1800px, calc(100vw - 3rem));
    }
}

/* PDF pages rendered as canvases: one column, or side by side on desktop when the spread view is on */
.ui-pdf-pages {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: .5rem;
    padding: .5rem;
}

.ui-pdf-page {
    position: relative;
    --scale-round-x: 1px;
    --scale-round-y: 1px;
}

.ui-pdf-page > canvas {
    display: block;
    width: 100%;
    height: auto;
}

/* PDF.js text layer: transparent text over the page, read by the desktop search (mirrors pdf_viewer.css) */
.ui-pdf-page > .textLayer {
    position: absolute;
    inset: 0;
    overflow: clip;
    line-height: 1;
    text-align: initial;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    forced-color-adjust: none;
    transform-origin: 0 0;
    z-index: 0;
}

.ui-pdf-page > .textLayer :is(span, br) {
    position: absolute;
    color: transparent;
    white-space: pre;
    cursor: text;
    transform-origin: 0 0;
}

.ui-pdf-page > .textLayer span.markedContent {
    top: 0;
    height: 0;
}

.ui-pdf-page > .textLayer ::selection {
    background: color-mix(in srgb, AccentColor, transparent 75%);
}

/* Search hits: marker over the words; the current one is also outlined (not told by colour alone) */
.ui-pdf-page > .textLayer .ui-pdf-hit {
    position: static;
    margin: -1px;
    padding: 1px;
    border-radius: 2px;
    background-color: rgb(255 193 7 / 0.4);
}

.ui-pdf-page > .textLayer .ui-pdf-hit.is-current {
    background-color: rgb(253 126 20 / 0.55);
    outline: 2px solid #212529;
    outline-offset: 1px;
}

@media (max-width: 991.98px) {
    .ui-pdf-page > .textLayer {
        display: none;
    }
}

/* Desktop page list beside a PDF preview: click a page to scroll to it, the visible one is marked */
.ui-pdf-thumbs {
    position: relative;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    width: calc(104px + 1.5rem);
    padding: .5rem .75rem;
    overflow-y: auto;
    border-right: 1px solid var(--bs-border-color);
    background-color: var(--bs-tertiary-bg);
}

.ui-pdf-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bs-secondary-color);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

.ui-pdf-thumb > canvas {
    display: block;
    width: 104px;
    height: auto;
    border-radius: 2px;
    outline: 1px solid var(--bs-border-color);
    box-shadow: var(--bs-box-shadow-sm);
    transition: outline-color .15s ease;
}

.ui-pdf-thumb:hover > canvas {
    outline: 2px solid var(--bs-secondary-color);
}

.ui-pdf-thumb:focus-visible {
    outline: none;
}

.ui-pdf-thumb:focus-visible > canvas {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.ui-pdf-thumb[aria-current="page"] {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-pdf-thumb[aria-current="page"] > canvas {
    outline: 3px solid var(--bs-primary);
    outline-offset: 2px;
}

.ui-pdf-search {
    width: clamp(15rem, 26vw, 22rem);
}

.ui-pdf-search-count {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (min-width: 992px) {
    .ui-pdf-pages.is-spread {
        grid-template-columns: repeat(var(--pdf-columns, 1), minmax(0, 1fr));
    }
}

/* Document preview whose header floats over the pages: a bar at the top, only its controls once the pages scroll */
.ui-doc-preview.has-floating-header > .ui-doc-preview-header {
    position: absolute;
    inset: 0 0 auto;
    z-index: 20;
    padding-bottom: 0.75rem;
    background-color: var(--bs-modal-bg);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
    transition: background-color 0.2s ease;
}

.ui-doc-preview.has-floating-header > .ui-doc-preview-header.is-floating {
    background-color: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    pointer-events: none;
}

.ui-doc-preview.has-floating-header > .ui-doc-preview-header.is-floating > * {
    pointer-events: auto;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-glass-surface);
    box-shadow: var(--ui-glass-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.ui-doc-preview.has-floating-header > .ui-doc-preview-header.is-floating > .ui-segmented {
    background-image: linear-gradient(var(--ui-active), var(--ui-active));
}

.ui-doc-preview.has-floating-header > .ui-doc-preview-header.is-floating > :not(.ui-segmented) {
    padding: 0.1875rem;
}

/* Bootstrap pulls the modal close button into the header padding; inside the pill it would touch the edge */
.ui-doc-preview.has-floating-header > .ui-doc-preview-header.is-floating .btn-close {
    margin: 0 0.375rem 0 0.25rem;
}

.ui-doc-preview.has-floating-header .ui-pdf-pages {
    padding-top: var(--doc-preview-header-h, 0.5rem);
}

/* Room for the current page's outline below the header */
.ui-doc-preview.has-floating-header .ui-pdf-thumbs {
    padding-top: calc(var(--doc-preview-header-h, 0px) + 0.5rem);
}

.ui-doc-preview.has-floating-header .ui-doc-preview-status {
    top: var(--doc-preview-header-h, 0) !important;
}

.modal-backdrop,
.offcanvas-backdrop {
    --bs-backdrop-bg: var(--ui-backdrop);
    --bs-backdrop-opacity: 1;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* Dialog opened over a modal or an offcanvas (custom snooze): it and its own backdrop sit above
   them (1055, 1045) and above popovers (1070); toasts (1090) stay on top.
   <div class="modal show d-block ui-modal-over">…</div><div class="modal-backdrop show ui-modal-over"></div> */
.modal.ui-modal-over {
    z-index: 1075;
}

.modal-backdrop.ui-modal-over {
    z-index: 1074;
}

.offcanvas,
.offcanvas-xs, .offcanvas-sm, .offcanvas-md, .offcanvas-lg, .offcanvas-xl, .offcanvas-xxl {
    --bs-offcanvas-width: 26rem;
    --bs-offcanvas-padding-x: 1.5rem;
    --bs-offcanvas-padding-y: 1.25rem;
    --bs-offcanvas-bg: var(--ui-glass-bg);
    --bs-offcanvas-border-color: var(--ui-glass-border);
    --bs-offcanvas-box-shadow: var(--bs-box-shadow-lg);
    --bs-offcanvas-title-line-height: 1.4;
}

/* Floating side panel detached from the viewport edges */
.offcanvas.offcanvas-end,
.offcanvas.offcanvas-start {
    top: var(--ui-shell-gap);
    bottom: var(--ui-shell-gap);
    max-width: calc(100vw - 2 * var(--ui-shell-gap));
    border: 1px solid var(--bs-offcanvas-border-color);
    border-radius: var(--bs-border-radius-xl);
}

.offcanvas.offcanvas-end {
    right: var(--ui-shell-gap);
}

.offcanvas.offcanvas-start {
    left: var(--ui-shell-gap);
}

.offcanvas.showing,
.offcanvas.show:not(.hiding) {
    box-shadow: var(--ui-highlight), var(--bs-offcanvas-box-shadow);
}

.offcanvas {
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.offcanvas-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

/* Accordion */
.accordion {
    --bs-accordion-bg: var(--ui-glass-surface);
    --bs-accordion-color: var(--bs-body-color);
    --bs-accordion-border-color: var(--ui-glass-border);
    --bs-accordion-border-radius: var(--bs-border-radius-lg);
    --bs-accordion-inner-border-radius: calc(var(--bs-border-radius-lg) - 1px);
    --bs-accordion-btn-padding-x: 1.25rem;
    --bs-accordion-btn-padding-y: 0.875rem;
    --bs-accordion-btn-color: var(--bs-emphasis-color);
    --bs-accordion-btn-bg: transparent;
    --bs-accordion-btn-icon-width: 0.875rem;
    --bs-accordion-btn-focus-box-shadow: inset var(--ui-focus-ring);
    --bs-accordion-body-padding-x: 1.25rem;
    --bs-accordion-body-padding-y: 0;
    --bs-accordion-active-color: var(--bs-emphasis-color);
    --bs-accordion-active-bg: transparent;
}

[data-bs-theme] .accordion-button::after {
    --bs-accordion-btn-icon: var(--ui-chevron-icon);
    --bs-accordion-btn-active-icon: var(--ui-chevron-icon);
}

.accordion-button {
    font-size: 0.875rem;
    font-weight: 500;
}

.accordion-button:hover {
    background-color: var(--ui-hover);
}

.accordion-button:not(.collapsed) {
    box-shadow: none;
}

/* Card accordions have no .accordion-item to provide Bootstrap's corner radii. */
.card.accordion > .card-header:first-child .accordion-button {
    border-top-left-radius: var(--bs-card-inner-border-radius);
    border-top-right-radius: var(--bs-card-inner-border-radius);
}

.card.accordion > .card-header:first-child .accordion-button.collapsed {
    border-bottom-left-radius: var(--bs-card-inner-border-radius);
    border-bottom-right-radius: var(--bs-card-inner-border-radius);
}

/* Keep the focus indicator visible in both the expanded and collapsed states. */
.accordion-button:focus {
    box-shadow: var(--bs-accordion-btn-focus-box-shadow);
}

.accordion-body {
    padding-bottom: 1rem;
    color: var(--bs-secondary-color);
}

.accordion:not(.accordion-flush) {
    border-radius: var(--bs-accordion-border-radius);
    box-shadow: var(--ui-glass-shadow);
}

.accordion-flush {
    --bs-accordion-bg: transparent;
    --bs-accordion-border-color: var(--bs-border-color);
}

/* List group */
.list-group {
    --bs-list-group-bg: var(--ui-glass-surface);
    --bs-list-group-color: var(--bs-body-color);
    --bs-list-group-border-color: var(--ui-glass-border);
    --bs-list-group-border-radius: var(--bs-border-radius-lg);
    --bs-list-group-item-padding-x: 1rem;
    --bs-list-group-item-padding-y: 0.75rem;
    --bs-list-group-action-color: var(--bs-body-color);
    --bs-list-group-action-hover-color: var(--bs-emphasis-color);
    --bs-list-group-action-hover-bg: var(--ui-hover);
    --bs-list-group-action-active-color: var(--bs-emphasis-color);
    --bs-list-group-action-active-bg: var(--ui-active);
    --bs-list-group-active-color: var(--bs-emphasis-color);
    --bs-list-group-active-bg: var(--ui-active);
    --bs-list-group-active-border-color: var(--bs-border-color);
    --bs-list-group-disabled-color: var(--bs-tertiary-color);
    font-size: 0.875rem;
}

.list-group:not(.list-group-flush) {
    box-shadow: var(--ui-glass-shadow);
}

:is(.card, .modal-content, .offcanvas) .list-group {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--bs-border-color);
    box-shadow: none;
}

:is(.modal-content, .offcanvas) .list-group:not(.list-group-flush) {
    --bs-list-group-bg: var(--ui-input-bg);
}

.list-group-item.active {
    font-weight: 500;
}

.list-group-item-action:hover {
    text-decoration: none;
}

/* Progress & spinners */
.progress,
.progress-stacked {
    --bs-progress-height: 0.375rem;
    --bs-progress-font-size: 0.6875rem;
    --bs-progress-bg: var(--ui-active);
    --bs-progress-border-radius: var(--bs-border-radius-pill);
    --bs-progress-bar-color: var(--ui-on-primary);
    --bs-progress-bar-bg: var(--bs-primary);
}

.progress > .progress-bar {
    border-radius: inherit;
}

.progress-bar.bg-success { color: var(--ui-on-success); }
.progress-bar.bg-warning { color: var(--ui-on-warning); }
.progress-bar.bg-danger { color: var(--ui-on-danger); }
.progress-bar.bg-info { color: var(--ui-on-info); }

.progress-stacked > .progress > .progress-bar {
    border-radius: 0;
}

.spinner-border {
    --bs-spinner-border-width: 0.15em;
}

.spinner-border-sm {
    --bs-spinner-width: 0.875rem;
    --bs-spinner-height: 0.875rem;
    --bs-spinner-border-width: 0.125em;
}

.placeholder {
    background-color: var(--bs-emphasis-color);
    border-radius: var(--bs-border-radius-sm);
    opacity: 0.07;
}

.placeholder-glow .placeholder {
    animation: ui-placeholder-glow 1.6s ease-in-out infinite;
}

@keyframes ui-placeholder-glow {
    50% {
        opacity: 0.03;
    }
}

/* Shimmer: a light band sweeps across the placeholders while a list or card loads */
.placeholder-shimmer .placeholder {
    opacity: 1;
    background-color: transparent;
    background-image: linear-gradient(90deg,
        color-mix(in srgb, var(--bs-emphasis-color) 6%, transparent) 25%,
        color-mix(in srgb, var(--bs-emphasis-color) 12%, transparent) 37%,
        color-mix(in srgb, var(--bs-emphasis-color) 6%, transparent) 63%);
    background-size: 400% 100%;
    animation: ui-shimmer 1.4s ease-in-out infinite;
}

@keyframes ui-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

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

/* 4. ADDITIONS
-------------------------------------------------- */

/* Loading region: while a request refreshes a result zone (a list, a
 * calendar, a map), that zone alone dims and a thin bar fills along its top
 * edge, slowing down as it waits; its clicks are blocked. When the response
 * arrives, ui.js adds .is-loaded: the bar completes and fades while the fresh
 * content fades in. Never put it on filters, which must stay clickable in a
 * row. Toggle .is-loading, e.g. wire:loading.class="is-loading" with
 * wire:loading.attr="aria-busy" and a wire:target scoped to the zone. Nothing
 * shows for requests shorter than 0.15 s. */
.ui-loading-region {
    position: relative;
}

/* Veil */
.ui-loading-region::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
    background-color: color-mix(in srgb, var(--bs-body-bg) 55%, transparent);
    cursor: progress;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

/* Progress bar: transitions (not animations) so completing starts from where it stopped */
.ui-loading-region::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    height: 0.1875rem;
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background-color: var(--bs-primary);
    box-shadow: 0 0 0.5rem color-mix(in srgb, var(--bs-primary) 50%, transparent);
    transform-origin: left;
    scale: 0 1;
    opacity: 0;
    pointer-events: none;
}

.ui-loading-region.is-loading::after {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease 0.15s, visibility 0s linear 0.15s;
}

.ui-loading-region.is-loading::before {
    scale: 0.9 1;
    opacity: 1;
    transition: scale 8s cubic-bezier(0.1, 0.8, 0.2, 1) 0.15s, opacity 0s linear 0.15s;
}

.ui-loading-region.is-loaded::before {
    scale: 1 1;
    opacity: 0;
    transition: scale 0.2s ease-out, opacity 0.3s ease 0.2s;
}

/* A busy zone nested in another busy zone keeps a single bar and veil */
.ui-loading-region.is-loading .ui-loading-region::before,
.ui-loading-region.is-loading .ui-loading-region::after {
    opacity: 0;
    visibility: hidden;
}

.ui-loading-region.is-loaded > * {
    animation: ui-loading-fade-in 0.3s ease both;
}

@keyframes ui-loading-fade-in {
    from {
        opacity: 0.5;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ui-loading-region.is-loading::before {
        transition-duration: 0s;
    }

    .ui-loading-region.is-loaded > * {
        animation: none;
    }
}

/* AI button: gold, the entry point of an assistant (one per page). Its sparkle icon and
   label name it; the sheen sweeps once on hover, not with reduced motion. */
.btn-ai {
    --bs-btn-color: #3b2a00;
    --bs-btn-bg: #f2c94c;
    --bs-btn-border-color: #d4a21c;
    --bs-btn-hover-color: #2b1f00;
    --bs-btn-hover-bg: #f6d872;
    --bs-btn-hover-border-color: #c4920f;
    --bs-btn-active-color: #2b1f00;
    --bs-btn-active-bg: #e6b628;
    --bs-btn-active-border-color: #b5860c;
    --bs-btn-focus-shadow-rgb: 212, 162, 28;
    --bs-btn-disabled-color: #5c4a1a;
    --bs-btn-disabled-bg: #f2dc9a;
    --bs-btn-disabled-border-color: #e3c56e;
    position: relative;
    overflow: hidden;
    font-weight: 600;
    background-image: linear-gradient(135deg, #fbe7a6 0%, #f2c94c 48%, #dfa526 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(120, 80, 0, 0.28);
}

.btn-ai:hover,
.btn-ai:focus-visible {
    background-image: linear-gradient(135deg, #fdeebd 0%, #f6d872 48%, #e7b234 100%);
}

.btn-ai::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.6) 50%, transparent 70%);
    transform: translateX(-120%);
    pointer-events: none;
}

.btn-ai:hover::after {
    transform: translateX(120%);
    transition: transform 0.8s ease;
}

@media (prefers-reduced-motion: reduce) {
    .btn-ai:hover::after {
        transition: none;
    }
}

/* Ghost button: transparent until hovered (toolbars, row actions) */
.btn-ghost {
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-bg: var(--ui-active);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: var(--ui-active);
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--bs-tertiary-color);
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: transparent;
}

/* Square icon-only button; combine with any .btn-* variant */
.btn-icon {
    --bs-btn-padding-x: 0;
    width: calc(1.3125rem + 2 * var(--bs-btn-padding-y) + 2px);
    flex-shrink: 0;
}

.btn-icon.btn-sm {
    width: calc(1.21875rem + 2 * var(--bs-btn-padding-y) + 2px);
}

.btn-icon.btn-lg {
    width: calc(1.40625rem + 2 * var(--bs-btn-padding-y) + 2px);
}

/* Segmented control: a .btn-group of .btn-check radios, or .ui-segmented with .active buttons */
.ui-segmented,
.btn-group:has(> .btn-check) {
    gap: 0.125rem;
    padding: 0.1875rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-active);
}

.ui-segmented > .btn,
.btn-group:has(> .btn-check) > .btn {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--bs-emphasis-color);
    --bs-btn-active-bg: var(--bs-body-bg);
    --bs-btn-active-border-color: transparent;
    margin-left: 0 !important;
    border-radius: calc(var(--bs-border-radius) - 0.1875rem) !important;
    background-image: none;
    box-shadow: none;
}

.ui-segmented > .btn.active,
.btn-group:has(> .btn-check) > .btn-check:checked + .btn {
    box-shadow: var(--bs-box-shadow-sm), 0 0 0 1px var(--bs-border-color);
}

[data-bs-theme="dark"] .ui-segmented > .btn,
[data-bs-theme="dark"] .btn-group:has(> .btn-check) > .btn {
    --bs-btn-active-bg: rgba(255, 255, 255, 0.1);
}

.ui-segmented > .btn-icon,
.btn-group:has(> .btn-check) > .btn-icon {
    width: 2rem;
}

/* Status dot: colour follows `text-*` utilities */
.ui-dot {
    display: inline-block;
    width: 0.4375rem;
    height: 0.4375rem;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: currentColor;
}

/* Icon tile: colour follows `bg-*-subtle` / `text-*-emphasis` utilities */
.ui-icon-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    border-radius: var(--bs-border-radius);
    font-size: 1.0625rem;
}

.ui-icon-tile-lg {
    width: 3rem;
    height: 3rem;
    border-radius: var(--bs-border-radius-lg);
    font-size: 1.375rem;
}

/* Avatar */
.ui-avatar {
    --ui-avatar-size: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ui-avatar-size);
    height: var(--ui-avatar-size);
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 50%;
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-size: calc(var(--ui-avatar-size) * 0.38);
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
}

.ui-avatar > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ui-avatar-sm { --ui-avatar-size: 1.5rem; }
.ui-avatar-lg { --ui-avatar-size: 2.75rem; }
.ui-avatar-xl { --ui-avatar-size: 4rem; }

.ui-avatar-status {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 0 2px var(--bs-body-bg);
}

.ui-avatar-group {
    display: inline-flex;
}

/* Opaque tint (from the text colour) so overlapping avatars stay readable */
.ui-avatar-group > .ui-avatar {
    background-image: linear-gradient(
        color-mix(in srgb, currentColor 16%, var(--bs-body-bg)),
        color-mix(in srgb, currentColor 16%, var(--bs-body-bg))
    );
    box-shadow: 0 0 0 2px var(--bs-body-bg);
}

.ui-avatar-group > .ui-avatar + .ui-avatar {
    margin-left: -0.3rem;
}

/* Empty state */
.ui-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 26rem;
    margin: 0 auto;
    padding: 2.5rem 1rem;
    text-align: center;
}

.ui-empty-title {
    margin: 0.5rem 0 0;
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.ui-empty-text {
    margin: 0;
    color: var(--bs-secondary-color);
}

.ui-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Entry page (sign-in and account access): one centred column over the ambient
   backdrop: logo, welcome title, then the form in a glass card. */
.ui-entry {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 1.25rem;
}

/* Page tools (theme menu) pinned to the top corner */
.ui-entry-tools {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
}

.ui-entry-inner {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 36rem;
    padding: 3rem 0 2rem;
}

.ui-entry-intro {
    margin-bottom: 1.75rem;
    text-align: center;
}

.ui-entry-logo {
    display: inline-flex;
    margin: 0 auto 1.25rem;
}

.ui-entry-logo:hover {
    text-decoration: none;
}

.ui-entry-logo .ui-brand-mark {
    width: 4.5rem;
    height: 2.25rem;
}

.ui-entry-eyebrow {
    margin: 0 0 0.5rem;
    color: var(--bs-primary-text-emphasis);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ui-entry-title {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

/* Highlighted words of the title: cyan to indigo, both text-emphasis tones */
.ui-entry-title-accent {
    background-image: linear-gradient(90deg, var(--bs-primary-text-emphasis), var(--bs-info-text-emphasis));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ui-entry-lead {
    margin: 0.75rem 0 0;
    color: var(--bs-secondary-color);
    font-size: 0.9375rem;
}

/* The welcome may run wider than the form, which keeps a comfortable measure */
.ui-entry-card {
    width: 100%;
    max-width: 26rem;
    margin-inline: auto;
}

.ui-entry-card > .card-body {
    padding: 1.5rem;
}

.ui-entry-note {
    margin: 1.25rem 0 0;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    text-align: center;
}

@media (min-width: 576px) {
    .ui-entry-title {
        font-size: 2.25rem;
    }

    .ui-entry-card > .card-body {
        padding: 2rem;
    }
}

/* Stepper */
.ui-stepper {
    display: flex;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: ui-step;
}

.ui-step {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    font-weight: 500;
    counter-increment: ui-step;
}

.ui-step:last-child {
    flex: 0 0 auto;
}

.ui-step::before {
    content: counter(ui-step);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: var(--ui-active);
    font-size: 0.75rem;
    font-weight: 600;
}

.ui-step:not(:last-child)::after {
    content: "";
    flex: 1 1 auto;
    min-width: 1rem;
    height: 1px;
    background-color: var(--bs-border-color);
}

.ui-step.is-active {
    color: var(--bs-emphasis-color);
}

.ui-step.is-active::before {
    background-color: var(--bs-body-bg);
    box-shadow: 0 0 0 1.5px var(--bs-primary), 0 0 0 5px rgba(var(--bs-primary-rgb), 0.18);
    color: var(--bs-primary-text-emphasis);
}

.ui-step.is-complete::before {
    content: "\F633"; /* bootstrap-icons check-lg */
    background-color: var(--bs-primary);
    color: var(--ui-on-primary);
    font-family: "bootstrap-icons";
}

.ui-step.is-complete::after {
    background-color: var(--bs-primary);
}

/* Semantic step colours, with a continuous transition to the next step. */
.ui-step[data-ui-step-tone="success"] { --ui-step-color: var(--bs-success); --ui-step-on: var(--ui-on-success); }
.ui-step[data-ui-step-tone="warning"] { --ui-step-color: var(--bs-warning); --ui-step-on: var(--ui-on-warning); }
.ui-step[data-ui-step-tone="danger"] { --ui-step-color: var(--bs-danger); --ui-step-on: var(--ui-on-danger); }
.ui-step[data-ui-step-tone="info"] { --ui-step-color: var(--bs-info); --ui-step-on: var(--ui-on-info); }
.ui-step[data-ui-step-next-tone="success"] { --ui-step-next-color: var(--bs-success); }
.ui-step[data-ui-step-next-tone="warning"] { --ui-step-next-color: var(--bs-warning); }
.ui-step[data-ui-step-next-tone="danger"] { --ui-step-next-color: var(--bs-danger); }
.ui-step[data-ui-step-next-tone="info"] { --ui-step-next-color: var(--bs-info); }

.ui-step[data-ui-step-tone]:is(.is-complete, .is-active)::before {
    background-color: var(--ui-step-color, var(--bs-primary));
    color: var(--ui-step-on, var(--ui-on-primary));
}

.ui-step[data-ui-step-tone].is-active::before {
    box-shadow: 0 0 0 1.5px var(--bs-body-bg), 0 0 0 5px color-mix(in srgb, var(--ui-step-color, var(--bs-primary)) 20%, transparent);
}

.ui-step[data-ui-step-next-tone].is-complete::after {
    background: linear-gradient(to right, var(--ui-step-color, var(--bs-primary)), var(--ui-step-next-color, var(--bs-primary)));
}

@media (max-width: 767.98px) {
    .ui-stepper:not(.ui-stepper-compact) {
        flex-direction: column;
    }

    .ui-stepper:not(.ui-stepper-compact) .ui-step:not(:last-child)::after {
        display: none;
    }
}

/* Compact stepper for a narrow panel: one line, each step as wide as its label, scrolls
   sideways when it does not fit. A step may hold a link to its page. */
.ui-stepper-compact {
    gap: 0.375rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 0.25rem 0.125rem;
}

.ui-stepper-compact .ui-step {
    flex: 0 0 auto;
    gap: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.ui-stepper-compact .ui-step::before {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.6875rem;
}

.ui-stepper-compact .ui-step:not(:last-child)::after {
    flex: 0 0 0.75rem;
    min-width: 0.75rem;
}

.ui-step > a {
    color: inherit;
    text-decoration: none;
}

.ui-step > a:hover,
.ui-step > a:focus-visible {
    color: var(--bs-emphasis-color);
    text-decoration: underline;
}

/* Page wizard (public/js/ui/wizard.js): a long page (report form…) shown one step at a time.
   <x-ui.wizard-bar> carries the current step, a menu of every step and previous / next;
   <x-ui.wizard-nav> closes the step with Précédent / Suivant and may hold the page tools
   (.ui-float-actions). .ui-wizard-sticky keeps the bar on screen while the page scrolls,
   .ui-wizard-fixed pins the nav to the bottom of the screen below lg. While the page has fewer
   than two steps or shows everything, the bar leaves and the nav keeps only its tools. Only the
   current step is shown (the script generates that rule), the content outside the steps stays
   on every step. */
.ui-wizard {
    --ui-wizard-nav-space: 4.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 992px) {
    .ui-wizard {
        flex: 1 1 auto;
        min-height: 0;
    }
}

.ui-wizard:not([data-ui-wizard-ready]) .ui-wizard-bar,
.ui-wizard[data-ui-wizard-idle] .ui-wizard-bar,
.ui-wizard:not([data-ui-wizard-on]) :is(.ui-wizard-bar, .ui-wizard-nav) > :is([data-ui-wizard-prev], [data-ui-wizard-next]) {
    display: none !important;
}

/* A frame of steps with nothing to show on the current step leaves the flow (wizard.js) */
.ui-wizard[data-ui-wizard-on] [data-ui-wizard-frame][data-ui-wizard-blank] {
    position: absolute !important;
}

/* No step to walk: the nav box leaves, the tools it holds float as they would on their own */
.ui-wizard:not([data-ui-wizard-on]) .ui-wizard-nav {
    display: contents;
}

.ui-wizard-bar {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.25rem 0.25rem 0.375rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--ui-glass-shadow);
}

/* Sticky under the topbar while the page scrolls (phones); on its own above the panel scroller from lg */
.ui-wizard-bar.ui-wizard-sticky {
    position: sticky;
    top: calc(var(--ui-topbar-height) + 0.5rem);
    z-index: 1020;
}

/* Pinned to the top of the panel scroller it opens (from lg): the panel scrolls under its glass,
   as the page does under the topbar. The glass sits on ::before so the step menu can still blur
   the page behind it. */
.ui-wizard-bar.ui-wizard-pinned {
    position: sticky;
    top: 0;
    z-index: 3;
    margin-bottom: 1rem;
    background-color: transparent;
}

.ui-wizard-bar.ui-wizard-pinned::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background-color: var(--ui-glass-chrome);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
    pointer-events: none;
}

/* The step title hugs its text; previous / next and the view switch keep to the end of the bar */
.ui-wizard-current {
    flex: 0 1 auto;
    min-width: 0;
}

.ui-wizard-current + *,
.ui-wizard:not([data-ui-wizard-on]) .ui-wizard-bar > [data-ui-wizard-mode] {
    margin-left: auto;
}

.ui-wizard-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    min-width: 0;
    text-align: start;
}

.ui-wizard-count {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Two lines at most: long builder titles differ by their end ("… entreprises ITI / ITE") */
.ui-wizard-label {
    display: -webkit-box;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ui-wizard-progress {
    position: absolute;
    right: 0.75rem;
    bottom: 0.1875rem;
    left: 0.75rem;
    height: 2px;
    overflow: hidden;
    border-radius: 1px;
    background-color: var(--bs-border-color-translucent);
}

.ui-wizard-progress > span {
    display: block;
    height: 100%;
    background-color: var(--bs-primary);
    transition: width 0.2s ease;
}

.ui-wizard:not([data-ui-wizard-on]) .ui-wizard-progress {
    visibility: hidden;
}

.ui-wizard-menu,
.ui-wizard-menu[data-ui-floating][popover] {
    width: min(26rem, calc(100vw - 1rem));
    max-height: min(70dvh, 32rem);
    overflow-y: auto;
}

.ui-wizard-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    white-space: normal;
}

.ui-wizard-menu-item > .text-truncate {
    display: -webkit-box;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ui-wizard-menu-index {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: var(--ui-active);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Points to review (x-ui.wizard-summary): rows when there are some, else the empty note or nothing */
.ui-wizard:is(:not([data-ui-wizard-ready]), [data-ui-wizard-idle]) .ui-wizard-summary,
.ui-wizard-summary[data-ui-wizard-summary-optional]:is(:not([data-ui-wizard-filled]), [data-ui-wizard-empty]),
.ui-wizard-summary:not([data-ui-wizard-empty]) .ui-wizard-summary-empty,
.ui-wizard-summary[data-ui-wizard-empty] .ui-wizard-summary-head {
    display: none !important;
}

.ui-wizard-summary {
    border-top: var(--bs-card-border-width, 1px) solid var(--bs-border-color-translucent);
}

.ui-wizard-summary-head,
.ui-wizard-summary-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem var(--bs-card-spacer-x, 1rem);
    font-size: 0.875rem;
}

.ui-wizard-summary-head {
    padding-bottom: 0.25rem;
    font-weight: 500;
}

.ui-wizard-summary-empty {
    color: var(--bs-secondary-color);
}

.ui-wizard-summary .list-group-item {
    padding-inline: var(--bs-card-spacer-x, 1rem);
    border-top: 0;
}

.ui-wizard-menu-item.active .ui-wizard-menu-index {
    background-color: var(--bs-primary);
    color: var(--ui-on-primary);
}

.ui-wizard-nav {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--ui-glass-shadow);
}

/* Pinned to the bottom of the screen below lg (the sidebar is an offcanvas there): the buttons
   keep their place whatever the step length, and the page tools float above them. */
@media (max-width: 991.98px) {
    .ui-wizard-nav.ui-wizard-fixed {
        position: fixed;
        right: 0.75rem;
        bottom: 0.5rem;
        left: 0.75rem;
        z-index: 1025;
    }

    .ui-wizard[data-ui-wizard-on]:has(.ui-wizard-nav.ui-wizard-fixed) {
        padding-bottom: var(--ui-wizard-nav-space);
    }

    .ui-wizard[data-ui-wizard-on]:has(.ui-wizard-nav.ui-wizard-fixed):has(.ui-float-actions) {
        padding-bottom: calc(var(--ui-wizard-nav-space) + 3.5rem);
    }

    .ui-wizard[data-ui-wizard-on] .ui-float-actions {
        bottom: calc(var(--ui-wizard-nav-space) + 0.5rem);
    }

    .ui-wizard[data-ui-wizard-on] .ui-float-actions-offset {
        margin-bottom: calc(3.5rem + var(--ui-wizard-nav-space));
    }

    /* Showing everything, the tools float alone: the end of the page stays clear of them */
    .ui-wizard:not([data-ui-wizard-on]):has(.ui-wizard-nav.ui-wizard-fixed > .ui-float-actions) {
        padding-bottom: 3.5rem;
    }
}

/* From lg the tools held by the nav sit between Précédent and Suivant, flat, when the panel
   leaves them the room; in a narrower panel they float just above the nav, at its right */
@media (min-width: 992px) {
    .ui-wizard[data-ui-wizard-on] .ui-wizard-nav {
        position: relative;
        container: ui-wizard-nav / inline-size;
    }

    @container ui-wizard-nav (width >= 34rem) {
        .ui-wizard[data-ui-wizard-on] .ui-wizard-nav > .ui-float-actions {
            position: static;
            z-index: auto;
            flex-shrink: 0;
            margin-inline: auto;
            padding: 0;
            background: none;
            box-shadow: none;
        }

        .ui-wizard[data-ui-wizard-on] .ui-wizard-nav > .ui-float-actions ~ .ui-wizard-next {
            margin-left: 0;
        }
    }

    @container ui-wizard-nav (width < 34rem) {
        .ui-wizard[data-ui-wizard-on] .ui-wizard-nav > .ui-float-actions {
            position: absolute;
            right: 0;
            bottom: calc(100% + 0.5rem);
        }
    }
}

.ui-wizard-nav > .btn {
    flex-shrink: 0;
}

/* Named after the step it returns to: shares the room, never wider than half the nav */
.ui-wizard-nav > .ui-wizard-prev {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    max-width: 50%;
}

@media (min-width: 576px) {
    .ui-wizard-nav > .ui-wizard-prev {
        max-width: 22rem;
    }
}

.ui-wizard-prev:has([data-ui-wizard-back-label]:not(:empty)) .ui-wizard-prev-word {
    display: none;
}

.ui-wizard-nav > .ui-wizard-next {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-width: 0;
    margin-left: auto;
}

@media (min-width: 576px) {
    .ui-wizard-nav > .ui-wizard-next {
        flex: 0 1 auto;
        max-width: 22rem;
    }
}

.ui-wizard-next-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-wizard-next-label:not(:empty)::before {
    content: " · ";
}

.ui-wizard-next-label {
    font-weight: 400;
}

/* A step opened from the bar starts below the sticky bar */
.ui-wizard [data-ui-wizard-step] {
    scroll-margin-top: calc(var(--ui-topbar-height) + 4.5rem);
}

@media (min-width: 992px) {
    .ui-wizard [data-ui-wizard-step] {
        scroll-margin-top: 0.5rem;
    }

    /* Below a step bar pinned in the same scroller: its height (2.75rem) and its margin */
    .ui-wizard-bar.ui-wizard-pinned ~ * [data-ui-wizard-step] {
        scroll-margin-top: 3.75rem;
    }
}

/* Connector: links two stacked blocks (e.g. a report version and the one it led to)
   with a dashed vertical line through the gap and an arrow towards the block above.
   Place it as a sibling between the blocks of a `gap-3` stack.
   <div class="ui-connector"><span class="ui-connector-icon"><i class="bi bi-arrow-up"></i></span><button class="btn btn-outline-secondary btn-sm">…</button></div> */
.ui-connector {
    --ui-connector-x: 1.5rem;
    --ui-connector-overlap: 1rem;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-height: 2rem;
    padding-left: calc(var(--ui-connector-x) + 1.5rem);
}

.ui-connector::before {
    content: "";
    position: absolute;
    left: var(--ui-connector-x);
    top: calc(-1 * var(--ui-connector-overlap));
    bottom: calc(-1 * var(--ui-connector-overlap));
    border-left: 2px dashed var(--bs-border-color);
    transform: translateX(-50%);
}

.ui-connector-icon {
    position: absolute;
    left: var(--ui-connector-x);
    top: 50%;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 50%;
    background: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    transform: translate(-50%, -50%);
}

/* Timeline (history, activity) */
.ui-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ui-timeline-item {
    position: relative;
    display: flex;
    gap: 0.875rem;
    padding-bottom: 1.25rem;
}

.ui-timeline-item:last-child {
    padding-bottom: 0;
}

.ui-timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 2rem;
    bottom: 0.25rem;
    left: 0.875rem;
    width: 1px;
    background-color: var(--bs-border-color);
}

.ui-timeline-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: var(--ui-active);
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
}

.ui-timeline-body {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 0.25rem;
}

/* Compact timeline for dense side panels (one stop per line, e.g. a day's tour) */
.ui-timeline-compact .ui-timeline-item {
    gap: 0.625rem;
    padding-bottom: 0.5rem;
}

.ui-timeline-compact .ui-timeline-item:last-child {
    padding-bottom: 0;
}

.ui-timeline-compact .ui-timeline-item:not(:last-child)::before {
    top: 1.5rem;
    left: 0.6875rem;
}

.ui-timeline-compact .ui-timeline-marker {
    width: 1.375rem;
    height: 1.375rem;
    font-size: 0.6875rem;
}

.ui-timeline-compact .ui-timeline-body {
    padding-top: 0.0625rem;
}

/* Stop of a tour: hours in a column (start over end) next to what happens there */
.ui-timeline-stop {
    display: flex;
    gap: 0.625rem;
    min-width: 0;
}

.ui-timeline-time {
    display: flex;
    flex: 0 0 2.5rem;
    flex-direction: column;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
}

.ui-timeline-time > :first-child {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-timeline-time > :last-child:not(:first-child) {
    color: var(--bs-secondary-color);
}

.ui-timeline-stop > :last-child {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.4;
}

/* Group heading kept visible while its rows scroll (e.g. one inspector per group). Opaque,
   underlined and lightly raised so the rows passing under it never read as part of it.
   --ui-group-tint (e.g. the inspector's colour) tints it and draws an accent on the left. */
.ui-sticky-group-head {
    --ui-group-wash: color-mix(in srgb, var(--ui-group-tint, var(--bs-secondary-color)) 10%, transparent);
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--bs-border-color);
    box-shadow: inset 3px 0 0 var(--ui-group-tint, transparent), 0 4px 8px -6px rgba(15, 23, 42, 0.35);
    background: linear-gradient(var(--ui-group-wash), var(--ui-group-wash)), linear-gradient(var(--bs-card-bg, var(--ui-surface-raised)), var(--bs-card-bg, var(--ui-surface-raised))) var(--bs-body-bg);
}

/* Week calendar (planning), built for volume: one row per time slot, each
   cell stacks compact one-line events and collapses the rest into "+N" */
.ui-calendar {
    display: grid;
    grid-template-columns: 3.5rem repeat(var(--ui-cal-days, 5), minmax(9.5rem, 1fr));
    overflow-x: auto;
    font-size: 0.75rem;
}

.ui-calendar-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.625rem 0.5rem;
    color: var(--bs-secondary-color);
    font-weight: 500;
}

.ui-calendar-head strong {
    color: var(--bs-emphasis-color);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.ui-calendar-head.is-today strong {
    color: var(--bs-primary-text-emphasis);
}

.ui-calendar-time {
    padding: 0.4375rem 0.625rem 0 0;
    border-top: 1px solid var(--bs-border-color);
    color: var(--bs-tertiary-color);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.ui-calendar-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    min-height: 2.5rem;
    padding: 0.25rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-calendar-cell.is-today,
.ui-calendar-head.is-today {
    background-color: color-mix(in srgb, var(--bs-primary) 5%, transparent);
}

/* Compact planning (work pages): one-line day heads (day, date, count) that stay
   visible while the grid scrolls inside its container (the container scrolls on both
   axes, so the grid itself must not clip). Today keeps its tint. */
.ui-calendar-compact {
    grid-template-columns: 3rem repeat(var(--ui-cal-days, 5), minmax(var(--ui-cal-day-min, 6.5rem), 1fr));
    overflow: visible;
}

.ui-calendar-compact > :first-child,
.ui-calendar-compact .ui-calendar-head {
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--bs-border-color);
    /* Opaque like .ui-table-sticky-head: the card surface painted over the page */
    background: linear-gradient(var(--bs-card-bg, var(--ui-surface-raised)), var(--bs-card-bg, var(--ui-surface-raised))) var(--bs-body-bg);
}

.ui-calendar-compact .ui-calendar-head {
    flex-flow: row wrap;
    justify-content: center;
    align-items: baseline;
    column-gap: 0.375rem;
    padding: 0.5rem;
}

.ui-calendar-compact .ui-calendar-head strong {
    font-size: 1rem;
}

.ui-calendar-compact .ui-calendar-head.is-today {
    background:
        linear-gradient(color-mix(in srgb, var(--bs-primary) 5%, transparent), color-mix(in srgb, var(--bs-primary) 5%, transparent)),
        linear-gradient(var(--bs-card-bg, var(--ui-surface-raised)), var(--bs-card-bg, var(--ui-surface-raised))) var(--bs-body-bg);
}

/* Events coloured by owner (e.g. one colour per inspector, set with --ui-status):
   stronger tint; the icon still carries the status and the label names the owner,
   so colour is never the only cue. */
.ui-calendar-owner .ui-calendar-event {
    background-color: color-mix(in srgb, var(--ui-event-tone) 22%, transparent);
}

.ui-calendar-owner .ui-calendar-event:hover,
.ui-calendar-owner .ui-calendar-event:focus-visible {
    background-color: color-mix(in srgb, var(--ui-event-tone) 34%, transparent);
}

.ui-calendar-event {
    --ui-event-tone: var(--bs-primary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    padding: 0.125rem 0.375rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background-color: color-mix(in srgb, var(--ui-event-tone) 12%, transparent);
    color: var(--bs-emphasis-color);
    font: inherit;
    line-height: 1.5;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ui-calendar-event:hover,
.ui-calendar-event:focus-visible {
    background-color: color-mix(in srgb, var(--ui-event-tone) 22%, transparent);
    outline: 0;
}

.ui-calendar-event[class*="ui-status-"] {
    --ui-event-tone: var(--ui-status);
}

.ui-calendar-event > time {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

.ui-calendar-event > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Past appointment: solid grey instead of the inspector tint, so what is left
   to do stands out. Text stays at the readable secondary colour and the status
   icon keeps its tone and shape. */
.ui-calendar-event.is-past,
.ui-calendar-owner .ui-calendar-event.is-past {
    background-color: color-mix(in srgb, var(--bs-secondary-color) 12%, var(--bs-body-bg));
    color: var(--bs-secondary-color);
}

.ui-calendar-event.is-past:hover,
.ui-calendar-event.is-past:focus-visible {
    background-color: color-mix(in srgb, var(--bs-secondary-color) 20%, var(--bs-body-bg));
}

/* Past row (table row, list-group item): same grey, emphasised text toned down
   to the secondary colour.
   <tr class="ui-past">…</tr> */
.ui-past {
    --bs-table-bg: color-mix(in srgb, var(--bs-secondary-color) 8%, var(--bs-body-bg));
    --bs-list-group-bg: color-mix(in srgb, var(--bs-secondary-color) 8%, var(--bs-body-bg));
}

.ui-past .text-body-emphasis {
    color: var(--bs-secondary-color) !important;
}

.ui-calendar-more {
    align-self: flex-start;
    padding: 0.0625rem 0.375rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background: none;
    color: var(--bs-secondary-color);
    font: inherit;
    font-weight: 500;
}

.ui-calendar-more:hover {
    background-color: var(--ui-active);
    color: var(--bs-emphasis-color);
}

/* Onboarding checklist (guided tours): done = check icon, todo = empty ring */
.ui-checklist-mark {
    display: inline-flex;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border: 1.5px dashed var(--bs-tertiary-color);
    border-radius: 50%;
}

.ui-checklist-item.is-done .ui-checklist-title {
    color: var(--bs-secondary-color);
}

/* Floating actions: page tools kept within reach wherever the user scrolls (report PDF
   preview, conformity). Pinned bottom-right above the content; a toast container on the
   same page gets .ui-float-actions-offset so it opens above the group. */
.ui-float-actions {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--ui-glass-shadow), var(--bs-box-shadow);
}

.ui-float-actions-offset {
    margin-bottom: 3.5rem;
}

/* Dropdown panel (notifications…): wider menu with header, list and footer */
.ui-dropdown-panel {
    --bs-dropdown-padding-x: 0;
    --bs-dropdown-padding-y: 0;
    width: min(24rem, calc(100vw - 1rem));
    overflow: hidden;
}

/* Wider panel for lists whose rows carry a sentence (action history…) */
.ui-dropdown-panel.ui-dropdown-panel-wide {
    width: min(30rem, calc(100vw - 1rem));
}

.ui-dropdown-panel .list-group {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: var(--bs-border-color);
    box-shadow: none;
}

.ui-dropdown-panel .list-group-item {
    border-right: 0;
    border-left: 0;
}

.ui-dropdown-panel .list-group-item.is-unread {
    background-color: color-mix(in srgb, var(--bs-primary) 6%, var(--ui-surface-raised));
}

/*
 * A blurred parent (topbar, sidebar) is a "backdrop root": menus opened inside
 * it cannot blur the page behind, so they would look see-through. Keep them opaque.
 */
:is(.ui-topbar, .ui-sidebar) .dropdown-menu {
    --bs-dropdown-bg: var(--ui-surface-raised);
}

/* Counter pinned on an icon button */
.ui-count {
    position: absolute;
    top: 0.125rem;
    right: 0.125rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-danger);
    box-shadow: 0 0 0 2px var(--bs-body-bg);
    color: var(--ui-on-danger);
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1rem;
    text-align: center;
}

/* Status: colour + icon, never colour alone.
   <span class="ui-status-icon ui-status-done"><i class="bi bi-check-lg"></i></span> */
.ui-status-done { --ui-status: var(--ui-status-done); --ui-status-ink: var(--ui-status-done-ink); }
.ui-status-progress { --ui-status: var(--ui-status-progress); --ui-status-ink: var(--ui-status-progress-ink); }
.ui-status-planned { --ui-status: var(--ui-status-planned); --ui-status-ink: var(--ui-status-planned-ink); }
.ui-status-fix { --ui-status: var(--ui-status-fix); --ui-status-ink: var(--ui-status-fix-ink); }
.ui-status-cancel { --ui-status: var(--ui-status-cancel); --ui-status-ink: var(--ui-status-cancel-ink); }

.ui-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: var(--ui-status, var(--bs-primary));
    color: var(--ui-status-ink, #ffffff);
    font-size: 0.625rem;
    line-height: 1;
}

.ui-status-icon > .bi::before {
    -webkit-text-stroke: 0.4px currentColor;
}

/* Live status (an assistant at work…): the disc sends out a soft ring; still under reduced motion.
   <span class="ui-status-icon ui-status-progress ui-status-live" title="En cours"><i class="bi bi-play-fill"></i><span class="visually-hidden">En cours</span></span> */
.ui-status-live {
    animation: ui-status-live 1.6s ease-out infinite;
}

@keyframes ui-status-live {
    from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ui-status, var(--bs-primary)) 55%, transparent); }
    to { box-shadow: 0 0 0 0.3125rem color-mix(in srgb, var(--ui-status, var(--bs-primary)) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
    .ui-status-live {
        animation: none;
        box-shadow: 0 0 0 0.125rem color-mix(in srgb, var(--ui-status, var(--bs-primary)) 35%, transparent);
    }
}

/* Pointing cue: blinking arrows that lead the eye to the element to change (a correction requested
   on a report field points down at the field it sits above). Still under reduced motion.
   <i class="bi bi-arrow-down ui-pointer-cue" aria-hidden="true"></i> */
.ui-pointer-cue {
    display: inline-block;
    animation: ui-pointer-cue 1s ease-in-out infinite;
}

@keyframes ui-pointer-cue {
    0%, 100% { opacity: 1; transform: translateY(0.125rem); }
    50% { opacity: 0.2; transform: translateY(-0.125rem); }
}

@media (prefers-reduced-motion: reduce) {
    .ui-pointer-cue {
        animation: none;
    }
}

/* Bare status icon (dense places such as calendar events): no disc, the glyph
   takes the tone. */
.ui-status-icon-plain {
    background-color: transparent;
    color: var(--ui-status, var(--bs-primary));
    font-size: 0.75rem;
}

/* Fiche tone: the colour of a fiche (report type), the same wherever it shows. A tone class sets
   --ui-fiche for the tag, the edge bar or anything inside; the code is always written beside it.
   <span class="ui-fiche-tag ui-fiche-tone-3">BAR-TH-160<span class="ui-fiche-tag-detail">Rapport</span></span>
   <a class="list-group-item ui-fiche-edge ui-fiche-tone-3">…</a> */
.ui-fiche-tone-1 { --ui-fiche: var(--ui-fiche-1); }
.ui-fiche-tone-2 { --ui-fiche: var(--ui-fiche-2); }
.ui-fiche-tone-3 { --ui-fiche: var(--ui-fiche-3); }
.ui-fiche-tone-4 { --ui-fiche: var(--ui-fiche-4); }
.ui-fiche-tone-5 { --ui-fiche: var(--ui-fiche-5); }
.ui-fiche-tone-6 { --ui-fiche: var(--ui-fiche-6); }
.ui-fiche-tone-7 { --ui-fiche: var(--ui-fiche-7); }
.ui-fiche-tone-8 { --ui-fiche: var(--ui-fiche-8); }

/* Fiche tag: a swatch of the tone, the code (cut with an ellipsis when long), then an optional detail (form, version) */
.ui-fiche-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    max-width: 100%;
    min-width: 0;
    padding: 0 0.375rem 0 0.3125rem;
    border: 1px solid color-mix(in srgb, var(--ui-fiche, var(--bs-secondary)) 35%, transparent);
    border-radius: var(--bs-border-radius-sm);
    background-color: color-mix(in srgb, var(--ui-fiche, var(--bs-secondary)) 10%, transparent);
    color: var(--bs-emphasis-color);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1rem;
    overflow: hidden;
    vertical-align: middle;
    white-space: nowrap;
}

.ui-fiche-tag::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    flex-shrink: 0;
    border-radius: 0.125rem;
    background-color: var(--ui-fiche, var(--bs-secondary));
}

.ui-fiche-tag-code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ui-fiche-tag-detail {
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
    color: var(--bs-body-color);
    font-weight: 400;
    text-overflow: ellipsis;
}

.ui-fiche-tag-detail::before {
    content: "· ";
    color: var(--bs-secondary-color);
}

/* Fiche tag as a button (changes the fiche): a chevron after the code, the tone stronger on hover */
.ui-fiche-tag-button {
    cursor: pointer;
    font-family: inherit;
    line-height: 1.25rem;
}

.ui-fiche-tag-button > .bi {
    flex-shrink: 0;
    font-size: 0.625rem;
    color: var(--bs-secondary-color);
}

.ui-fiche-tag-button:hover {
    border-color: var(--ui-fiche, var(--bs-secondary));
    background-color: color-mix(in srgb, var(--ui-fiche, var(--bs-secondary)) 18%, transparent);
}

.ui-fiche-tag-button:focus-visible {
    outline: 0;
    box-shadow: var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color);
}

/* Edge bar in the tone of the fiche, on the left of a row or a card */
.ui-fiche-edge {
    position: relative;
}

.ui-fiche-edge::before {
    content: "";
    position: absolute;
    top: 0.375rem;
    bottom: 0.375rem;
    left: 0.1875rem;
    width: 0.1875rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--ui-fiche, var(--bs-secondary));
    pointer-events: none;
}

/* Synchronisation state of a form that keeps working offline: a ghost button (opening a
   dropdown panel with the details) whose icon takes the tone of the state, always with a
   label and the number of entries waiting to be sent, never colour alone.
   data-ui-sync: synced (bi-cloud-check) | pending (bi-cloud-arrow-up) | sending (bi-arrow-repeat,
   turns) | offline (bi-wifi-off) | warning (bi-exclamation-triangle) | error (bi-exclamation-octagon).
   The attribute also tones any .ui-sync-icon inside another container (e.g. the panel header).
   <button class="btn btn-ghost btn-sm ui-sync" data-ui-sync="offline">
       <i class="bi bi-wifi-off ui-sync-icon"></i><span class="ui-sync-label">Hors ligne</span>
       <span class="ui-sync-count">3<span class="visually-hidden"> saisies en attente</span></span>
   </button> */
[data-ui-sync] { --ui-sync-tone: var(--bs-secondary-color); }
[data-ui-sync="synced"] { --ui-sync-tone: var(--ui-status-done); }
[data-ui-sync="pending"],
[data-ui-sync="sending"] { --ui-sync-tone: var(--ui-status-progress); }
[data-ui-sync="offline"],
[data-ui-sync="warning"] { --ui-sync-tone: var(--ui-status-fix); }
[data-ui-sync="error"] { --ui-sync-tone: var(--bs-danger); }

.ui-sync {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.ui-sync-icon {
    display: inline-block;
    color: var(--ui-sync-tone, var(--bs-secondary-color));
}

[data-ui-sync="sending"] .ui-sync-icon {
    animation: ui-sync-turn 1s linear infinite;
}

@keyframes ui-sync-turn {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    [data-ui-sync="sending"] .ui-sync-icon { animation: none; }
}

.ui-sync-count {
    min-width: 1.25rem;
    padding: 0 0.375rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: color-mix(in srgb, var(--ui-sync-tone, var(--bs-secondary-color)) 16%, var(--bs-body-bg));
    color: var(--bs-emphasis-color);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-align: center;
}

/* Filter steps: a row of separate, checkable rounded tiles (e.g. the demande journey).
   Neutral surface; only the icon carries the tone. A checked tile gets a tinted
   background, a tone ring and a check mark (never colour alone).
   <div class="ui-filter-steps" role="group" aria-label="Étape">
       <input type="checkbox" class="btn-check" id="s1">
       <label class="ui-filter-step ui-filter-step-success" for="s1">
           <span class="ui-filter-step-icon"><i class="bi bi-file-earmark-pdf"></i></span>
           <span class="ui-filter-step-body"><strong>12</strong><small>Rapports émis</small></span>
           <i class="bi bi-check-circle-fill ui-filter-step-check"></i>
       </label>
       …
   </div> */
.ui-filter-steps {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 0.5rem;
}

@media (max-width: 767.98px) {
    .ui-filter-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
    }
}

.ui-filter-step {
    --ui-filter-rgb: var(--bs-primary-rgb);
    --ui-filter-ink: var(--bs-primary-text-emphasis);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.ui-filter-step:hover {
    background-color: var(--ui-hover);
}

.btn-check:checked + .ui-filter-step {
    background-color: rgba(var(--ui-filter-rgb), 0.1);
}

/* Tiles: a lone step, a stacked step and a step column each stand as their own tile */
.ui-filter-steps > .ui-filter-step,
.ui-filter-step-stack > .ui-filter-step,
.ui-filter-steps > .ui-filter-step-group:not(.ui-filter-step-stack) {
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-input-bg);
    box-shadow: inset 0 0 0 1px var(--bs-border-color-translucent), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ui-filter-steps > .ui-filter-step {
    padding: 0.625rem 0.75rem;
}

.ui-filter-steps > .ui-filter-step:hover,
.ui-filter-step-stack > .ui-filter-step:hover {
    background-color: color-mix(in srgb, var(--ui-input-bg), rgb(var(--bs-emphasis-color-rgb)) 4%);
}

.ui-filter-steps > .btn-check:checked + .ui-filter-step,
.ui-filter-step-stack > .btn-check:checked + .ui-filter-step,
.ui-filter-steps > .ui-filter-step-group:not(.ui-filter-step-stack):has(> .btn-check:checked) {
    background-color: rgba(var(--ui-filter-rgb), 0.1);
    box-shadow: inset 0 0 0 1.5px rgba(var(--ui-filter-rgb), 0.45);
}

.ui-filter-steps > .btn-check:focus-visible + .ui-filter-step,
.ui-filter-step-stack > .btn-check:focus-visible + .ui-filter-step,
.btn-check:focus-visible + .ui-filter-step {
    z-index: 1;
    box-shadow: var(--ui-focus-ring);
}

.ui-filter-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: var(--bs-border-radius);
    background-color: rgba(var(--ui-filter-rgb), 0.12);
    color: var(--ui-filter-ink);
    font-size: 1rem;
}

.ui-filter-step-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.ui-filter-step-body > strong {
    color: var(--bs-emphasis-color);
    font-size: 1.0625rem;
    font-variant-numeric: tabular-nums;
}

.ui-filter-step-body > small {
    overflow: hidden;
    color: var(--bs-secondary-color);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-check:checked + .ui-filter-step .ui-filter-step-icon {
    background-color: rgba(var(--ui-filter-rgb), 0.2);
}

.btn-check:checked + .ui-filter-step .ui-filter-step-body > small {
    color: var(--ui-filter-ink);
    font-weight: 500;
}

/* Selection mark: an empty ring says "selectable", the filled check says "selected" */
.ui-filter-step-check {
    display: inline-flex;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bs-secondary-color) 55%, transparent);
    color: transparent;
    line-height: 1;
}

.ui-filter-step-check::before {
    vertical-align: 0;
}

.btn-check:checked + .ui-filter-step .ui-filter-step-check {
    box-shadow: none;
    color: rgb(var(--ui-filter-rgb));
}

/* Compact bar for narrow cards: smaller icon tile and padding, same reading order */
.ui-filter-steps-sm .ui-filter-step {
    gap: 0.375rem;
    padding: 0.4375rem 0.5rem;
}

.ui-filter-steps-sm .ui-filter-step-icon {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.875rem;
}

/* Grouped filter steps: each step heads a column listing its work queues, so a queue is
   read under the step it belongs to. The column carries the step tone; queue icons take it,
   a checked queue gets a tint and a check mark instead of its icon (never colour alone).
   Steps and queues stay separate checkboxes. Columns stack on small screens.
   <div class="ui-filter-steps ui-filter-steps-grouped" role="group" aria-label="Étapes">
       <div class="ui-filter-step-group ui-filter-step-warning">
           <input type="checkbox" class="btn-check" id="s2">
           <label class="ui-filter-step ui-filter-step-warning" for="s2">…</label>
           <div class="ui-filter-queues" role="group" aria-label="Files : RDV à planifier">
               <input type="checkbox" class="btn-check" id="q1">
               <label class="ui-filter-queue" for="q1">
                   <i class="bi bi-calendar-plus ui-filter-queue-icon"></i><i class="bi bi-check-lg ui-filter-queue-check"></i>
                   <span class="ui-filter-queue-label">À placer</span><span class="ui-filter-queue-count">12</span>
               </label>
           </div>
       </div>
       …
   </div> */
.ui-filter-steps-grouped {
    --ui-filter-queue-pad: 0.5rem;
    --ui-filter-queue-icon: 2rem;
    --ui-filter-queue-gap: 0.625rem;
}

.ui-filter-steps-grouped.ui-filter-steps-sm {
    --ui-filter-queue-pad: 0.25rem;
    --ui-filter-queue-icon: 1.5rem;
    --ui-filter-queue-gap: 0.375rem;
}

.ui-filter-step-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* In a column the step is the tile header: rounded on top, tinted over the column tint */
.ui-filter-step-group:not(.ui-filter-step-stack) > .ui-filter-step {
    border-radius: calc(var(--bs-border-radius-lg) - 1px) calc(var(--bs-border-radius-lg) - 1px) 0 0;
}

.ui-filter-step-group:not(.ui-filter-step-stack) > .ui-filter-step:only-of-type:last-child {
    border-radius: calc(var(--bs-border-radius-lg) - 1px);
}

.ui-filter-step-group:not(.ui-filter-step-stack) > .btn-check:checked + .ui-filter-step {
    background-color: rgba(var(--ui-filter-rgb), 0.08);
}

/* Only the filled check is shown: the queues below already make the column read as a filter */
.ui-filter-steps-grouped .ui-filter-step-check {
    box-shadow: none;
}

/* Steps without queues (none authorised or none pending) share one column when another step
   has queues: their tiles stack and split its height, so no column is left blank.
   <div class="ui-filter-step-group ui-filter-step-stack"> btn-check + ui-filter-step, … </div> */
.ui-filter-step-stack {
    gap: 0.5rem;
}

.ui-filter-step-stack > .ui-filter-step {
    flex: 1 1 0;
}

@media (max-width: 767.98px) {
    .ui-filter-steps-grouped {
        grid-template-columns: minmax(0, 1fr);
    }
}

.ui-filter-queues {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1px;
    padding: 0.25rem;
    border-top: 1px solid var(--bs-border-color-translucent);
}

.ui-filter-queue {
    display: flex;
    align-items: center;
    gap: var(--ui-filter-queue-gap);
    min-width: 0;
    padding: 0.1875rem var(--ui-filter-queue-pad);
    /* Inner radius follows the tile: tile radius minus the queue list padding */
    border-radius: calc(var(--bs-border-radius-lg) - 0.25rem);
    color: var(--bs-body-color);
    font-size: 0.875rem;
    line-height: 1.25;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.ui-filter-queue:hover {
    background-color: var(--ui-hover);
}

.btn-check:checked + .ui-filter-queue {
    background-color: rgba(var(--ui-filter-rgb), 0.1);
    color: var(--ui-filter-ink);
    font-weight: 500;
}

.btn-check:focus-visible + .ui-filter-queue {
    box-shadow: var(--ui-focus-ring);
}

.ui-filter-queue-icon,
.ui-filter-queue-check {
    flex-shrink: 0;
    width: var(--ui-filter-queue-icon);
    color: var(--ui-filter-ink);
    text-align: center;
}

.ui-filter-queue-check,
.btn-check:checked + .ui-filter-queue .ui-filter-queue-icon {
    display: none;
}

.btn-check:checked + .ui-filter-queue .ui-filter-queue-check {
    display: inline-block;
}

/* A checked column already reads as selected as a whole: its queues stay unmarked */
.ui-filter-step-group:has(> .btn-check:checked) .btn-check:checked + .ui-filter-queue {
    color: var(--bs-body-color);
    font-weight: inherit;
}

.ui-filter-step-group:has(> .btn-check:checked) .btn-check:checked + .ui-filter-queue:not(:hover) {
    background-color: transparent;
}

.ui-filter-step-group:has(> .btn-check:checked) .btn-check:checked + .ui-filter-queue .ui-filter-queue-icon {
    display: inline-block;
}

.ui-filter-step-group:has(> .btn-check:checked) .btn-check:checked + .ui-filter-queue .ui-filter-queue-check {
    display: none;
}

.ui-filter-queue-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-filter-queue-count {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

.btn-check:checked + .ui-filter-queue .ui-filter-queue-count {
    color: var(--ui-filter-ink);
}

.ui-filter-step-group:has(> .btn-check:checked) .btn-check:checked + .ui-filter-queue .ui-filter-queue-count {
    color: var(--bs-secondary-color);
}

.ui-filter-step-primary { --ui-filter-rgb: var(--bs-primary-rgb); --ui-filter-ink: var(--bs-primary-text-emphasis); }
.ui-filter-step-info { --ui-filter-rgb: var(--bs-info-rgb); --ui-filter-ink: var(--bs-info-text-emphasis); }
.ui-filter-step-success { --ui-filter-rgb: var(--bs-success-rgb); --ui-filter-ink: var(--bs-success-text-emphasis); }
.ui-filter-step-warning { --ui-filter-rgb: var(--bs-warning-rgb); --ui-filter-ink: var(--bs-warning-text-emphasis); }
.ui-filter-step-danger { --ui-filter-rgb: var(--bs-danger-rgb); --ui-filter-ink: var(--bs-danger-text-emphasis); }
.ui-filter-step-secondary { --ui-filter-rgb: var(--bs-secondary-rgb); --ui-filter-ink: var(--bs-secondary-text-emphasis); }

/* Colour choice (e.g. a binder's colour): round swatches on btn-check radios, one class per
   kit tone. Each swatch has a text label (visually hidden) and a title; the selected one
   shows a check mark and an outer ring, so the choice never relies on colour alone.
   <input type="radio" class="btn-check" name="color" id="c1" checked>
   <label class="ui-color-option ui-color-option-success" for="c1" title="Vert">
       <i class="bi bi-check-lg"></i><span class="visually-hidden">Vert</span>
   </label> */
.ui-color-option {
    --ui-color-option: var(--bs-primary);
    --ui-color-option-ink: var(--ui-on-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: var(--ui-color-option);
    box-shadow: inset 0 0 0 1px rgba(var(--bs-emphasis-color-rgb), 0.12);
    color: var(--ui-color-option-ink);
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

.ui-color-option > .bi {
    display: none;
    font-size: 0.875rem;
}

.btn-check:checked + .ui-color-option {
    box-shadow: 0 0 0 2px var(--bs-body-bg), 0 0 0 4px var(--ui-color-option);
}

.btn-check:checked + .ui-color-option > .bi {
    display: inline-block;
}

.btn-check:focus-visible + .ui-color-option {
    box-shadow: 0 0 0 2px var(--bs-body-bg), var(--ui-focus-ring);
}

.ui-color-option-primary { --ui-color-option: var(--bs-primary); --ui-color-option-ink: var(--ui-on-primary); }
.ui-color-option-info { --ui-color-option: var(--bs-info); --ui-color-option-ink: var(--ui-on-info); }
.ui-color-option-success { --ui-color-option: var(--bs-success); --ui-color-option-ink: var(--ui-on-success); }
.ui-color-option-warning { --ui-color-option: var(--bs-warning); --ui-color-option-ink: var(--ui-on-warning); }
.ui-color-option-danger { --ui-color-option: var(--bs-danger); --ui-color-option-ink: var(--ui-on-danger); }
.ui-color-option-secondary { --ui-color-option: var(--bs-secondary); --ui-color-option-ink: var(--ui-on-secondary); }

/* Choice toggle (a form's radio or checkbox options shown as buttons): btn-check +
   .btn-outline-secondary.ui-choice. The optional --ui-choice-color tints the whole button;
   the selection mark (empty ring, then a filled check) keeps its state explicit.
   <input type="radio" class="btn-check" name="c" id="c1">
   <label class="btn btn-outline-secondary ui-choice" for="c1" style="--ui-choice-color: #1e7a46">
       <i class="bi bi-check-circle-fill ui-choice-mark"></i>
       <span>Conforme</span>
   </label> */
.ui-choice {
    --bs-btn-bg: color-mix(in srgb, var(--ui-choice-color, transparent) 14%, var(--ui-input-bg));
    --bs-btn-border-color: color-mix(in srgb, var(--ui-choice-color, transparent) 30%, var(--ui-input-border));
    --bs-btn-hover-bg: color-mix(in srgb, var(--ui-choice-color, transparent) 22%, var(--ui-input-bg-focus));
    --bs-btn-hover-border-color: var(--bs-btn-border-color);
    --bs-btn-disabled-bg: var(--bs-btn-bg);
    --bs-btn-disabled-border-color: var(--bs-btn-border-color);
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    text-align: start;
}

.btn-check:checked + .ui-choice,
.btn-check:active + .ui-choice {
    --bs-btn-active-bg: color-mix(in srgb, var(--ui-choice-color, transparent) 28%, var(--ui-active));
    --bs-btn-active-border-color: color-mix(in srgb, var(--ui-choice-color, transparent) 65%, var(--ui-input-border));
}

.ui-choice-mark {
    display: inline-flex;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bs-secondary-color) 55%, transparent);
    color: transparent;
    line-height: 1;
}

.ui-choice-mark::before {
    vertical-align: 0;
}

.btn-check:checked + .ui-choice .ui-choice-mark {
    box-shadow: none;
    color: var(--bs-emphasis-color);
}

/* Several answers can be ticked: square mark (bi-check-square-fill) instead of the ring. */
.ui-choice-mark-square {
    border-radius: 0.2em;
}

/* Dropzone & file list */
.ui-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    border: 1.5px dashed var(--ui-input-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-input-bg);
    color: var(--bs-secondary-color);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ui-dropzone:hover,
.ui-dropzone.is-dragover {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary-bg-subtle);
}

.ui-dropzone:focus-within {
    box-shadow: var(--ui-focus-ring);
}

.ui-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
}

.ui-file + .ui-file {
    margin-top: 0.5rem;
}

.ui-file-body {
    flex: 1 1 auto;
    min-width: 0;
}

/* Image preview in a file row, in place of its icon tile */
.ui-file-thumb {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: var(--bs-border-radius);
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--bs-border-color);
}

.ui-file-name {
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: 0.5rem;
}

.ui-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-active);
    box-shadow: inset 0 0 0 1px var(--bs-border-color);
}

.ui-thumb > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ui-thumb > .badge {
    position: absolute;
    bottom: 0.375rem;
    left: 0.375rem;
}

/* File gallery: larger square tiles, each a .ui-thumb-card (tile + caption).
   Inside the tile, .ui-thumb-link opens the preview over the whole surface;
   the checkbox, menu and status badges sit on top of it. */
.ui-thumbs-lg {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}

@media (max-width: 575.98px) {
    .ui-thumbs-lg {
        grid-template-columns: repeat(auto-fill, minmax(6.25rem, 1fr));
    }
}

.ui-thumbs-lg .ui-thumb {
    aspect-ratio: 1;
}

/* The tile lets its menu overflow; the link clips the image to the rounded corners */
.ui-thumb-card > .ui-thumb {
    overflow: visible;
}

.ui-thumb-card {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.ui-thumb-link {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: inherit;
}

.ui-thumb-link > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ui-thumb-link:focus-visible {
    outline: 0;
    box-shadow: inset 0 0 0 2px var(--bs-primary);
}

/* A file left out (e.g. of the PDF) fades; its badge says why */
.ui-thumb-card.is-excluded .ui-thumb-link > img {
    opacity: 0.45;
    filter: grayscale(1);
}

.ui-thumb > .ui-thumb-check {
    position: absolute;
    top: 0.375rem;
    left: 0.375rem;
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    box-shadow: 0 0 0 2px var(--bs-body-bg);
}

/* Pick one photo: the whole tile is the label of its radio; the chosen one is outlined
   on top of the checked mark (not colour alone) */
.ui-thumb-pick {
    cursor: pointer;
}

.ui-thumb-pick:has(> .ui-thumb-check:checked) {
    outline: 3px solid var(--bs-primary);
    outline-offset: -3px;
}

.ui-thumb-pick:has(> .ui-thumb-check:focus-visible) {
    box-shadow: 0 0 0 2px var(--bs-body-bg), 0 0 0 4px var(--bs-primary);
}

.ui-thumb > .ui-thumb-menu {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
}

.ui-thumb-menu > .btn {
    background-color: var(--bs-body-bg);
    box-shadow: var(--bs-box-shadow-sm);
}

/* Status badges on a tile: stacked bottom-left, opaque so they read on any image */
.ui-thumb-badges {
    position: absolute;
    bottom: 0.375rem;
    left: 0.375rem;
    right: 0.375rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    pointer-events: none;
}

.ui-thumb-badges > .badge {
    max-width: 100%;
    overflow: hidden;
    background-color: var(--bs-body-bg) !important;
    box-shadow: var(--bs-box-shadow-sm);
    text-overflow: ellipsis;
}

/* Phone-sized tiles: badges shrink to icon chips (distinct shapes), the word stays for screen readers */
.ui-thumbs-lg .ui-thumb {
    container-type: inline-size;
}

@container (max-width: 8.5rem) {
    .ui-thumb-badges {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .ui-thumb-badge-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

.ui-thumb-caption {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    min-width: 0;
    font-size: 0.8125rem;
}

.ui-thumb-caption > .ui-file-name {
    flex: 1 1 auto;
}

/* "Add" tile closing a file gallery */
.ui-thumbs-lg .ui-dropzone.ui-thumb {
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem;
    font-size: 0.8125rem;
}

/* Signature pad */
.ui-signature {
    position: relative;
    height: 11rem;
    border: 1px solid var(--ui-input-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    box-shadow: var(--ui-control-highlight);
    touch-action: none;
}

.ui-signature::after {
    content: "";
    position: absolute;
    right: 1.5rem;
    bottom: 2.25rem;
    left: 1.5rem;
    border-bottom: 1px dashed var(--ui-input-border);
    pointer-events: none;
}

.ui-signature > canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Square pad for a fixed square canvas (e.g. 500 × 500 report signatures) so strokes keep their ratio */
.ui-signature-square {
    width: 100%;
    max-width: 31.25rem;
    height: auto;
    aspect-ratio: 1 / 1;
}

.ui-signature-hint {
    position: absolute;
    bottom: 0.75rem;
    left: 1.5rem;
    color: var(--bs-tertiary-color);
    font-size: 0.75rem;
    pointer-events: none;
}

/* Pad and preview of a stored signature: black ink on a transparent PNG, so the paper stays white in dark mode
   (pair with data-bs-theme="light" so the hint and guide keep their light colours) */
.ui-signature-paper,
.ui-signature-preview {
    background-color: #fff;
}

.ui-signature-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.ui-signature-preview > img {
    display: block;
    max-width: 100%;
    height: 9rem;
    object-fit: contain;
}

/* Chat */
.ui-chat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
}

.ui-chat-day {
    margin: 0.5rem 0;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

/* Divider naming what follows in the thread (e.g. the form a run of messages edits): a line on each
   side of an icon and a label (never colour alone), with an optional link to go there.
   <div class="ui-chat-day ui-chat-divider"><span class="ui-chat-divider-label"><i class="bi bi-file-earmark-text"></i>Rapport</span><a class="ui-chat-divider-link" href="#">Y aller</a></div> */
.ui-chat-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.ui-chat-divider::before,
.ui-chat-divider::after {
    content: "";
    flex: 1 1 0;
    min-width: 1rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-chat-divider-label {
    min-width: 0;
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-chat-divider-label > .bi {
    margin-right: 0.375rem;
    color: var(--bs-secondary-color);
}

.ui-chat-divider-link {
    flex-shrink: 0;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.ui-chat-divider-link:hover,
.ui-chat-divider-link:focus-visible {
    text-decoration: underline;
}

.ui-message {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 75%;
}

.ui-message-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: var(--bs-border-radius-lg);
    border-bottom-left-radius: var(--bs-border-radius-sm);
    border: 1px solid color-mix(in srgb, var(--bs-info) 25%, var(--bs-body-bg));
    background-color: color-mix(in srgb, var(--bs-info) 10%, var(--bs-body-bg));
    color: var(--bs-emphasis-color);
}

.ui-message-meta {
    margin-top: 0.125rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.ui-message.is-mine {
    flex-direction: row-reverse;
    align-self: flex-end;
    text-align: right;
}

.ui-message.is-mine .ui-message-bubble {
    border-bottom-right-radius: var(--bs-border-radius-sm);
    border-bottom-left-radius: var(--bs-border-radius-lg);
    border-color: color-mix(in srgb, var(--bs-primary) 45%, var(--bs-body-bg));
    background-color: color-mix(in srgb, var(--bs-primary) 22%, var(--bs-body-bg));
    color: var(--bs-emphasis-color);
    text-align: left;
}

/* Hover preview card: floats beside a list row, same glass as the sidebar flyout.
   Read-only and pointer-transparent, so it never steals the hover from the list. */
.ui-peek {
    position: fixed;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    width: 22rem;
    max-height: min(24rem, calc(100vh - 1rem));
    overflow: hidden;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--bs-box-shadow-lg);
    pointer-events: none;
    animation: ui-nav-panel-in 0.16s ease-out;
}

.ui-peek[hidden] {
    display: none;
}

.ui-peek-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem 0.5rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.ui-peek-title {
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
}

.ui-peek-header > .badge {
    margin-left: auto;
}

/* Latest messages stay in view: the body is anchored to its bottom edge. */
.ui-peek-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.5rem;
    min-height: 0;
    overflow: hidden;
    padding: 0.625rem 0.875rem;
}

.ui-peek-message {
    flex-shrink: 0;
}

.ui-peek-text {
    display: -webkit-box;
    overflow: hidden;
    color: var(--bs-body-color);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
    white-space: pre-line;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.ui-peek-footer {
    padding: 0.375rem 0.875rem;
    border-top: 1px solid var(--bs-border-color-translucent);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.ui-message-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* @mention inside a message; the reader's own mention, and the bubble that holds it, stand out */
.ui-mention {
    padding: 0 0.3em;
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
}

.ui-mention.is-me {
    background-color: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
    box-shadow: inset 0 0 0 1px var(--bs-warning-border-subtle);
}

.ui-message.is-mentioned .ui-message-bubble {
    border-color: var(--bs-warning-border-subtle);
    box-shadow: inset 3px 0 0 var(--bs-warning);
}

/* Quoted message a reply refers to, inside the bubble */
.ui-message-quote {
    margin-bottom: 0.375rem;
    padding-left: 0.5rem;
    border-left: 3px solid currentColor;
    color: var(--bs-secondary-text-emphasis);
    font-size: 0.8125rem;
}

/* Recorded action in a thread (call without answer, reopening…): tinted bubble by tone;
   an icon and a label (.ui-message-event) always carry the meaning, not the colour alone */
.ui-message .ui-message-bubble[class*="ui-message-bubble-"] {
    border: 1px solid var(--ui-message-tone-border);
    background: linear-gradient(var(--ui-message-tone-bg), var(--ui-message-tone-bg)), var(--bs-body-bg);
    color: var(--bs-emphasis-color);
}

.ui-message-bubble-primary {
    --ui-message-tone-bg: var(--bs-primary-bg-subtle);
    --ui-message-tone-border: var(--bs-primary-border-subtle);
    --ui-message-tone-text: var(--bs-primary-text-emphasis);
}

.ui-message-bubble-success {
    --ui-message-tone-bg: var(--bs-success-bg-subtle);
    --ui-message-tone-border: var(--bs-success-border-subtle);
    --ui-message-tone-text: var(--bs-success-text-emphasis);
}

.ui-message-bubble-info {
    --ui-message-tone-bg: var(--bs-info-bg-subtle);
    --ui-message-tone-border: var(--bs-info-border-subtle);
    --ui-message-tone-text: var(--bs-info-text-emphasis);
}

.ui-message-bubble-warning {
    --ui-message-tone-bg: var(--bs-warning-bg-subtle);
    --ui-message-tone-border: var(--bs-warning-border-subtle);
    --ui-message-tone-text: var(--bs-warning-text-emphasis);
}

.ui-message-bubble-danger {
    --ui-message-tone-bg: var(--bs-danger-bg-subtle);
    --ui-message-tone-border: var(--bs-danger-border-subtle);
    --ui-message-tone-text: var(--bs-danger-text-emphasis);
}

.ui-message-event {
    color: var(--ui-message-tone-text, inherit);
}

/* Reactions under a bubble, aligned with it */
.ui-message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.ui-message.is-mine .ui-message-reactions {
    justify-content: flex-end;
}

.ui-chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-chat-composer > .form-control {
    resize: none;
}

/* Assistant answer (AI working on the page): the bubble may span the thread
   (.ui-message-wide) and holds the steps it went through, its text, then a
   card of the changes it made. Steps and changes carry an icon and a
   sentence each; a failed step adds the error text, never colour alone. */
.ui-message.ui-message-wide {
    max-width: 100%;
}

.ui-message-wide > .min-w-0 {
    flex: 1 1 auto;
}

.ui-agent-steps {
    margin-bottom: 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
}

.ui-agent-steps > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    list-style: none;
}

.ui-agent-steps > summary::-webkit-details-marker {
    display: none;
}

.ui-agent-steps > summary::after {
    content: "\F282"; /* bi-chevron-down */
    font-family: bootstrap-icons;
    font-size: 0.6875rem;
    transition: transform 0.15s ease;
}

.ui-agent-steps[open] > summary::after {
    transform: rotate(180deg);
}

.ui-agent-steps-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.375rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-tertiary-bg);
}

.ui-agent-steps-count.is-write {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

.ui-agent-steps-count.is-error {
    background-color: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

/* Trace of the tools run, like a terminal agent: dot + action + target, then "⎿ outcome" */
.ui-agent-trace {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.ui-agent-call {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-width: 0;
}

/* Thin rail linking the steps */
.ui-agent-call:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 1.25rem;
    bottom: -0.375rem;
    left: 0.5625rem;
    border-left: 1px solid var(--bs-border-color);
}

.ui-agent-call-dot {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.0625rem;
    border-radius: 50%;
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.6875rem;
}

.ui-agent-call-dot .spinner-border {
    --bs-spinner-width: 0.75rem;
    --bs-spinner-height: 0.75rem;
    --bs-spinner-border-width: 0.125em;
}

.ui-agent-call.is-write .ui-agent-call-dot {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

.ui-agent-call.is-error .ui-agent-call-dot {
    background-color: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

.ui-agent-call-body {
    flex: 1 1 auto;
    min-width: 0;
}

.ui-agent-call-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.375rem;
    line-height: 1.25rem;
}

.ui-agent-call-title {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-agent-call-target {
    min-width: 0;
    color: var(--bs-body-color);
    overflow-wrap: anywhere;
}

.ui-agent-call-time {
    margin-left: auto;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ui-agent-call-result {
    display: flex;
    gap: 0.375rem;
    color: var(--bs-secondary-color);
    overflow-wrap: anywhere;
}

.ui-agent-call-elbow {
    flex-shrink: 0;
    font-family: var(--bs-font-monospace);
    line-height: 1.25rem;
}

.ui-agent-call.is-error .ui-agent-call-result {
    color: var(--bs-danger-text-emphasis);
}

.ui-agent-call-items {
    margin: 0.125rem 0 0;
    padding-left: 1rem;
}

.ui-agent-call.is-note .ui-agent-call-body {
    color: var(--bs-body-color);
    font-style: italic;
}

.ui-agent-changes {
    margin-top: 0.5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-surface-raised, var(--bs-body-bg));
    font-size: 0.875rem;
}

.ui-agent-changes-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-changes-title {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

/* Control point tree shown by the assistant: the header may wrap in a narrow chat, the outline
   scrolls inside the card so a big form does not stretch the conversation. */
.ui-agent-tree .ui-agent-changes-header {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}

.ui-agent-tree-summary {
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ui-agent-tree-body {
    max-height: 26rem;
    padding: 0.25rem 0.375rem;
    overflow: auto;
}

.ui-agent-tree-empty {
    margin: 0;
    padding: 0.5rem 0.75rem;
    color: var(--bs-secondary-color);
}

/* Changes listed as a diff: a mark per line (+ − ↕ ~), never colour alone */
.ui-agent-diff {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.ui-agent-diff-action {
    margin-bottom: 0.125rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
}

.ui-agent-diff-line {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--bs-border-radius-sm);
    overflow-wrap: anywhere;
}

.ui-agent-diff-line > .bi {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
}

.ui-agent-diff-line strong {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-agent-diff-mark {
    flex-shrink: 0;
    width: 0.75rem;
    font-family: var(--bs-font-monospace);
    font-weight: 700;
    text-align: center;
}

.ui-agent-diff-line.is-add {
    background-color: color-mix(in srgb, var(--bs-success) 9%, transparent);
}

.ui-agent-diff-line.is-add .ui-agent-diff-mark,
.ui-agent-diff-totals .is-add {
    color: var(--bs-success-text-emphasis);
}

.ui-agent-diff-line.is-remove {
    background-color: color-mix(in srgb, var(--bs-danger) 9%, transparent);
}

.ui-agent-diff-line.is-remove .ui-agent-diff-mark,
.ui-agent-diff-totals .is-remove {
    color: var(--bs-danger-text-emphasis);
}

.ui-agent-diff-line.is-move .ui-agent-diff-mark,
.ui-agent-diff-totals .is-move {
    color: var(--bs-info-text-emphasis);
}

.ui-agent-diff-line.is-edit .ui-agent-diff-mark,
.ui-agent-diff-totals .is-edit {
    color: var(--bs-warning-text-emphasis);
}

.ui-agent-diff-totals {
    display: inline-flex;
    gap: 0.5rem;
    font-family: var(--bs-font-monospace);
    font-size: 0.75rem;
    font-weight: 600;
}

.ui-agent-changes-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--bs-border-color-translucent);
}

/* Undone changes stay listed, struck through, next to their "Annulées" badge */
.ui-agent-changes.is-undone .ui-agent-diff {
    color: var(--bs-secondary-color);
    text-decoration: line-through;
}

.ui-agent-changes.is-undone .ui-agent-diff-line {
    background-color: transparent;
}

/* Question closing an answer: last, framed, with the points it is about and its clickable answers */
.ui-agent-question {
    margin-top: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--bs-primary-border-subtle);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--bs-primary-bg-subtle);
    font-size: 0.875rem;
}

.ui-agent-question-title {
    display: flex;
    gap: 0.5rem;
    margin: 0;
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-agent-question-title > .bi {
    flex-shrink: 0;
    color: var(--bs-primary-text-emphasis);
}

.ui-agent-question-points {
    margin: 0.5rem 0 0;
    padding: 0.375rem 0.625rem 0.375rem 1.75rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-surface-raised, var(--bs-body-bg));
    overflow-wrap: anywhere;
}

.ui-agent-question-points li + li {
    margin-top: 0.25rem;
}

.ui-agent-question-points strong {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-agent-question-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.625rem;
}

.ui-agent-question-options .btn {
    background-color: var(--bs-body-bg);
}

.ui-agent-question-options .btn:hover {
    background-color: var(--bs-btn-hover-bg);
}

/* Free answer when none of the proposed ones fits: a quiet button that opens a field in place of the options */
.ui-agent-question-options .ui-agent-question-other {
    border: 1px dashed var(--bs-border-color);
    background-color: transparent;
    color: var(--bs-secondary-color);
}

.ui-agent-question-options .ui-agent-question-other:hover {
    border-color: var(--bs-primary-border-subtle);
    background-color: var(--bs-body-bg);
    color: var(--bs-emphasis-color);
}

.ui-agent-question-own {
    display: flex;
    flex: 1 1 100%;
    gap: 0.25rem;
    align-items: center;
    padding: 0.1875rem 0.1875rem 0.1875rem 0.25rem;
    border: 1px solid var(--bs-primary-border-subtle);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--bs-body-bg);
}

.ui-agent-question-own:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

.ui-agent-question-own .form-control {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.25rem 0.375rem;
    border: 0;
    background-color: transparent;
    box-shadow: none;
    font-size: inherit;
}

.ui-agent-question-options .ui-agent-question-own .btn {
    flex-shrink: 0;
    background-color: var(--bs-btn-bg);
}

.ui-agent-question-options .ui-agent-question-own .btn:hover {
    background-color: var(--bs-btn-hover-bg);
}

/* An answered question stays readable but no longer calls for attention */
.ui-agent-question.is-answered {
    border-color: var(--bs-border-color);
    background-color: transparent;
}

.ui-agent-question.is-answered .ui-agent-question-title > .bi {
    color: var(--bs-secondary-color);
}

/* Question asked on another form: where it is answered instead of the options */
.ui-agent-question-elsewhere {
    align-items: center;
}

.ui-agent-question-where {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--bs-body-color);
}

.ui-agent-question-elsewhere > .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.ui-agent-question-where > .bi {
    color: var(--bs-primary-text-emphasis);
}

/* Time, tokens and price under an answer */
.ui-agent-usage {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-top: 0.375rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.ui-agent-usage-cost {
    color: var(--bs-body-color);
    font-weight: 600;
}

.ui-agent-usage-total {
    margin-left: auto;
}

.ui-agent-cost {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Past conversations with an agent, in a header dropdown: open one (title + meta), or delete it.
   The open one is marked by a filled icon and a written "Ouverte", not by colour alone. */
.ui-agent-history {
    width: min(24rem, calc(100vw - 2rem));
    max-height: min(26rem, 70vh);
    overflow-y: auto;
}

.ui-agent-history-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.5rem;
}

.ui-agent-history-item > .dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
}

.ui-agent-history-item > .dropdown-item > .bi {
    margin-top: 0.125rem;
    color: var(--bs-secondary-color);
}

.ui-agent-history-item.is-current > .dropdown-item {
    background-color: var(--bs-tertiary-bg);
}

.ui-agent-history-item.is-current > .dropdown-item > .bi {
    color: var(--bs-primary);
}

.ui-agent-history-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

/* Title row of a conversation with its status disc (running, finished…) after the title */
.ui-agent-history-head {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.ui-agent-history-head > .ui-agent-history-title {
    flex: 0 1 auto;
    min-width: 0;
}

.ui-agent-history-meta {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.ui-agent-history-item > .btn {
    flex-shrink: 0;
}

/* Web pages an answer cites: numbered, title as the link, site after it */
.ui-agent-sources {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color-translucent);
    font-size: 0.8125rem;
}
.ui-agent-sources-title {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
    color: var(--bs-secondary-color);
    font-weight: 600;
}
.ui-agent-sources ol {
    margin: 0;
    padding-left: 1.25rem;
}
.ui-agent-sources li + li {
    margin-top: 0.125rem;
}
.ui-agent-sources a {
    overflow-wrap: anywhere;
}
.ui-agent-source-site {
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

/* Markdown of an answer: compact headings, tables and code inside the bubble */
.ui-agent-answer {
    min-width: 0;
    line-height: 1.55;
}

.ui-agent-answer table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--bs-body-bg);
    font-size: 0.8125rem;
}

.ui-agent-answer th,
.ui-agent-answer td {
    padding: 0.3125rem 0.625rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
    vertical-align: top;
}

.ui-agent-answer th {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-emphasis-color);
    font-weight: 600;
    white-space: nowrap;
}

.ui-agent-answer tr:last-child td {
    border-bottom: 0;
}

.ui-agent-answer td + td,
.ui-agent-answer th + th {
    border-left: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-answer code {
    padding: 0.0625rem 0.3125rem;
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-emphasis-color);
    font-size: 0.8125em;
}

.ui-agent-answer pre {
    padding: 0.5rem 0.75rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-tertiary-bg);
    font-size: 0.8125rem;
}

.ui-agent-answer pre code {
    padding: 0;
    background: none;
}

.ui-agent-answer hr {
    margin: 0.75rem 0;
}

.ui-agent-answer strong {
    color: var(--bs-emphasis-color);
}

/* Wider side panels (assistant, long threads); .ui-offcanvas-xl when enlarged */
.offcanvas.ui-offcanvas-wide {
    --bs-offcanvas-width: 46rem;
}

.offcanvas.ui-offcanvas-wide.ui-offcanvas-xl {
    --bs-offcanvas-width: 72rem;
}

/* Full-screen agent workspace: conversations (search, list) | chat | live preview.
   Each pane scrolls on its own; the conversation list folds away from the toggle at the start of the chat toolbar. */
.offcanvas.ui-offcanvas-workspace {
    --bs-offcanvas-width: calc(100vw - 2 * var(--ui-shell-gap));
    /* It covers the page: no live blur, which Chrome recomputes while its preview frame scrolls and makes the whole panel flicker. */
    --bs-offcanvas-bg: var(--ui-surface-raised);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

:root:has(.offcanvas.ui-offcanvas-workspace.show) .offcanvas-backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Offcanvas shown at once, without sliding or fading in (reopened after a page change):
   set on <html> just before show(), removed once shown so that closing still slides. */
.ui-offcanvas-instant .offcanvas,
.ui-offcanvas-instant .offcanvas-backdrop {
    transition: none !important;
}

.ui-agent-workspace {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Close button of the workspace, out of the header and level with the preview toolbar (always shown) */
.ui-agent-workspace {
    --ui-agent-bar-height: 3.3125rem;
    position: relative;
}

/* Top bars of the chat, the settings and the preview: one height, so their bottom borders line up */
.ui-agent-bar {
    min-height: var(--ui-agent-bar-height);
}

.ui-agent-close {
    position: absolute;
    top: calc((var(--ui-agent-bar-height) - 1px - 1.96875rem) / 2);
    right: 1rem;
    z-index: 2;
}

.ui-agent-preview-bar {
    padding-right: 3.5rem !important;
}

/* Conversations and chat: share what the preview leaves, whatever the length of the messages */
.ui-agent-main {
    display: flex;
    flex: 1 1 0;
    min-width: 22rem;
    min-height: 0;
}

/* Never narrower than the chat (and the list beside it): the settings panel and the preview give way */
.ui-agent-main:has(> .ui-agent-conversations:not([style*="display: none"])) {
    min-width: 39rem;
}

.ui-agent-conversations {
    display: flex;
    flex: 0 0 17rem;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-conversations .list-group {
    --bs-list-group-bg: transparent;
}

.ui-agent-conversation {
    position: relative;
}

.ui-agent-conversation > .list-group-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--bs-border-radius);
}

.ui-agent-conversation > .list-group-item > .bi {
    margin-top: 0.125rem;
    color: var(--bs-secondary-color);
}

.ui-agent-conversation > .list-group-item.active {
    color: var(--bs-emphasis-color);
    background-color: var(--ui-active);
}

.ui-agent-conversation > .list-group-item.active > .bi {
    color: var(--bs-primary);
}

/* Actions of a row (archive, delete), above it: Bootstrap lifts a hovered row (z-index 1) or the active one (2).
   Two actions cover the end of the title on hover, on the row's own background. */
.ui-agent-conversation-actions {
    position: absolute;
    top: 0.3125rem;
    right: 0.25rem;
    z-index: 3;
    display: flex;
    gap: 0.125rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-body-bg);
}

.ui-agent-conversation-actions:empty {
    display: none;
}

/* Archives of the list: a folding head with their count, under the recent conversations */
.ui-agent-archives {
    margin-top: 0.5rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-archives-toggle {
    width: 100%;
    padding: 0.25rem 0.5rem;
    border-radius: var(--bs-border-radius);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.ui-agent-archives-toggle:hover {
    color: var(--bs-emphasis-color);
    background-color: var(--bs-tertiary-bg);
}

.ui-agent-archives-toggle > .badge {
    margin-left: auto;
}

/* A line in place of rows (nothing recent, archives cut) */
.ui-agent-list-hint {
    margin: 0;
    padding: 0.25rem 0.5rem 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

/* Conversations of the person elsewhere (another form or fiche), above those of the form */
.ui-agent-elsewhere {
    flex-shrink: 0;
    max-height: 15rem;
    overflow-y: auto;
    padding: 0.25rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-elsewhere-title {
    margin: 0;
    padding: 0.25rem 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
}

/* New conversation, here (main button) or on another fiche (second button opening the fiche picker) */
.ui-agent-new > .ui-agent-new-elsewhere {
    flex: 0 0 auto;
}

/* Fiche of the chat, in its bar: a long name is cut at a width that keeps its code, the form label shrinks first */
.ui-agent-fiche {
    flex: 0 0 auto;
    max-width: 12rem;
}

/* Every fiche's conversations, in place of the conversation list: back button, search, then each fiche
   talked about (latest first) as a compact head (tag, title, new-conversation button) over its
   conversations; when searching, the other fiches with a draft, where a new conversation starts. */
.ui-agent-picker {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.ui-agent-picker .ui-agent-conversation > .list-group-item {
    padding-right: 0.5rem;
}

.ui-agent-picker-fiche + .ui-agent-picker-fiche {
    margin-top: 0.375rem;
}

.ui-agent-picker-fiche-head {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    min-height: 2rem;
    padding: 0.125rem 0.125rem 0.125rem 0.5rem;
}

/* A long code shrinks (cut with an ellipsis) before the new-conversation button leaves the head */
.ui-agent-picker-fiche-head > .ui-fiche-tag {
    flex: 0 1 auto;
}

.ui-agent-picker-fiche-head > .ui-fiche-tag > .ui-fiche-tag-code {
    white-space: nowrap;
}

.ui-agent-picker-fiche-head > .btn {
    flex: 0 0 auto;
    margin-left: auto;
}

/* The title takes only the room left by the code */
.ui-agent-picker-fiche-meta {
    flex: 1 1 0;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

/* Parent of a sub-fiche, after the version on the meta line (the line truncates) */
.ui-agent-picker-parent {
    color: var(--bs-secondary-color);
}

.ui-agent-picker-parent > .bi {
    margin-right: 0.25rem;
}

.ui-agent-picker-more {
    margin: 0;
    padding: 0.5rem 0.75rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

/* Form switcher in the chat bar: icon tile and label of the form the next message edits, cut with an
   ellipsis when the bar is narrow (the bar never wraps); the menu lists the forms of the version. */
.ui-agent-sections {
    /* The form the next message edits: kept whole before the selection hint, cut only past 11rem */
    flex: 0 0 auto;
    max-width: 11rem;
}

.ui-agent-sections > .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
}

.ui-agent-sections-label {
    min-width: 0;
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-agent-sections .dropdown-menu {
    min-width: 15rem;
}

.ui-agent-conversation > .list-group-item.ui-fiche-edge {
    padding-left: 0.875rem;
}

.ui-agent-conversation mark {
    padding: 0 0.0625rem;
    border-radius: 0.1875rem;
}

.ui-agent-chat {
    display: flex;
    flex: 1 1 26rem;
    flex-direction: column;
    min-width: 22rem;
    min-height: 0;
    container: ui-agent-chat / inline-size;
}

/* Selection hint of the chat bar: only the room the other controls leave, cut with an ellipsis */
.ui-agent-context {
    flex: 1 1 0;
}

/* Model and reasoning of the chat bar: the label is cut with an ellipsis before the bar overflows */
.ui-agent-effort {
    flex: 0 1 auto;
    min-width: 0;
}

.ui-agent-effort > .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
}

.ui-agent-effort-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Narrow chat (preview or settings open): the bar stays on one line by dropping what can wait,
   the hint of no selection first, then the words next to the icons and the model's name (kept in the tooltips). */
@container ui-agent-chat (width < 40rem) {
    .ui-agent-context-empty {
        display: none;
    }

    .ui-agent-sections {
        max-width: 8.5rem;
    }
}

@container ui-agent-chat (width < 38rem) {
    .ui-agent-codex-label {
        display: none;
    }

    .ui-agent-bar > .ui-agent-fiche {
        max-width: 8rem;
    }
}

@container ui-agent-chat (width < 34rem) {
    .ui-agent-effort-model {
        display: none;
    }
}

.ui-agent-preview {
    container-type: inline-size;
    display: flex;
    flex: 0 1 clamp(26rem, 40vw, 58rem);
    flex-direction: column;
    min-width: 22rem;
    min-height: 0;
    border-left: 1px solid var(--bs-border-color-translucent);
}

.ui-agent-preview-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background-color: var(--bs-tertiary-bg);
}

.ui-agent-preview-stage > iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.ui-agent-preview-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
}

/* Narrow preview (PDF tab with its render switch): the update time moves to the refresh button's tooltip */
@container (max-width: 34rem) {
    .ui-agent-preview-at {
        display: none;
    }
}

/* Settings of an element picked in the preview, between the chat and the preview */
.ui-agent-settings {
    display: flex;
    flex: 0 1 24rem;
    flex-direction: column;
    min-width: 20rem;
    min-height: 0;
    border-left: 1px solid var(--bs-border-color-translucent);
}

/* Not enough room for the list, the chat, the settings and the preview: the list steps aside while the settings are open */
@media (max-width: 84rem) {
    .ui-agent-workspace:has(> .ui-agent-settings:not([style*="display: none"])) .ui-agent-conversations {
        display: none !important;
    }

    .ui-agent-workspace:has(> .ui-agent-settings:not([style*="display: none"])) .ui-agent-main {
        min-width: 22rem;
    }
}

.ui-agent-settings-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.75rem;
    overflow-y: auto;
}

/* Overlay while a render is replaced: the previous one stays readable under it.
   The notice (an element already first, an empty name…) uses the same pill at the bottom. */
.ui-agent-preview-busy,
.ui-agent-preview-notice {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: 999px;
    background: var(--ui-glass-bg);
    box-shadow: var(--bs-box-shadow-sm);
    font-size: 0.8125rem;
    transform: translateX(-50%);
    white-space: nowrap;
}

.ui-agent-preview-notice {
    top: auto;
    bottom: 0.75rem;
    z-index: 3;
    max-width: calc(100% - 1.5rem);
    white-space: normal;
}

/* Heatmap: discrete sequential steps via data-level 0–5 */
.ui-heatmap {
    display: grid;
    grid-template-columns: 2.25rem repeat(var(--ui-heatmap-cols, 12), minmax(0, 1fr));
    gap: 2px;
    font-size: 0.6875rem;
}

.ui-heatmap-label {
    display: flex;
    align-items: center;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
}

.ui-heatmap-label.is-col {
    justify-content: center;
}

.ui-heatmap-cell {
    aspect-ratio: 1.6;
    border-radius: 4px;
    background-color: var(--ui-active);
}

.ui-heatmap-cell[data-level="1"] { background-color: var(--ui-seq-1); }
.ui-heatmap-cell[data-level="2"] { background-color: var(--ui-seq-2); }
.ui-heatmap-cell[data-level="3"] { background-color: var(--ui-seq-3); }
.ui-heatmap-cell[data-level="4"] { background-color: var(--ui-seq-4); }
.ui-heatmap-cell[data-level="5"] { background-color: var(--ui-seq-5); }

.ui-heatmap-cell:hover {
    box-shadow: 0 0 0 2px var(--bs-body-bg), 0 0 0 3px var(--bs-emphasis-color);
}

.ui-heatmap-scale {
    display: inline-flex;
    gap: 2px;
}

.ui-heatmap-scale > span {
    width: 1rem;
    height: 0.625rem;
    border-radius: 2px;
}

/* Chart containers: fixed height so the canvas never collapses */
.ui-chart {
    position: relative;
    height: var(--ui-chart-height, 16rem);
}

/* Chart taller than its panel (one bar per row of a long list): it keeps its full height
   and scrolls inside this frame, so the page never grows past the viewport. */
.ui-chart-scroll {
    max-height: min(24rem, 45vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ui-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 0;
    padding: 0;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    list-style: none;
}

.ui-chart-legend > li {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
}

.ui-chart-swatch {
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
    border-radius: 3px;
    background-color: var(--swatch);
}

/* Toggleable legend entry (behaviour in ui.js): a button per series inside
   <ul class="ui-chart-legend" data-ui-chart-legend="<canvas id>">. A hidden series keeps
   its label, struck through, with a hollow swatch, so the state never relies on colour. */
.ui-chart-legend-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    margin: -0.125rem -0.375rem;
    padding: 0.125rem 0.375rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.ui-chart-legend-toggle:hover {
    color: var(--bs-emphasis-color);
    background-color: rgba(var(--bs-emphasis-color-rgb), 0.06);
}

.ui-chart-legend-toggle:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 1px;
}

.ui-chart-legend-toggle[aria-pressed="false"] {
    text-decoration: line-through;
}

.ui-chart-legend-toggle[aria-pressed="false"] .ui-chart-swatch {
    background-color: transparent;
    box-shadow: inset 0 0 0 1.5px var(--swatch);
}

/* Line series swatch: a short stroke in the series colour (--swatch), drawn solid, dashed
   or dotted (--swatch-stroke, matching the Chart.js borderDash), with the point marker of
   the series as an icon. Lines stay distinct without colour.
   <span class="ui-chart-swatch-line" style="--swatch: var(--ui-chart-2); --swatch-stroke: dashed" aria-hidden="true"><i class="bi bi-square-fill"></i></span> */
.ui-chart-swatch-line {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 0.75rem;
    flex-shrink: 0;
    color: var(--swatch);
    font-size: 0.5rem;
    line-height: 1;
}

.ui-chart-swatch-line::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    border-top: 2px var(--swatch-stroke, solid) var(--swatch);
    transform: translateY(-50%);
}

.ui-chart-swatch-line > .bi {
    position: relative;
}

.ui-chart-legend-toggle[aria-pressed="false"] .ui-chart-swatch-line {
    opacity: 0.45;
}

/* Path of an item through its steps: a node per step, then a bar in the colour of the stage
   (--swatch) sized by its duration (--journey-grow, any unit) with the value under it. The
   last node (ui-journey-end) has no bar. Stacked below xl, where the bar width follows
   --journey-share (percentage of the longest stage).
   <ol class="ui-journey"><li class="ui-journey-step" style="--swatch: var(--ui-chart-1); --journey-grow: 14; --journey-share: 100%">
   <span class="ui-journey-node">Validation</span><span class="ui-journey-bar"></span>
   <span class="ui-journey-value">14,0 j</span><span class="ui-journey-meta">4 696 demandes</span></li>
   <li class="ui-journey-step ui-journey-end"><span class="ui-journey-node">Émission</span></li></ol> */
.ui-journey {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ui-journey-step {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ui-journey-node {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--bs-emphasis-color);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.3;
}

.ui-journey-node::before {
    content: "";
    width: 0.625rem;
    height: 0.625rem;
    flex-shrink: 0;
    border: 2px solid var(--bs-emphasis-color);
    border-radius: 50%;
    background: var(--bs-body-bg);
}

.ui-journey-bar {
    width: var(--journey-share, 100%);
    min-width: 0.75rem;
    height: 0.375rem;
    margin: 0.375rem 0 0.5rem;
    border-radius: 999px;
    background: var(--swatch, var(--bs-primary));
}

.ui-journey-value {
    color: var(--bs-emphasis-color);
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.ui-journey-meta {
    margin-top: 0.125rem;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 1200px) {
    /* The last node can carry a figure (a total): it lines up with the values of the stages. */
    .ui-journey-end .ui-journey-node + .ui-journey-value {
        margin-top: 1.25rem;
    }

    .ui-journey {
        flex-direction: row;
        gap: 0;
    }

    /* A stage is never narrower than its label, kept on one line so the bars line up. */
    .ui-journey-step {
        flex: var(--journey-grow, 1) 1 0;
        min-width: auto;
        padding-inline-end: 0.75rem;
    }

    .ui-journey-node {
        white-space: nowrap;
    }

    /* The bar runs to the next node, 2px short of it. */
    .ui-journey-bar {
        width: auto;
        margin-inline-end: calc(-0.75rem + 2px);
    }

    .ui-journey-end {
        flex: 0 1 auto;
        min-width: 7rem;
        padding-inline-end: 0;
    }
}

.ui-meter {
    --bs-progress-height: 0.375rem;
    --bs-progress-bg: var(--bs-primary-bg-subtle);
    --bs-progress-bar-bg: var(--bs-primary);
}

/* Progress ring: small donut filled to --ui-ring-value (0–100), e.g. binder progress
   in the navigation. Always paired with a text or aria-label giving the figure; a full
   ring turns success and can carry a check next to it.
   <span class="ui-ring" style="--ui-ring-value: 60" role="img" aria-label="3 sur 5 terminés"></span> */
.ui-ring {
    --ui-ring-value: 0;
    --ui-ring-size: 1rem;
    --ui-ring-thickness: 3px;
    --ui-ring-color: var(--bs-primary);
    display: inline-block;
    flex: 0 0 var(--ui-ring-size);
    width: var(--ui-ring-size);
    height: var(--ui-ring-size);
    border-radius: 50%;
    background: conic-gradient(var(--ui-ring-color) calc(var(--ui-ring-value) * 1%), rgba(var(--bs-emphasis-color-rgb), 0.12) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--ui-ring-thickness)), #000 calc(100% - var(--ui-ring-thickness) + 0.5px));
    mask: radial-gradient(farthest-side, transparent calc(100% - var(--ui-ring-thickness)), #000 calc(100% - var(--ui-ring-thickness) + 0.5px));
}

/* On arrival every ring fills up from zero to its value. */
@property --ui-ring-value {
    syntax: "<number>";
    inherits: false;
    initial-value: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .ui-ring {
        animation: ui-ring-fill 900ms cubic-bezier(0.33, 1, 0.68, 1) 150ms both;
    }
}

@keyframes ui-ring-fill {
    from { --ui-ring-value: 0; }
}

.ui-ring-lg {
    --ui-ring-size: 2.5rem;
    --ui-ring-thickness: 5px;
}

.ui-ring.is-complete {
    --ui-ring-color: var(--bs-success);
}

.ui-nav-link > .ui-ring {
    margin-left: auto;
}

/* Completion mark: gold ring + check for a finished item (e.g. a binder in the navigation).
   Rendered with .is-filling and an inner .ui-ring at 100: the ring fills up on arrival, then
   ui.js swaps it for the gold mark with .is-celebrating (on arrival only, never on hover):
   the mark squashes and springs back, the check is drawn in and bounces, a ripple and a
   burst of sparks leave the ring, then it glows. Purely decorative: the aria-label
   carries the figure. */
.ui-completion-mark {
    position: relative;
    display: inline-grid;
    place-items: center;
}

.ui-completion-mark > .bi {
    grid-area: 1 / 1;
}

.ui-completion-mark > .bi-check-lg {
    font-size: 0.7em;
}

.ui-completion-mark > .ui-ring {
    --ui-ring-size: 0.875em;
    grid-area: 1 / 1;
    display: none;
}

.ui-completion-mark.is-filling > .ui-ring {
    display: inline-block;
}

.ui-completion-mark.is-filling > .bi {
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ui-completion-mark.is-filling > .ui-ring {
        display: none;
    }

    .ui-completion-mark.is-filling > .bi {
        opacity: 1;
    }
}

.ui-completion-mark::before,
.ui-completion-mark::after {
    content: "";
    grid-area: 1 / 1;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

/* Ripple leaving the ring. */
.ui-completion-mark::after {
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
}

/* Sparks: one invisible dot thrown in eight directions by its shadows. */
.ui-completion-mark::before {
    width: 3px;
    height: 3px;
}

@media (prefers-reduced-motion: no-preference) {
    .ui-completion-mark.is-celebrating {
        animation:
            ui-completion-pop 620ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
            ui-completion-shine 1100ms ease-out both;
    }

    .ui-completion-mark.is-celebrating > .bi-check-lg {
        animation: ui-completion-draw 520ms cubic-bezier(0.22, 1, 0.36, 1) 120ms both;
    }

    .ui-completion-mark.is-celebrating::after {
        animation: ui-completion-ripple 640ms cubic-bezier(0.22, 1, 0.36, 1) 260ms both;
    }

    .ui-completion-mark.is-celebrating::before {
        animation: ui-completion-sparks 620ms cubic-bezier(0.16, 1, 0.3, 1) 280ms both;
    }
}

@keyframes ui-completion-pop {
    0% { transform: scale(1); }
    18% { transform: scale(0.72); }
    55% { transform: scale(1.25); }
    78% { transform: scale(0.94); }
    100% { transform: scale(1); }
}

@keyframes ui-completion-draw {
    0% { clip-path: inset(0 100% 0 0); transform: scale(0.8); }
    35% { clip-path: inset(0 55% 0 0); transform: scale(0.9); }
    65% { clip-path: inset(0 0 0 0); transform: scale(1.3); }
    100% { clip-path: inset(0 0 0 0); transform: scale(1); }
}

@keyframes ui-completion-ripple {
    0% { opacity: 0.8; transform: scale(0.7); border-width: 2px; }
    100% { opacity: 0; transform: scale(2.1); border-width: 0.5px; }
}

@keyframes ui-completion-sparks {
    0% {
        opacity: 1;
        box-shadow:
            0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor,
            0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor, 0 0 0 0.5px currentColor;
    }
    70% { opacity: 1; }
    100% {
        opacity: 0;
        box-shadow:
            0 -1.05em 0 -1px currentColor, 0.74em -0.74em 0 -1px currentColor, 1.05em 0 0 -1px currentColor, 0.74em 0.74em 0 -1px currentColor,
            0 1.05em 0 -1px currentColor, -0.74em 0.74em 0 -1px currentColor, -1.05em 0 0 -1px currentColor, -0.74em -0.74em 0 -1px currentColor;
    }
}

@keyframes ui-completion-shine {
    0%, 40%, 100% { filter: drop-shadow(0 0 0 transparent); }
    62% { filter: drop-shadow(0 0 4px color-mix(in srgb, currentColor 75%, transparent)); }
}

.ui-sparkline {
    height: 2.5rem;
}

/* Sortable list */
.ui-sortable-handle {
    color: var(--bs-tertiary-color);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.ui-sortable-handle:active {
    cursor: grabbing;
}

.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    background-color: var(--ui-input-bg-focus);
    box-shadow: var(--bs-box-shadow);
}

/* Small icon tile for dense rows (tree rows, compact lists) */
.ui-icon-tile-sm {
    width: 1.625rem;
    height: 1.625rem;
    border-radius: var(--bs-border-radius-sm);
    font-size: 0.875rem;
}

/* Tree: an outline of nested items (e.g. the structure of a report form).
   <ul class="ui-tree" role="tree"> holds <li class="ui-tree-item" role="treeitem">; each item has
   one .ui-tree-row (drag handle, .ui-tree-toggle or .ui-tree-spacer, icon tile, .ui-tree-label
   with .ui-tree-title and .ui-tree-meta, trailing badges and .ui-tree-actions) and, for a
   container, a <ul class="ui-tree-group" role="group"> indented behind a guide line. The toggle's
   aria-expanded says whether the group is shown (hide the group with `hidden` or x-show). The
   selected row carries .active: tinted, with a bold title (never colour alone).
   Row actions appear on hover or focus and stay visible on touch screens; .ui-tree-actions-visible
   on the .ui-tree keeps them visible on every row (a list whose actions are its main use). An empty group keeps
   a small drop zone so SortableJS can move items into an empty container. */
.ui-tree,
.ui-tree-group {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ui-tree-group {
    min-height: 0.375rem;
    margin-left: 1.3125rem;
    padding-left: 0.375rem;
    border-left: 1px solid var(--bs-border-color);
}

.ui-tree-drop-placeholder {
    min-height: 2.375rem;
    margin: 0.1875rem 0;
    padding: 0.5rem;
    border: 1px dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
    pointer-events: none;
}

.ui-tree-group:has(> .ui-tree-item) > .ui-tree-drop-placeholder {
    display: none;
}

.ui-tree-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.375rem;
    padding: 0.1875rem 0.375rem;
    border-radius: var(--bs-border-radius);
    font-size: 0.875rem;
}

.ui-tree-row:hover {
    background-color: var(--ui-hover);
}

.ui-tree-row.active {
    background-color: var(--ui-active);
}

.ui-tree-row.active .ui-tree-title {
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

/* Drop target of an element dragged in from elsewhere (e.g. another browser tab): a bar
   above (.ui-tree-drop-before) or below (.ui-tree-drop-after) the row, or a dashed outline
   when the element goes inside a container row (.ui-tree-drop-into). Shape, not colour,
   tells where it lands. */
.ui-tree-row.ui-tree-drop-before::before,
.ui-tree-row.ui-tree-drop-after::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 2px;
    background-color: var(--bs-primary);
    pointer-events: none;
}

.ui-tree-row.ui-tree-drop-before::before {
    top: -2px;
}

.ui-tree-row.ui-tree-drop-after::before {
    bottom: -2px;
}

.ui-tree-row.ui-tree-drop-into {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -2px;
    background-color: var(--ui-hover);
}

.ui-tree-toggle,
.ui-tree-spacer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background: none;
    color: var(--bs-secondary-color);
}

.ui-tree-toggle:hover {
    background-color: var(--ui-active);
    color: var(--bs-emphasis-color);
}

.ui-tree-toggle i {
    transition: transform 0.15s ease;
}

.ui-tree-toggle[aria-expanded="false"] i {
    transform: rotate(-90deg);
}

.ui-tree-label {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    text-align: left;
}

.ui-tree-label:focus-visible {
    border-radius: var(--bs-border-radius-sm);
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.ui-tree-text {
    min-width: 0;
    line-height: 1.25;
}

.ui-tree-title,
.ui-tree-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-tree-title {
    color: var(--bs-body-color);
    font-weight: 500;
}

.ui-tree-meta {
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.ui-tree-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.125rem;
}

.ui-tree-row .ui-sortable-handle {
    flex-shrink: 0;
}

/* Count pill at the end of a tree row (e.g. points under a category): small, tabular figures. */
.ui-tree-count {
    flex-shrink: 0;
    min-width: 1.375rem;
    padding: 0 0.375rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.25rem;
    text-align: center;
}

/* Compact tree: a dense read-only outline (e.g. inside a chat card). Plain icons instead of
   icon tiles, shorter rows, a tighter indent. */
.ui-tree-compact .ui-tree-row {
    gap: 0.25rem;
    min-height: 1.75rem;
    padding: 0.0625rem 0.25rem;
    font-size: 0.8125rem;
}

.ui-tree-compact .ui-tree-label {
    gap: 0.375rem;
}

.ui-tree-compact .ui-tree-group {
    margin-left: 0.875rem;
    padding-left: 0.25rem;
}

.ui-tree-compact .badge {
    flex-shrink: 0;
    font-size: 0.6875rem;
}

/* Status columns: items sorted by status, one column per status side by side (e.g. the
   non-conformes and non-vérifiables écarts of a synthèse), all as tall as the tallest. Columns
   fall back to a single stack when the container is too narrow. Each column has a tinted header (icon + words, so the
   status never rests on colour alone), section titles on a grey band with a status-coloured
   edge, and plain rows split by hairlines for the items.
   <div class="ui-status-columns">
     <section class="ui-status-column ui-status-column-danger">
       <h3 class="ui-status-column-header"><i class="bi bi-x-circle-fill"></i>Non conformes <span class="ui-status-column-count">3</span></h3>
       <ul class="ui-status-column-list">
         <li><div class="ui-status-column-section"><i class="bi bi-folder2-open"></i><span>Section</span><span class="ui-tree-count">2</span></div>
             <ul class="ui-status-column-group"><li class="ui-status-column-item">…</li></ul></li>
       </ul>
     </section>
   </div> */
.ui-status-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 0.75rem;
}

.ui-status-column {
    --ui-status-rgb: var(--bs-secondary-rgb);
    --ui-status-color: var(--bs-secondary-text-emphasis);
    --ui-status-bg: var(--bs-tertiary-bg);
    --ui-status-border: var(--bs-border-color);
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--ui-status-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--bs-body-bg);
}

.ui-status-column-danger {
    --ui-status-rgb: var(--bs-danger-rgb);
    --ui-status-color: var(--bs-danger-text-emphasis);
    --ui-status-bg: var(--bs-danger-bg-subtle);
    --ui-status-border: var(--bs-danger-border-subtle);
}

.ui-status-column-warning {
    --ui-status-rgb: var(--bs-warning-rgb);
    --ui-status-color: var(--bs-warning-text-emphasis);
    --ui-status-bg: var(--bs-warning-bg-subtle);
    --ui-status-border: var(--bs-warning-border-subtle);
}

.ui-status-column-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--ui-status-border);
    background-color: var(--ui-status-bg);
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
}

.ui-status-column-header > .bi {
    color: var(--ui-status-color);
}

.ui-status-column-count {
    min-width: 1.375rem;
    padding: 0 0.4375rem;
    border: 1px solid var(--ui-status-border);
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-body-bg);
    color: var(--ui-status-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25rem;
    text-align: center;
}

.ui-status-column-list,
.ui-status-column-group {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Section title: the grey band and coloured edge set it apart from the items under it. */
.ui-status-column-section {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem 0.5rem calc(0.875rem - 3px);
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 1px solid var(--bs-border-color);
    border-left: 3px solid rgba(var(--ui-status-rgb), 0.85);
    background-color: var(--bs-secondary-bg);
    color: var(--bs-emphasis-color);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
}

.ui-status-column-list > li:first-child > .ui-status-column-section {
    border-top: 0;
}

.ui-status-column-section > .bi {
    flex-shrink: 0;
    color: var(--bs-secondary-color);
}

.ui-status-column-section > span:not(.ui-tree-count) {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ui-status-column-section .ui-tree-count {
    background-color: var(--bs-body-bg);
}

/* A sub-section (category nested in another) keeps a lighter title without the band. */
.ui-status-column-group .ui-status-column-section {
    border-top: 1px solid var(--bs-border-color);
    border-bottom: 0;
    border-left-color: transparent;
    background-color: transparent;
    color: var(--bs-secondary-text-emphasis);
    font-size: 0.8125rem;
}

.ui-status-column-item {
    padding: 0.5rem 0.875rem;
    border-top: 1px solid var(--bs-border-color);
    color: var(--bs-emphasis-color);
    font-size: 0.875rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.ui-status-column-section + .ui-status-column-group > .ui-status-column-item:first-child,
.ui-status-column-list > .ui-status-column-item:first-child {
    border-top: 0;
}

@media (max-width: 767.98px) {
    /* Section usage counts get their own line so the section name stays readable. */
    .ui-tree-row:has(.ui-tree-usage-counts) {
        flex-wrap: wrap;
    }

    .ui-tree-usage-counts {
        flex-basis: 100%;
        order: 1;
        justify-content: flex-end;
    }
}

@media (hover: hover) {
    /* Top-layer dropdowns can briefly lose ancestor hover/focus on mousedown.
       Keep their actions visible until the menu closes so the click completes. */
    .ui-tree-row:not(:hover, :focus-within, :has(.dropdown-menu.show)) .ui-tree-usage-counts {
        opacity: 0;
    }

    .ui-tree:not(.ui-tree-actions-visible) .ui-tree-row:not(:hover, :focus-within, .active, :has(.dropdown-menu.show)) .ui-tree-actions,
    .ui-tree-row:not(:hover, :focus-within) .ui-sortable-handle {
        visibility: hidden;
    }
}

/* Colour swatch: a small square showing --ui-swatch (set inline from the stored value);
   without a colour it shows a diagonal stroke meaning "none". Pair it with the colour code
   in text. Colour field: .input-group[data-ui-color-field] with a label.input-group-text
   holding the swatch and a visually hidden <input type="color" data-ui-color-picker>, then
   the text input [data-ui-color-text] (fields.js keeps both in sync). */
.ui-swatch {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--ui-swatch, linear-gradient(to top right, transparent calc(50% - 1px), var(--bs-secondary-color) 50%, transparent calc(50% + 1px)));
}

[data-ui-color-field] > label.input-group-text {
    cursor: pointer;
}

/* Value list: an ordered list of short values edited one per row (choices, headers…),
   stored as one string with a separator. fields.js renders the rows from
   [data-ui-value-list] > input[data-ui-value-list-input]: grip, position, input, remove,
   then an "add" button. */
.ui-value-list-index {
    min-width: 1.25rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Wider side panel for a split view whose aside holds an editor (e.g. a component's settings) */
@media (min-width: 992px) {
    .ui-split-aside.ui-split-aside-wide {
        flex-basis: 26rem;
    }
}

@media (min-width: 1400px) {
    .ui-split-aside.ui-split-aside-wide {
        flex-basis: 32rem;
    }
}

/* App shell: sidebar on the page background, content in an inset panel */
.ui-app {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.ui-sidebar {
    --bs-offcanvas-width: var(--ui-sidebar-width);
    --bs-offcanvas-border-color: var(--ui-glass-border);
    /* The glass sits on ::before; also overrides the offcanvas background below lg */
    background-color: transparent !important;
}

/*
 * Glass layer on a pseudo-element: a blurred element is a "backdrop root", so the
 * navigation panel opened from the sidebar could not blur the page behind it.
 */
.ui-sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background-color: var(--ui-glass-chrome);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
    pointer-events: none;
}

.ui-sidebar > .offcanvas-body {
    min-height: 0;
    padding: 0;
}

@media (min-width: 992px) {
    /* Floating glass panel */
    .ui-sidebar {
        position: sticky;
        top: var(--ui-shell-gap);
        display: flex;
        flex-direction: column;
        width: var(--ui-sidebar-width);
        height: calc(100vh - 2 * var(--ui-shell-gap));
        height: calc(100dvh - 2 * var(--ui-shell-gap));
        flex-shrink: 0;
        margin: var(--ui-shell-gap);
        border: 1px solid var(--ui-glass-border);
        border-radius: var(--bs-border-radius-lg);
        box-shadow: var(--ui-glass-shadow);
    }

    .ui-sidebar > .offcanvas-body {
        flex: 1 1 auto;
        flex-direction: column;
        overflow-y: auto;
    }
}

.ui-sidebar-brand {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.625rem;
    height: var(--ui-topbar-height);
    padding: 0 1.25rem;
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.ui-brand-mark {
    display: block;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 1.25rem;
    object-fit: contain;
}

.ui-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    padding: 0.25rem 0.75rem 1rem;
}

.ui-nav-heading {
    padding: 1rem 0.625rem 0.375rem;
    color: var(--bs-tertiary-color);
    font-size: 0.75rem;
    font-weight: 500;
}

.ui-nav-heading:first-child {
    padding-top: 0.25rem;
}

.ui-nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--bs-border-radius);
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ui-nav-link > i {
    width: 1.125rem;
    font-size: 1rem;
    text-align: center;
}

.ui-nav-link > .badge {
    margin-left: auto;
}

.ui-nav-link:hover {
    background-color: var(--ui-hover);
    color: var(--bs-emphasis-color);
    text-decoration: none;
}

.ui-nav-link:focus-visible {
    outline: 0;
    box-shadow: var(--ui-focus-ring);
}

.ui-nav-link.active {
    background-color: var(--ui-nav-active-bg);
    box-shadow: var(--bs-box-shadow-sm), 0 0 0 1px var(--bs-border-color);
    color: var(--bs-emphasis-color);
}

.ui-nav-link.active > i {
    color: var(--bs-primary-text-emphasis);
}

/* Main navigation shell (layouts/partials/ui-navigation): built for ~100 entries.
   Sections stay in the sidebar; their pages open in one flyout panel at a time. */
.ui-navshell {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.ui-navshell-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.ui-navshell-search {
    padding: 0.25rem 0.75rem 0.5rem;
}

.ui-navshell-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.75rem 0.75rem;
    scroll-padding-block: 0.75rem;
    scrollbar-width: none;
}

.ui-navshell-scroll::-webkit-scrollbar {
    display: none;
}

.ui-navshell-scroll-hints {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    color: var(--bs-secondary-color);
}

.ui-navshell-scroll-hints[hidden],
.ui-navshell-scroll-hints > [hidden] {
    display: none;
}

.ui-navshell-scroll-hints > i {
    position: absolute;
    left: 50%;
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 0.875rem;
    border-radius: 999px;
    background: var(--ui-surface-raised);
    box-shadow: var(--bs-box-shadow-sm);
    font-size: 0.625rem;
    opacity: 0.8;
    transform: translateX(-50%);
}

.ui-navshell-scroll-hints > .bi-chevron-up {
    top: 1px;
}

.ui-navshell-scroll-hints > .bi-chevron-down {
    bottom: 1px;
}

.ui-navshell-scroll [data-ui-nav-home],
.ui-navshell-scroll [data-ui-nav-order-list],
.ui-navshell-scroll [data-ui-nav-rubric-list],
.ui-navshell-scroll [data-ui-nav-results],
.ui-navshell-scroll [data-ui-nav-pins-list],
.ui-navshell-scroll [data-ui-nav-results-list] {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ui-navshell-scroll [hidden] {
    display: none !important;
}

.ui-navshell-orderable,
.ui-navshell-rubric {
    position: relative;
    min-width: 0;
}

.ui-navshell-orderable > [data-ui-nav-handle],
.ui-navshell-rubric > [data-ui-nav-rubric-handle] {
    position: absolute;
    top: 0.2rem;
    right: 0.1rem;
    z-index: 1;
    display: none;
}

.ui-navshell-orderable-group > .ui-nav-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ui-navshell-orderable-group > .ui-nav-heading [data-ui-nav-handle] {
    display: none;
}

.ui-navshell.is-editing .ui-navshell-orderable > [data-ui-nav-handle],
.ui-navshell.is-editing .ui-navshell-rubric > [data-ui-nav-rubric-handle],
.ui-navshell.is-editing .ui-navshell-orderable-group > .ui-nav-heading [data-ui-nav-handle] {
    display: inline-flex;
    background-color: var(--ui-hover);
}

.ui-navshell.is-editing .ui-navshell-orderable > .ui-nav-link,
.ui-navshell.is-editing .ui-navshell-orderable > .ui-navshell-item .ui-nav-link,
.ui-navshell.is-editing .ui-navshell-rubric > .ui-nav-link,
.ui-navshell.is-editing .ui-navshell-rubric > .ui-navshell-item .ui-nav-link {
    padding-right: 2.5rem;
}

.ui-navshell.is-editing .ui-navshell-orderable .ui-navshell-pin,
.ui-navshell.is-editing .ui-navshell-orderable .ui-navshell-chevron {
    display: none;
}

.ui-navshell.is-editing .ui-navshell-orderable > .ui-nav-link > .badge {
    display: none;
}

.ui-navshell-footer {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-navshell-footer [data-ui-nav-edit][aria-pressed="true"] {
    background-color: var(--bs-success-bg-subtle);
    color: var(--bs-success-text-emphasis);
}

button.ui-nav-link {
    width: 100%;
    border: 0;
    background: none;
    font-family: inherit;
    line-height: inherit;
    text-align: left;
}

.ui-nav-link > span:not(.badge):not(.ui-ring) {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-navshell-chevron {
    width: auto !important;
    font-size: 0.6875rem !important;
    opacity: 0.55;
}

.ui-navshell-section.is-current {
    background-color: var(--ui-nav-active-bg);
    box-shadow: var(--bs-box-shadow-sm), 0 0 0 1px var(--bs-border-color);
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-navshell-current-path {
    margin: 0.25rem 0.25rem 0.25rem 1.25rem;
    font-size: 0.75rem;
}

.ui-navshell-section.is-current > i:first-child {
    color: var(--bs-primary-text-emphasis);
}

.ui-navshell-section[aria-expanded="true"] {
    background-color: var(--ui-nav-active-bg);
    box-shadow: var(--bs-box-shadow-sm), 0 0 0 1px var(--bs-border-color);
    color: var(--bs-emphasis-color);
}

.ui-navshell-section[aria-expanded="true"] > .ui-navshell-chevron {
    opacity: 1;
}

.ui-navshell-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(100% + var(--ui-shell-gap) + 1px);
    z-index: 1035;
    display: flex;
    flex-direction: column;
    width: 18rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--bs-box-shadow-lg);
    animation: ui-nav-panel-in 0.16s ease-out;
}

.ui-navshell-panel[hidden] {
    display: none;
}

@keyframes ui-nav-panel-in {
    from {
        opacity: 0;
        transform: translateX(-0.375rem);
    }
}

.ui-navshell-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 0.625rem 0.5rem 1rem;
}

.ui-navshell-panel-title {
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.ui-navshell-back {
    display: none;
}

.ui-navshell-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.625rem 1rem;
}

.ui-navshell-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem 0.25rem;
    color: var(--bs-tertiary-color);
    font-size: 0.75rem;
    font-weight: 500;
}

.ui-navshell-group.level-1 {
    margin-top: 0.25rem;
    margin-left: 1.25rem;
}

.ui-navshell-group.level-1 > .ui-navshell-group-title {
    padding-top: 0.25rem;
}

.ui-navshell-item {
    position: relative;
    display: flex;
    align-items: center;
}

.ui-navshell-item-divided {
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-navshell-item > .ui-nav-link {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 2rem;
}

.ui-navshell-pin {
    position: absolute;
    right: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background: none;
    color: var(--bs-tertiary-color);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.ui-navshell-item:hover > .ui-navshell-pin,
.ui-navshell-pin:focus-visible,
.ui-navshell-pin[aria-pressed="true"] {
    opacity: 1;
}

@media (hover: none) {
    .ui-navshell-pin {
        opacity: 1;
    }
}

.ui-navshell-pin:hover {
    background-color: var(--ui-active);
    color: var(--bs-emphasis-color);
}

.ui-navshell-pin[aria-pressed="true"] {
    color: var(--bs-warning-text-emphasis);
}

.ui-navshell-pin:focus-visible {
    outline: 0;
    box-shadow: var(--ui-focus-ring);
}

.ui-navshell-result-path {
    display: block;
    overflow: hidden;
    color: var(--bs-tertiary-color);
    font-size: 0.6875rem;
    font-weight: 400;
    text-overflow: ellipsis;
}

@media (min-width: 992px) {
    .ui-sidebar {
        z-index: 1030;
    }

    /* The flyout must escape the sidebar: the navshell scrolls its own list */
    .ui-sidebar > .offcanvas-body:has(> .ui-navshell) {
        overflow: visible;
    }

    /* Same glass as the sidebar (its blur sits on ::before, so the panel can blur the page) */
    .ui-navshell-panel {
        top: var(--ui-shell-gap);
        background-color: var(--ui-glass-chrome);
        box-shadow: var(--ui-glass-shadow);
        -webkit-backdrop-filter: var(--ui-glass-filter);
        backdrop-filter: var(--ui-glass-filter);
    }

    .ui-sidebar,
    .kit-nav-demo-sidebar {
        transition: width 0.2s ease;
    }

    /* Collapsed icon rail (html.ui-nav-collapsed, or .is-nav-collapsed on a frame) */
    html.ui-nav-collapsed .ui-sidebar,
    .is-nav-collapsed {
        --ui-sidebar-width: 4.25rem;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) :is(.ui-navshell-search .input-group, .ui-navshell-chevron, .ui-navshell-main .ui-nav-heading, .ui-navshell-current-path, .ui-sidebar-brand > span:not(.ui-brand-mark), .ui-sidebar-brand > .btn-close) {
        display: none !important;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-footer .ui-nav-link {
        justify-content: center;
        padding: 0.5rem 0;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-footer .ui-nav-link > span {
        display: none;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) :is(.ui-navshell-main .ui-nav-link > span:not(.badge):not(.ui-ring), .ui-navshell-main .ui-navshell-pin) {
        display: none;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-main .ui-nav-link {
        position: relative;
        justify-content: center;
        padding: 0.5rem 0;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-main .ui-nav-link > .badge {
        position: absolute;
        top: 0.125rem;
        right: 0.25rem;
        padding: 0.0625rem 0.3125rem;
        font-size: 0.625rem;
    }

    /* Progress ring shrinks into the icon's corner, like the counters */
    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-main .ui-nav-link > .ui-ring {
        --ui-ring-size: 0.75rem;
        --ui-ring-thickness: 2px;
        position: absolute;
        top: 0.25rem;
        right: 0.375rem;
        margin: 0;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) :is(.ui-navshell-scroll, .ui-navshell-footer) {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-navshell-scroll [data-ui-nav-pins] {
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--bs-border-color);
        margin-bottom: 0.5rem;
    }

    :is(html.ui-nav-collapsed .ui-sidebar, .is-nav-collapsed) .ui-sidebar-brand {
        justify-content: center;
        padding: 0;
    }
}

/* Mobile: the menu is a sheet rising from the bottom, as the bottom bar sits there (a tablet
   gets it centred, at a reading width); the panel slides over the section list inside it */
@media (max-width: 991.98px) {
    .ui-sidebar {
        --bs-offcanvas-height: min(88dvh, 52rem);
        right: 0;
        left: 0;
        max-width: 40rem;
        margin-inline: auto;
        padding-bottom: env(safe-area-inset-bottom);
        border: 1px solid var(--ui-glass-border);
        border-bottom: 0;
        border-radius: var(--bs-border-radius-xl) var(--bs-border-radius-xl) 0 0;
    }

    /* Grip of the sheet: its header can be dragged down to close it */
    .ui-sidebar-brand {
        position: relative;
        touch-action: none;
    }

    .ui-sidebar-brand::before {
        content: "";
        position: absolute;
        top: 0.375rem;
        left: 50%;
        width: 2.25rem;
        height: 0.25rem;
        border-radius: var(--bs-border-radius-pill);
        background-color: var(--bs-border-color);
        transform: translateX(-50%);
    }

    .ui-sidebar.is-dragging {
        transition: none;
    }

    .ui-sidebar::before {
        background-color: var(--ui-surface-raised);
    }

    .ui-sidebar > .offcanvas-body:has(> .ui-navshell) {
        overflow: hidden;
    }

    .ui-sidebar .ui-navshell-scroll,
    .ui-sidebar .ui-navshell-panel-body {
        overscroll-behavior-y: contain;
    }

    .ui-sidebar .ui-nav-link {
        min-height: 2.75rem;
    }

    .ui-sidebar .ui-navshell-search .form-control {
        min-height: 2.75rem;
        font-size: 1rem;
    }

    .ui-sidebar-brand > .btn-close {
        box-sizing: border-box;
        width: 2.75rem;
        height: 2.75rem;
        flex-shrink: 0;
    }

    .ui-navshell-panel-header {
        padding: 0.25rem 0.75rem 0.5rem;
        border-bottom: 1px solid var(--bs-border-color);
        margin-bottom: 0.25rem;
    }

    .ui-navshell-panel-header > .btn {
        min-width: 2.75rem;
        min-height: 2.75rem;
    }

    .ui-app:has(> .ui-sidebar:is(.show, .showing, .hiding)) > .ui-main {
        overflow-y: hidden;
    }

    .ui-navshell-panel {
        inset: 0;
        width: auto;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .ui-navshell-back {
        display: inline-flex;
    }

    .ui-navshell-footer {
        padding: 0.5rem 0.75rem 0.75rem;
    }

    .ui-navshell-footer > :not([data-ui-nav-edit]) {
        display: none;
    }
}

/* Transparent scroll container: content scrolls under the floating topbar */
.ui-main {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    /* Vertical scrolling only, as in .ui-split-main: from lg the content has no side padding, so
       a top-level grid row's negative gutters would add an 8px horizontal bar. Wide content
       scrolls in its own frame (.table-responsive, .ui-chart-scroll). */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: none;
}

.ui-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.75rem;
    height: var(--ui-topbar-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--ui-glass-border);
    background-color: var(--ui-glass-chrome);
    box-shadow: var(--ui-glass-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

/* Keep action groups at their natural width, including Livewire teleport slots. */
.ui-topbar > :not([data-ui-topbar-workspace]),
[data-ui-topbar-workspace] > * {
    flex-shrink: 0;
}

@media (max-width: 991.98px) {
    .ui-topbar {
        height: auto;
        min-height: var(--ui-topbar-height);
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    [data-ui-topbar-workspace] {
        flex-wrap: wrap;
    }
}

/* Bottom bar below lg (components/ui/shell, public/js/ui/bottom-nav.js): the first entries of
   the menu as the sidebar lists them, then Menu, which opens the sidebar. It replaces the menu
   button of the topbar, which gets that room back. Only where the sidebar holds the main
   navigation; a form whose Précédent / Suivant bar is pinned to the bottom of the screen owns
   that edge, and the keyboard of a phone needs the room (.ui-keyboard-open, set by the script).
   --ui-bottom-nav-height is what the page keeps free at the bottom, 0px where the bar is absent. */
:root {
    --ui-bottom-nav-height: 0px;
}

.ui-bottom-nav {
    display: none;
}

@media (max-width: 991.98px) {
    :root:has(#ui-sidebar [data-ui-nav]) {
        --ui-bottom-nav-height: calc(4rem + env(safe-area-inset-bottom, 0px));
    }

    :root:has(#ui-sidebar [data-ui-nav]):has(.ui-wizard-nav.ui-wizard-fixed),
    :root.ui-keyboard-open:has(#ui-sidebar [data-ui-nav]) {
        --ui-bottom-nav-height: 0px;
    }

    /* The topbar keeps its menu button where a pinned form bar takes the place of the bottom bar,
       or the page would have no way left to open the menu */
    :root:has(#ui-sidebar [data-ui-nav]):not(:has(.ui-wizard-nav.ui-wizard-fixed)) .ui-topbar > [data-bs-target="#ui-sidebar"] {
        display: none;
    }

    /* The page scrolls above the bar, so nothing of it is ever hidden behind it */
    .ui-main {
        height: calc(100vh - var(--ui-bottom-nav-height));
        height: calc(100dvh - var(--ui-bottom-nav-height));
    }

    :root:has(#ui-sidebar [data-ui-nav]):not(.ui-keyboard-open):not(:has(.ui-wizard-nav.ui-wizard-fixed)) .ui-bottom-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1030;
        display: block;
        height: var(--ui-bottom-nav-height);
        padding: 0.25rem calc(0.5rem + env(safe-area-inset-right, 0px)) calc(0.25rem + env(safe-area-inset-bottom, 0px)) calc(0.5rem + env(safe-area-inset-left, 0px));
        border-top: 1px solid var(--ui-glass-border);
        background-color: var(--ui-glass-chrome);
        box-shadow: var(--ui-glass-shadow);
        -webkit-backdrop-filter: var(--ui-glass-filter);
        backdrop-filter: var(--ui-glass-filter);
    }

    /* Floating tools, PAC button and toasts stay above the bar */
    .toast-container.position-fixed.bottom-0 {
        bottom: var(--ui-bottom-nav-height) !important;
    }

    .ui-float-actions,
    .pac-fab,
    .pac-bubble {
        margin-bottom: var(--ui-bottom-nav-height);
    }

    .pac-bubble {
        max-height: calc(100dvh - var(--pac-fab-bottom, 1rem) - 5.5rem - var(--ui-bottom-nav-height));
    }
}

.ui-bottom-nav-list {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 0.25rem;
    max-width: 36rem;
    height: 100%;
    margin: 0 auto;
    padding: 0;
    list-style: none;
}

.ui-bottom-nav-list > li {
    display: flex;
    min-width: 0;
}

.ui-bottom-nav-link {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    /* Icons on one line whether a label takes one line or two */
    justify-content: flex-start;
    gap: 0.125rem;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.25rem 0.125rem 0.125rem;
    border: 0;
    border-radius: var(--bs-border-radius-lg);
    background: none;
    color: var(--bs-secondary-color);
    font-family: inherit;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.ui-bottom-nav-link:focus-visible {
    outline: 0;
    box-shadow: var(--ui-focus-ring);
}

.ui-bottom-nav-link:active .ui-bottom-nav-icon {
    transform: scale(0.94);
}

/* The current tab: a tinted pill behind its icon, the label in ink */
.ui-bottom-nav-link:is(.active, .is-current) {
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

.ui-bottom-nav-link:is(.active, .is-current) .ui-bottom-nav-icon {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

@media (hover: hover) {
    .ui-bottom-nav-link:not(.active, .is-current):hover {
        color: var(--bs-emphasis-color);
    }

    .ui-bottom-nav-link:not(.active, .is-current):hover .ui-bottom-nav-icon {
        background-color: var(--ui-hover);
    }
}

.ui-bottom-nav-icon {
    position: relative;
    display: inline-flex;
    justify-content: center;
    width: 3.5rem;
    padding: 0.25rem 0;
    border-radius: var(--bs-border-radius-pill);
    font-size: 1.25rem;
    line-height: 1;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

/* Labels of the menu are long ("Tableau de bord", "Toutes mes demandes"): two lines at most,
   the full label stays in the title */
.ui-bottom-nav-label {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.ui-bottom-nav-badge {
    position: absolute;
    top: -0.125rem;
    left: calc(50% + 0.375rem);
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-primary);
    box-shadow: 0 0 0 2px var(--bs-body-bg);
    color: var(--bs-white);
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1rem;
    text-align: center;
    white-space: nowrap;
}

/* A badge without a number (unread messages): a dot */
.ui-bottom-nav-badge.is-dot {
    top: 0.125rem;
    left: calc(50% + 0.375rem);
    min-width: 0.5rem;
    width: 0.5rem;
    height: 0.5rem;
    padding: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ui-bottom-nav-link,
    .ui-bottom-nav-icon {
        transition: none;
    }

    .ui-bottom-nav-link:active .ui-bottom-nav-icon {
        transform: none;
    }
}

/* Workspace list footers on a phone: the count and the page size share a row, the page links
   take the next one, centred (livewire/workspace/partials/pagination) */
@media (max-width: 575.98px) {
    .ui-pagination-nav {
        display: flex;
        flex: 1 0 100%;
        justify-content: center;
    }
}

@media print {
    .ui-bottom-nav {
        display: none !important;
    }
}

@media (min-width: 992px) {
    /* Starting the scrollport below the gap keeps content out of it */
    .ui-main {
        height: calc(100vh - var(--ui-shell-gap));
        height: calc(100dvh - var(--ui-shell-gap));
        margin-top: var(--ui-shell-gap);
    }

    .ui-topbar {
        margin-right: var(--ui-shell-gap);
        padding: 0 0.75rem;
        border: 1px solid var(--ui-glass-border);
        border-radius: var(--bs-border-radius-lg);
    }

    /* Next to the floating sidebar, the scrollport is a rounded panel one gap away from the
       right and bottom edges (the sidebar margin gives the left one): the page scrolls inside
       it and disappears behind rounded corners under the topbar and at the bottom. */
    .ui-sidebar ~ .ui-main {
        height: calc(100vh - 2 * var(--ui-shell-gap));
        height: calc(100dvh - 2 * var(--ui-shell-gap));
        margin-right: var(--ui-shell-gap);
        border-radius: var(--bs-border-radius-lg);
    }

    .ui-sidebar ~ .ui-main > .ui-topbar {
        margin-right: 0;
    }

    /* While the page continues below, a card cut by the panel gets the border of its rounded
       bottom edge back, like the sidebar beside it (public/js/ui/overlay-scrollbars.js sets
       the attribute). Sticky as the last item, it adds no height. */
    .ui-sidebar ~ .ui-main::after {
        content: "";
        position: sticky;
        bottom: 0;
        z-index: 1;
        flex-shrink: 0;
        height: var(--bs-border-radius-lg);
        margin-top: calc(-1 * var(--bs-border-radius-lg));
        border: 1px solid transparent;
        border-top: 0;
        border-radius: 0 0 var(--bs-border-radius-lg) var(--bs-border-radius-lg);
        visibility: hidden;
        pointer-events: none;
    }

    .ui-sidebar ~ .ui-main[data-ui-scroll-below]::after {
        border-color: var(--ui-glass-border);
        visibility: visible;
    }

    /* Full width, so cards line up with the topbar edges and a card cut at the bottom takes the
       rounded corners of the panel, level with the sidebar; a little more than the gap above, and
       below the room the card shadow (--ui-glass-shadow) needs to fade before the panel clips it.
       It wins over the py-* / pb-* utilities pages pass through content-class, which still apply
       below lg. */
    .ui-sidebar ~ .ui-main > .ui-content {
        padding: 0.75rem 0 1.5rem !important;
    }

    /* A page that fits the viewport does not scroll, so no card is cut at the bottom: its panels
       end level with the sidebar instead of stopping the bottom padding above it. Older pages
       build the same fit with utilities (d-flex flex-column flex-grow-1 overflow-hidden). */
    .ui-sidebar ~ .ui-main > .ui-content:is(.ui-content-fill, .overflow-hidden) {
        padding-bottom: 0 !important;
    }
}

/* Shared section navigation, measured by ui.js against its available space. */
[data-ui-responsive-tabs] {
    display: flex;
    flex-wrap: nowrap;
    flex-shrink: 0;
    white-space: nowrap;
}

[data-ui-responsive-menu] {
    flex-shrink: 0;
}

.ui-content {
    width: 100%;
    padding: 2rem 2rem 3rem;
}

/* Opt-in reading width for text or single-form pages */
.ui-content-narrow {
    max-width: 64rem;
    margin-right: auto;
    margin-left: auto;
}

/* Work page that fits the viewport from lg up: its panels scroll inside themselves.
   Below lg the page keeps its natural height and scrolls as a whole (phones). */
@media (min-width: 992px) {
    .ui-content-fill {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }
}

/* Container that disappears when none of its content is shown (e.g. a form section whose
   fields are all hidden by display conditions, or a grid cell left empty): mark the container
   with data-ui-hide-empty and each content root with data-ui-content, adding .d-none to a
   content root while it is hidden. Empty cells leave the grid instead of leaving holes. */
[data-ui-hide-empty]:not(:has([data-ui-content]:not(.d-none))) {
    display: none !important;
}

/* Split view: a main panel and a side panel (summary, checklist) side by side from lg up,
   each scrolling on its own; stacked below lg in document order (main panel first).
   Put it in a `.ui-content-fill` page. */
.ui-split {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ui-split-main,
.ui-split-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 992px) {
    .ui-split {
        flex: 1 1 auto;
        flex-direction: row;
        min-height: 0;
    }

    /* Vertical scrolling only: a grid row's negative gutters must not add a horizontal bar */
    .ui-split-main,
    .ui-split-aside {
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ui-split-main {
        flex: 1 1 auto;
    }

    /* Keep panel tools outside its inner scroller; phones retain viewport positioning. */
    .ui-split-main > .ui-float-actions,
    .ui-split-main > .ui-wizard-nav > .ui-float-actions {
        position: absolute;
    }

    .ui-split-aside {
        flex: 0 0 22rem;
    }
}

@media (min-width: 1400px) {
    .ui-split-aside {
        flex-basis: 24rem;
    }
}

/* Card holding the selectable list of a split view (list beside its editor): below lg it keeps
   a bounded height and its list scrolls inside, so the editor stays reachable under it. */
@media (max-width: 991.98px) {
    .ui-split-list-panel {
        max-height: 22rem;
    }
}

/* A side panel slot still empty (filled later by a component, e.g. while the form loads)
   takes no gap, so both panels start on the same line */
.ui-split-aside > :empty {
    display: none !important;
}

/* Below lg the side panel dissolves into the split, so key blocks can move above the main
   panel with `order-first order-lg-0` (e.g. a summary). Wrappers inside the side panel that
   must dissolve too (a Livewire root, for instance) carry data-ui-split-dissolve. */
@media (max-width: 991.98px) {
    .ui-split-aside,
    .ui-split-aside [data-ui-split-dissolve] {
        display: contents !important;
    }
}

@media (max-width: 575.98px) {
    .ui-topbar {
        gap: 0.25rem;
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

    .ui-content {
        padding-right: 1rem;
        padding-left: 1rem;
    }
}

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

/* ID card: a physical-looking card (credit-card ratio) whose back shows a document, e.g. the
   inspector's professional card and accreditation. It stays white in both themes, like the
   printed object. A horizontal swipe, a mouse click or Enter/Space flips it (ui.js); a portrait
   document on the back is turned to fill the landscape face.
   <div class="ui-id-card-stage"><div class="ui-id-card" data-ui-id-card role="button" tabindex="0">
     <article class="ui-id-card-face ui-id-card-front">…</article>
     <article class="ui-id-card-face ui-id-card-back"><div class="ui-id-card-document">…</div></article>
   </div></div>
   In a .modal.ui-id-card-modal the card floats without a panel and fills a phone screen sideways. */
.ui-id-card-stage {
    --ui-id-card-blue: #1599d1;
    --ui-id-card-blue-deep: #0879ad;
    --ui-id-card-ink: #172f3b;
    --ui-id-card-muted: #53636b;
    width: min(100%, 780px);
    margin: 0 auto;
    perspective: 1800px;
    container-type: inline-size;
}

.ui-id-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1.586 / 1;
    cursor: grab;
    outline: none;
    touch-action: pan-y;
    transform-style: preserve-3d;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.78s cubic-bezier(0.2, 0.72, 0.2, 1);
}

.ui-id-card.is-dragging {
    cursor: grabbing;
    transition: none;
}

.ui-id-card:focus-visible {
    border-radius: 4cqi;
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), 0.35);
}

.ui-id-card.is-flipped {
    transform: rotateY(180deg);
}

.ui-id-card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(16, 92, 126, 0.18);
    border-radius: 3.4cqi;
    background: #fff;
    box-shadow: 0 24px 55px rgba(10, 52, 72, 0.24), 0 2px 8px rgba(10, 52, 72, 0.12);
    color: var(--ui-id-card-ink);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.ui-id-card-front {
    isolation: isolate;
    padding: 4.7% 5% 3.6%;
    background: linear-gradient(118deg, rgba(255, 255, 255, 0.98) 0 66%, rgba(232, 247, 252, 0.96) 100%), #fff;
}

/* Decorative rings in the corners */
.ui-id-card-front::before,
.ui-id-card-front::after {
    content: "";
    position: absolute;
    z-index: -1;
    aspect-ratio: 1;
    border: 7.5cqi solid rgba(21, 153, 209, 0.16);
    border-radius: 50%;
    pointer-events: none;
}

.ui-id-card-front::before {
    width: 42%;
    top: -23%;
    right: -8%;
}

.ui-id-card-front::after {
    width: 46%;
    bottom: -32%;
    left: -19%;
    border-color: rgba(8, 121, 173, 0.12);
}

.ui-id-card-brand {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.ui-id-card-brand img {
    width: 23%;
    height: auto;
}

.ui-id-card-brand > span {
    padding: 0.42em 0.78em;
    border: 1px solid rgba(21, 153, 209, 0.24);
    border-radius: 999px;
    background: rgba(21, 153, 209, 0.08);
    color: var(--ui-id-card-blue-deep);
    font-size: 1.6cqi;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ui-id-card-identity {
    display: grid;
    grid-template-columns: 24% minmax(0, 1fr) 20%;
    align-items: center;
    gap: 4%;
    min-height: 0;
    margin: auto 0;
}

.ui-id-card-photo {
    display: grid;
    width: 100%;
    aspect-ratio: 1;
    place-items: center;
    overflow: hidden;
    border: 0.7cqi solid #fff;
    border-radius: 18%;
    background: linear-gradient(145deg, #dff3fb, #b7ddea);
    box-shadow: 0 8px 24px rgba(9, 93, 128, 0.18);
    color: var(--ui-id-card-blue-deep);
    font-size: 5.2cqi;
    font-weight: 800;
}

.ui-id-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ui-id-card-person {
    min-width: 0;
}

.ui-id-card-company {
    display: block;
    margin-bottom: 0.35em;
    color: var(--ui-id-card-blue-deep);
    font-size: 1.6cqi;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.ui-id-card-name {
    margin: 0;
    color: var(--ui-id-card-ink);
    font-size: 4.2cqi;
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.04;
}

.ui-id-card-role {
    margin: 0.35em 0 0.45em;
    color: var(--ui-id-card-muted);
    font-size: 2.5cqi;
    font-weight: 600;
    line-height: 1.15;
}

.ui-id-card-meta {
    display: block;
    overflow: hidden;
    color: var(--ui-id-card-muted);
    font-size: 1.5cqi;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-id-card-qr {
    text-align: center;
}

.ui-id-card-qr img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border: 0.6cqi solid #fff;
    border-radius: 10%;
    background: #fff;
    box-shadow: 0 7px 18px rgba(15, 67, 88, 0.14);
}

.ui-id-card-qr span {
    display: block;
    margin-top: 0.35em;
    color: var(--ui-id-card-muted);
    font-size: 1.3cqi;
    font-weight: 700;
    line-height: 1.15;
}

.ui-id-card-footer {
    display: grid;
    grid-template-columns: 1.6fr 1fr 0.8fr;
    gap: 3%;
    margin: 0;
    padding-top: 2.4%;
    border-top: 2px solid rgba(21, 153, 209, 0.55);
}

.ui-id-card-footer > div {
    min-width: 0;
}

.ui-id-card-footer dt,
.ui-id-card-footer dd {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-id-card-footer dt {
    margin-bottom: 0.14em;
    color: var(--ui-id-card-muted);
    font-size: 1.25cqi;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.ui-id-card-footer dd {
    color: #31515f;
    font-size: 1.5cqi;
    font-weight: 700;
}

/* "Flip" hint: icon + words, bottom-right of the front */
.ui-id-card-hint {
    position: absolute;
    right: 3%;
    bottom: 2.2%;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    color: var(--ui-id-card-muted);
    font-size: 1.25cqi;
    font-weight: 700;
}

.ui-id-card-back {
    transform: rotateY(180deg);
}

.ui-id-card-document {
    position: relative;
    display: grid;
    flex: 1;
    min-height: 0;
    place-items: center;
    overflow: hidden;
    border-radius: inherit;
}

.ui-id-card-document > img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

/* Portrait document turned a quarter so it fills the landscape face (sized by ui.js) */
.ui-id-card-document > img.is-rotated {
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: none;
    transform: translate(-50%, -50%) rotate(-90deg);
}

.ui-id-card-empty {
    display: grid;
    max-width: 60%;
    place-items: center;
    color: var(--ui-id-card-muted);
    font-size: 1.9cqi;
    font-weight: 600;
    text-align: center;
}

.ui-id-card-empty .bi {
    margin-bottom: 0.25em;
    color: rgba(21, 153, 209, 0.55);
    font-size: 7cqi;
}

/* Modal holding an ID card: no panel around it, a round close button on its corner */
.ui-id-card-modal .modal-dialog {
    width: calc(100% - 2rem);
    max-width: 780px;
}

.ui-id-card-modal .modal-content {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.ui-id-card-modal .modal-body {
    padding: 0;
}

.ui-id-card-close {
    position: absolute;
    z-index: 5;
    top: -14px;
    right: -14px;
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(8, 121, 173, 0.18);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 8px 24px rgba(5, 25, 39, 0.3);
    color: #173642;
    font-size: 1.05rem;
    transition: transform 0.18s ease, background-color 0.18s ease;
}

.ui-id-card-close:hover,
.ui-id-card-close:focus-visible {
    background: #edf8fc;
    color: #0879ad;
    transform: scale(1.06);
}

/* Phone: the card is turned sideways to use the whole screen; it flips vertically */
@media (max-width: 575.98px) {
    .ui-id-card-modal .modal-dialog {
        width: calc(100% - 1rem);
        height: calc(100dvh - 1rem);
        margin: 0.5rem;
    }

    .ui-id-card-modal .modal-content,
    .ui-id-card-modal .modal-body {
        height: 100%;
    }

    .ui-id-card-modal .ui-id-card-stage {
        position: absolute;
        top: 50%;
        left: 50%;
        width: min(calc(100dvh - 2rem), calc((100vw - 2rem) * 1.586));
        transform: translate(-50%, -50%) rotate(-90deg);
    }

    .ui-id-card-modal .ui-id-card.is-flipped,
    .ui-id-card-modal .ui-id-card-back {
        transform: rotateX(180deg);
    }

    .ui-id-card-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ui-id-card,
    .ui-id-card-close {
        transition: none;
    }
}

/* Utility: Alpine content hidden by x-show stays hidden until Alpine starts */
[x-cloak] {
    display: none !important;
}

/* Utility: lets a flex child shrink below its content so text-truncate works */
.min-w-0 {
    min-width: 0 !important;
}

/* Utility: lets a flex child of a fixed-height column shrink so its content scrolls inside it */
.min-h-0 {
    min-height: 0 !important;
}

/* Inspector visit card: fixed hour column (date above a large hour) beside the visit details,
   so the hours of a day list line up and read at a glance on a phone. */
.ui-visit-time {
    flex: 0 0 5.75rem;
    text-align: center;
}

.ui-visit-hour {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* On phones the call and directions shortcuts share one row under the full-width open button. */
@media (max-width: 575.98px) {
    .ui-visit-links > .btn {
        flex: 1 1 0;
    }
}

/* Utility: bounded list inside a form (checkbox list of clients, users…) that scrolls on its own */
.ui-scroll-list {
    max-height: 16rem;
    overflow-y: auto;
}

/* Search
   Topbar field that opens the search dialog, stacked query + criteria fields,
   matched terms and result rows. */
.ui-topbar-search {
    flex: 1 1 auto;
    min-width: 12rem;
    max-width: 20rem;
}

/* Search field at the start of a list toolbar: grows up to a readable width, never
   pushes the other controls onto a second line */
.ui-toolbar-search {
    flex: 1 1 auto;
    min-width: 12rem;
    max-width: 22rem;
}

/* Query and extra criteria share one column; side actions stay outside it */
.ui-search-fields {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

/* Matched term: tint + weight, never colour alone */
.ui-match {
    padding: 0 0.0625rem;
    border-radius: 0.1875rem;
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-emphasis-color);
    font-weight: 600;
}

/* Result row: icon tile, title line with status, single-line details, trailing action.
   Every line truncates so all rows keep the same height. */
[data-ui-search] input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

.ui-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ui-result-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: 0.8125rem;
}

.ui-result-body > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-result-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ui-result-title {
    overflow: hidden;
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    text-overflow: ellipsis;
}

.ui-result-title:hover {
    color: var(--bs-emphasis-color);
}

.ui-result-head > .badge,
.ui-result-head > .ui-result-aside {
    flex-shrink: 0;
    max-width: 50%;
    margin-left: auto;
}

.ui-result-head > .badge > span,
.ui-result-head > .ui-result-aside {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ui-result-actions {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.ui-result-actions > .badge {
    overflow: hidden;
    max-width: min(50vw, 20rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-result-actions > .dropdown {
    flex: none;
}

/* Row actions stay clickable above the row's stretched link,
   and an open menu stacks above the following rows */
.ui-result > .dropdown > .btn,
.ui-result-actions > .dropdown > .btn {
    position: relative;
    z-index: 2;
}

.ui-result:has(.dropdown-menu.show) {
    z-index: 3;
}

/* Users asking for less transparency get opaque surfaces */
@media (prefers-reduced-transparency: reduce) {
    :root,
    [data-bs-theme] {
        --ui-glass-surface: var(--bs-body-bg);
        --ui-glass-chrome: var(--bs-body-bg);
        --ui-glass-bg: var(--ui-surface-raised);
        --ui-glass-filter: none;
    }
}


/* 5. THIRD-PARTY LIBRARIES
-------------------------------------------------- */

/* Leaflet */
.leaflet-container {
    border-radius: inherit;
    background-color: var(--ui-page-bg);
    font-family: var(--bs-body-font-family);
    font-size: 0.8125rem;
}

.leaflet-tile-pane {
    filter: var(--ui-map-tiles-filter);
}

.leaflet-bar {
    overflow: hidden;
    border: 1px solid var(--ui-glass-border) !important;
    border-radius: var(--bs-border-radius) !important;
    box-shadow: var(--bs-box-shadow) !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    width: 2rem;
    height: 2rem;
    border-bottom-color: var(--bs-border-color);
    background-color: var(--ui-glass-bg);
    color: var(--bs-emphasis-color);
    line-height: 2rem;
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.leaflet-bar a:hover {
    background-color: var(--ui-surface-raised);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background-color: var(--ui-glass-bg);
    color: var(--bs-body-color);
    box-shadow: var(--bs-box-shadow);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.leaflet-popup-content-wrapper {
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--bs-secondary-color);
}

.leaflet-control-attribution {
    border-top-left-radius: var(--bs-border-radius-sm);
    background-color: var(--ui-glass-bg) !important;
    color: var(--bs-secondary-color);
    font-size: 0.625rem;
}

.leaflet-control-attribution a {
    color: inherit;
}

/* Map pin (L.divIcon): status colour + status icon
   <div class="ui-map-pin ui-status-done"><i class="bi bi-check-lg"></i></div> */
.ui-map-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background-color: var(--ui-status, var(--bs-primary));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-status, var(--bs-primary)) 30%, transparent), 0 2px 6px rgba(0, 0, 0, 0.3);
    color: var(--ui-status-ink, #ffffff);
    font-size: 0.75rem;
}

/* Selected marker (e.g. the inspector picked in a form): larger, above the others */
.ui-map-pin.is-selected {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-status, var(--bs-primary)) 45%, transparent), 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Past appointment pin: desaturated, the icon still carries the status */
.ui-map-pin.is-past {
    filter: saturate(0.3);
    opacity: 0.8;
}

/* Map embedded in a page section (not a full work panel): fixed height, rounded like its card */
.ui-map {
    height: var(--ui-map-height, 18rem);
    overflow: hidden;
    border-radius: var(--bs-border-radius);
    box-shadow: inset 0 0 0 1px var(--bs-border-color);
}

/* markercluster */
.marker-cluster,
.marker-cluster div {
    background-color: transparent !important;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin: 5px 0 0 5px;
    border-radius: 50%;
    text-align: center;
    background-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 5px rgba(var(--bs-primary-rgb), 0.28), 0 2px 8px rgba(0, 0, 0, 0.25);
    color: var(--ui-on-primary);
    font: 600 0.75rem/30px var(--bs-body-font-family);
}

/* Planning map layers (rdv-planning.js): one cluster group per layer, each with its own bubble.
   Requests are rounded squares under the appointments, appointments round, forecasts round.
   L.divIcon className "marker-cluster ui-map-cluster ui-map-cluster-demande|rdv|prediction" */
.ui-map-cluster-demande { --ui-cluster: var(--ui-status-fix); --ui-cluster-ink: var(--ui-status-fix-ink); --ui-cluster-radius: 0.5rem; }
.ui-map-cluster-rdv { --ui-cluster: var(--ui-status-planned); --ui-cluster-ink: var(--ui-status-planned-ink); --ui-cluster-radius: 999px; }
.ui-map-cluster-prediction { --ui-cluster: var(--ui-status-progress); --ui-cluster-ink: var(--ui-status-progress-ink); --ui-cluster-radius: 999px; }

.marker-cluster.ui-map-cluster > div,
.ui-map-cluster-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.1875rem;
    border-radius: var(--ui-cluster-radius);
    background-color: var(--ui-cluster) !important;
    color: var(--ui-cluster-ink);
    font: 600 0.75rem/1 var(--bs-body-font-family);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.marker-cluster.ui-map-cluster > div {
    position: absolute;
    top: 50%;
    left: 50%;
    width: auto;
    min-width: 1.875rem;
    height: 1.875rem;
    margin: 0;
    padding: 0 0.4375rem;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-cluster) 30%, transparent), 0 2px 8px rgba(0, 0, 0, 0.25);
}

.marker-cluster.ui-map-cluster.is-large > div {
    height: 2.25rem;
    padding: 0 0.5625rem;
    font-size: 0.8125rem;
}

.ui-map-cluster > div > .bi,
.ui-map-cluster-swatch > .bi {
    font-size: 0.6875rem;
}

/* Legend sample of a bubble */
.ui-map-cluster-swatch {
    min-width: 1.75rem;
    height: 1rem;
    padding: 0 0.25rem;
    font-size: 0.625rem;
}

.ui-map-cluster-swatch > .bi {
    font-size: 0.5625rem;
}

/* Pin variants: request (rounded square), forecast stop (dashed), tour stop (number), home */
.ui-map-pin.is-demande,
.ui-status-icon.is-demande {
    border-radius: 0.375rem;
}

.ui-status-icon.is-demande {
    border-radius: 0.25rem;
}

.ui-map-pin.is-prediction {
    border-style: dashed;
}

.ui-map-pin.is-stop {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Several stops at the same place share one pin: the disc stretches into a pill ("1-3", "2, 5") */
.ui-map-pin.is-group {
    width: auto;
    min-width: 1.5rem;
    padding: 0 0.375rem;
    border-radius: 999px;
    white-space: nowrap;
}

.ui-map-pin.is-home,
.ui-status-icon.is-home {
    --ui-status: var(--bs-emphasis-color);
    --ui-status-ink: var(--bs-body-bg);
}

/* Request near the displayed tour: ring in the text colour, stays fully opaque */
.ui-map-pin.is-near,
.ui-status-icon.is-near {
    box-shadow: 0 0 0 2px var(--bs-body-bg), 0 0 0 4px var(--bs-emphasis-color), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Inspector colour swatch: the native colour input lies invisibly over the icon */
.ui-map-color {
    position: relative;
    display: inline-flex;
    border-radius: 50%;
    cursor: pointer;
}

.ui-map-color > input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.ui-map-color:hover > .ui-status-icon,
.ui-map-color:focus-within > .ui-status-icon {
    box-shadow: 0 0 0 2px var(--bs-body-bg), 0 0 0 4px var(--bs-border-color);
}

/* Tours other than the one unfolded in the panel fade back */
.ui-map-pin.is-dimmed {
    opacity: 0.35;
}

/* Sample of a day's line in the tours panel (solid, dashes, dots) */
.ui-map-day-line {
    flex-shrink: 0;
    width: 1.75rem;
    height: 0.375rem;
    color: var(--bs-secondary-color);
}

/* Tour mode (.ui-map-focus on the map container): other requests fade back, restored on hover */
.ui-map-focus .leaflet-demandes-pane > .leaflet-marker-icon:not(.ui-map-near) > * {
    opacity: 0.35;
    transition: opacity 0.15s ease;
}

.ui-map-focus .leaflet-demandes-pane > .leaflet-marker-icon:not(.ui-map-near):hover > * {
    opacity: 1;
}

/* Time beside a numbered tour stop (permanent L.tooltip) */
.leaflet-tooltip.ui-map-tour-label {
    padding: 0.0625rem 0.375rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background-color: var(--bs-body-bg);
    box-shadow: var(--bs-box-shadow-sm);
    color: var(--bs-emphasis-color);
    font: 600 0.6875rem/1.4 var(--bs-body-font-family);
    font-variant-numeric: tabular-nums;
}

.leaflet-tooltip.ui-map-tour-label::before {
    display: none;
}

/* Map refine panel: sections with the same heading row, separated by a rule.
   Hidden sections (x-show) keep their place in the sibling chain, so the rule stays on the right one. */
.ui-map-panel-section + .ui-map-panel-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--bs-border-color);
}

.ui-map-panel-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.75rem;
    margin-bottom: 0.5rem;
}

/* Tour timeline: numbers in one column joined by a thin line, two short lines per stop */
.ui-map-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ui-map-timeline > li {
    position: relative;
}

.ui-map-timeline > li:not(:last-of-type)::after {
    content: "";
    position: absolute;
    top: 1.625rem;
    bottom: -0.125rem;
    left: calc(0.875rem - 0.5px);
    width: 1px;
    background-color: var(--bs-border-color);
    pointer-events: none;
}

.ui-map-timeline-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
    padding: 0.25rem;
    border: 0;
    border-radius: var(--bs-border-radius-sm);
    background-color: transparent;
    color: inherit;
    text-align: start;
}

.ui-map-timeline-row:hover,
.ui-map-timeline-row:focus-visible {
    background-color: var(--bs-tertiary-bg);
}

.ui-map-timeline-row.is-past {
    opacity: 0.7;
}

.ui-map-timeline-mark {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--bs-secondary-color);
}

.ui-map-pin.is-compact {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 1.5px;
    box-shadow: none;
    font-size: 0.625rem;
}

/* Overlays floating over a work map: compact toolbar at the top (beside the zoom buttons),
   folding legend at the bottom left. Above the loading veil; the gaps let the map be dragged. */
.ui-map-overlay {
    position: absolute;
    z-index: 7;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.375rem;
    pointer-events: none;
}

.ui-map-overlay > * {
    pointer-events: auto;
}

.ui-map-overlay-top {
    top: 0.625rem;
    right: 0.625rem;
    left: 3.25rem;
}

.ui-map-overlay-bottom {
    bottom: 0.625rem;
    left: 0.625rem;
    max-width: calc(100% - 1.25rem);
    flex-direction: column;
}

.ui-map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--ui-glass-shadow), var(--bs-box-shadow-sm);
}

.ui-map-legend {
    max-height: min(22rem, 60vh);
    overflow: auto;
    padding: 0.5rem 0.75rem;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--ui-glass-shadow), var(--bs-box-shadow-sm);
}

.ui-map-legend .ui-chart-legend {
    flex-direction: column;
    flex-wrap: nowrap;
    font-size: 0.75rem;
}

@media (max-width: 575.98px) {
    .ui-map-overlay-top {
        right: 0.5rem;
        left: 3rem;
    }
}

/* Select2 (default theme) */
.select2-container {
    font-size: 0.875rem;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    min-height: calc(1.3125rem + 0.875rem + 2px);
    border: 1px solid var(--ui-input-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 0.75rem;
    padding-right: 2.25rem;
    color: var(--bs-emphasis-color);
    line-height: calc(1.3125rem + 0.875rem);
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--bs-tertiary-color);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    right: 0.5rem;
    height: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    width: 0.625rem;
    height: 0.625rem;
    margin: -0.3125rem 0 0 -0.3125rem;
    border: 0;
    background-color: var(--bs-secondary-color);
    -webkit-mask: var(--ui-chevron-mask) center / contain no-repeat;
    mask: var(--ui-chevron-mask) center / contain no-repeat;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection {
    border-color: var(--ui-focus-border);
    background-color: var(--ui-input-bg-focus);
    box-shadow: var(--ui-focus-ring);
}

.select2-container--default .select2-selection--multiple {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.375rem;
}

.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: contents;
}

.select2-container--default .select2-selection--multiple .select2-search--inline {
    flex: 1 1 4rem;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0.125rem 0.5rem 0.125rem 0.25rem;
    border: 0;
    border-radius: var(--bs-border-radius-pill);
    background-color: var(--bs-primary-bg-subtle);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bs-primary) 22%, transparent);
    color: var(--bs-primary-text-emphasis);
    font-size: 0.75rem;
    font-weight: 500;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    position: static;
    padding: 0 0.25rem;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.6;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: transparent;
    color: inherit;
    opacity: 1;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    padding: 0;
}

.select2-container .select2-search--inline .select2-search__field {
    height: 1.5rem;
    margin: 0 0 0 0.25rem;
    vertical-align: middle;
    line-height: 1.5rem;
    color: var(--bs-emphasis-color);
    font-family: inherit;
}

.select2-dropdown {
    overflow: hidden;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg) !important;
    background-color: var(--ui-glass-bg);
    box-shadow: var(--bs-box-shadow);
    color: var(--bs-body-color);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.select2-container--open .select2-dropdown--below {
    margin-top: 0.25rem;
}

.select2-container--open .select2-dropdown--above {
    margin-top: -0.25rem;
}

.select2-search--dropdown {
    padding: 0.5rem;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--ui-input-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    color: var(--bs-emphasis-color);
    outline: 0;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--ui-focus-border);
    box-shadow: var(--ui-focus-ring);
}

.select2-results__options {
    padding: 0.3125rem;
}

.select2-container--default .select2-results > .select2-results__options {
    max-height: 16rem;
}

.select2-results__option {
    padding: 0.4375rem 0.625rem;
    border-radius: var(--bs-border-radius-sm);
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--ui-active);
    color: var(--bs-emphasis-color);
}

.select2-container--default .select2-results__option--selected {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    font-weight: 500;
}

.select2-container--default .select2-results__group {
    padding: 0.5rem 0.625rem 0.25rem;
    color: var(--bs-tertiary-color);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Flatpickr */
.flatpickr-calendar {
    width: auto;
    padding: 0.5rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background: var(--ui-glass-bg);
    box-shadow: var(--bs-box-shadow);
    font-family: var(--bs-body-font-family);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.flatpickr-calendar::before,
.flatpickr-calendar::after {
    display: none;
}

/* Inside a modal the glass blur stacks on the modal's own blur and Chromium then
   drops the modal content; use the opaque raised surface instead. */
.modal .flatpickr-calendar {
    background: var(--ui-surface-raised);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    background: transparent;
    color: var(--bs-emphasis-color);
    fill: var(--bs-emphasis-color);
}

.flatpickr-current-month {
    font-size: 0.9375rem;
    font-weight: 600;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--bs-secondary-color);
    fill: var(--bs-secondary-color);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--bs-primary);
}

span.flatpickr-weekday {
    color: var(--bs-tertiary-color);
    font-size: 0.75rem;
    font-weight: 500;
}

.flatpickr-day {
    border-radius: var(--bs-border-radius-sm);
    color: var(--bs-body-color);
    font-size: 0.8125rem;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
    border-color: transparent;
    background: var(--ui-active);
}

.flatpickr-day.today {
    border-color: var(--bs-primary-border-subtle);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--bs-tertiary-color);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    border-color: var(--bs-primary);
    background: var(--bs-primary);
    color: var(--ui-on-primary);
    font-weight: 600;
}

.flatpickr-day.selected.startRange,
.flatpickr-day.startRange.startRange,
.flatpickr-day.selected.endRange,
.flatpickr-day.endRange.endRange {
    border-radius: var(--bs-border-radius-sm);
}

.flatpickr-day.inRange {
    border-color: transparent;
    background: var(--bs-primary-bg-subtle);
    box-shadow: -5px 0 0 var(--bs-primary-bg-subtle), 5px 0 0 var(--bs-primary-bg-subtle);
}

.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
    color: var(--bs-emphasis-color);
}

.flatpickr-time input:hover,
.flatpickr-time input:focus {
    background: var(--ui-active);
}

/* Quill (snow) */
.ql-toolbar.ql-snow,
.ql-container.ql-snow {
    border-color: var(--ui-input-border);
    font-family: var(--bs-body-font-family);
}

.ql-toolbar.ql-snow {
    padding: 0.375rem;
    border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
    background-color: var(--ui-input-bg);
}

.ql-container.ql-snow {
    border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    color: var(--bs-emphasis-color);
    font-size: 0.875rem;
}

.ql-container.ql-snow {
    height: auto;
}

.ql-editor {
    min-height: 9rem;
}

.ql-editor.ql-blank::before {
    color: var(--bs-tertiary-color);
    font-style: normal;
}

/* Information help (rapports.information.document): authored HTML read in the side panel.
   InformationContent::display() maps pasted colours to kit tones; this sets the type scale. */
.rapport-information-section {
    padding-bottom: 1.25rem;
    scroll-margin-top: 1rem;
}

.rapport-information-section + .rapport-information-section {
    padding-top: 1.25rem;
    border-top: 1px solid var(--bs-border-color-translucent);
}

.rapport-information-section:last-child {
    padding-bottom: 0;
}

/* Focused by script to bring the asked block into view; the highlight below marks it instead. */
.rapport-information-section:focus {
    outline: none;
}

.rapport-information-section > h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.rapport-information-section.information-highlight > h3 {
    padding-left: 0.625rem;
    border-left: 3px solid var(--bs-primary);
}

.rapport-information-prose {
    font-size: 0.9375rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.rapport-information-prose :is(h1, h2, h3, h4, h5, h6) {
    margin: 1.25rem 0 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
}

.rapport-information-prose :is(h1, h2) {
    font-size: 1rem;
}

.rapport-information-prose :is(p, ul, ol, dl, blockquote, pre, figure, .table-responsive) {
    margin-bottom: 0.75rem;
}

.rapport-information-prose :is(ul, ol) {
    padding-left: 1.25rem;
}

.rapport-information-prose li + li {
    margin-top: 0.25rem;
}

.rapport-information-prose blockquote {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--bs-border-color);
    border-radius: 0 var(--bs-border-radius-sm) var(--bs-border-radius-sm) 0;
    background: var(--bs-tertiary-bg);
}

.rapport-information-prose :is(div, blockquote, li, td, th) > :first-child,
.rapport-information-prose > :first-child {
    margin-top: 0;
}

.rapport-information-prose :is(div, blockquote, li, td, th) > :last-child,
.rapport-information-prose > :last-child {
    margin-bottom: 0;
}

.rapport-information-prose img {
    max-width: 100%;
    height: auto;
    border-radius: var(--bs-border-radius);
}

.rapport-information-prose .table {
    margin-bottom: 0;
}

.rapport-information-prose .table > thead > tr > th {
    white-space: normal;
}

.rapport-information-prose .ql-align-center { text-align: center; }
.rapport-information-prose .ql-align-right { text-align: right; }
.rapport-information-prose .ql-align-justify { text-align: justify; }
.rapport-information-prose .ql-indent-1 { padding-left: 1.5rem; }
.rapport-information-prose .ql-indent-2 { padding-left: 3rem; }
.rapport-information-prose .ql-indent-3 { padding-left: 4.5rem; }
.rapport-information-prose .ql-indent-4 { padding-left: 6rem; }
.rapport-information-prose .ql-indent-5 { padding-left: 7.5rem; }
.rapport-information-prose .ql-indent-6 { padding-left: 9rem; }
.rapport-information-prose .ql-indent-7 { padding-left: 10.5rem; }
.rapport-information-prose .ql-indent-8 { padding-left: 12rem; }

.ql-snow.ql-toolbar button,
.ql-snow .ql-picker-label {
    border-radius: var(--bs-border-radius-sm);
}

.ql-snow.ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active {
    background-color: var(--ui-active);
}

.ql-snow .ql-stroke {
    stroke: var(--bs-secondary-color);
}

.ql-snow .ql-fill {
    fill: var(--bs-secondary-color);
}

.ql-snow .ql-picker {
    color: var(--bs-secondary-color);
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-picker-label:hover .ql-stroke {
    stroke: var(--bs-primary-text-emphasis);
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill {
    fill: var(--bs-primary-text-emphasis);
}

.ql-snow .ql-picker-options {
    border: 1px solid var(--ui-glass-border) !important;
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-surface-raised);
    box-shadow: var(--bs-box-shadow);
}

.ql-snow a {
    color: var(--bs-link-color);
}

/* driver.js (guided tours) — popoverClass: "ui-tour" */
.driver-popover.ui-tour {
    --driver-popover-font-family: var(--bs-body-font-family);
    min-width: 18rem;
    max-width: 22rem;
    padding: 1rem 1.125rem;
    border: 1px solid var(--ui-glass-border);
    border-radius: var(--bs-border-radius-lg);
    background-color: var(--ui-glass-bg);
    box-shadow: var(--ui-highlight), var(--bs-box-shadow-lg);
    color: var(--bs-body-color);
    font-family: var(--bs-body-font-family);
    -webkit-backdrop-filter: var(--ui-glass-filter);
    backdrop-filter: var(--ui-glass-filter);
}

.driver-popover.ui-tour .driver-popover-title {
    padding-right: 1.75rem;
    color: var(--bs-emphasis-color);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.driver-popover.ui-tour .driver-popover-description {
    color: var(--bs-body-color);
    font-size: 0.875rem;
    line-height: 1.55;
}

.driver-popover.ui-tour .driver-popover-close-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: var(--bs-border-radius-sm);
    color: var(--bs-tertiary-color);
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.driver-popover.ui-tour .driver-popover-close-btn:hover,
.driver-popover.ui-tour .driver-popover-close-btn:focus-visible {
    background-color: var(--ui-active);
    color: var(--bs-emphasis-color);
}

.driver-popover.ui-tour .driver-popover-footer {
    gap: 0.75rem;
    margin-top: 1rem;
}

.driver-popover.ui-tour .driver-popover-progress-text {
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.driver-popover.ui-tour .driver-popover-navigation-btns {
    gap: 0.375rem;
}

.driver-popover.ui-tour .driver-popover-navigation-btns button + button {
    margin-left: 0;
}

.driver-popover.ui-tour .driver-popover-footer-btn {
    padding: 0.3125rem 0.75rem;
    border: 1px solid var(--ui-input-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--ui-input-bg);
    background-image: var(--ui-control-sheen);
    box-shadow: var(--ui-control-highlight), var(--bs-box-shadow-sm);
    color: var(--bs-emphasis-color);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.5;
    text-shadow: none;
}

.driver-popover.ui-tour .driver-popover-footer-btn:hover {
    background-color: var(--ui-input-bg-focus);
}

.driver-popover.ui-tour .driver-popover-footer-btn:focus-visible {
    box-shadow: var(--ui-focus-ring);
}

.driver-popover.ui-tour .driver-popover-next-btn {
    border-color: var(--bs-primary);
    background-color: var(--bs-primary);
    background-image: none;
    color: var(--ui-on-primary);
}

.driver-popover.ui-tour .driver-popover-next-btn:hover {
    background-color: color-mix(in srgb, var(--bs-primary) 90%, var(--ui-hover-mix));
}

.driver-popover.ui-tour .driver-popover-btn-disabled {
    display: none;
}

.driver-popover.ui-tour .driver-popover-arrow {
    border-width: 6px;
}

.driver-popover.ui-tour .driver-popover-arrow-side-left { border-color: transparent transparent transparent var(--ui-glass-bg); }
.driver-popover.ui-tour .driver-popover-arrow-side-right { border-color: transparent var(--ui-glass-bg) transparent transparent; }
.driver-popover.ui-tour .driver-popover-arrow-side-top { border-color: var(--ui-glass-bg) transparent transparent transparent; }
.driver-popover.ui-tour .driver-popover-arrow-side-bottom { border-color: transparent transparent var(--ui-glass-bg) transparent; }

/* Shared, inline microphone controls in CRM composers. */
.neo-dictation [data-dictation-indicator]:not([hidden]) { display: inline-flex; }
.neo-dictation-volume { width: 56px; height: 24px; }
.neo-dictation-error { width: min(18rem, calc(100vw - 2rem)); z-index: 5; }

/* PAC agréments: power curve legend keys, source extract, floating PAC bubble. */
.pac-legend-key { display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--bs-secondary-color); }
.pac-legend-key svg { width: 22px; height: 8px; }
.pac-proof { font-size: .875rem; line-height: 1.6; background: var(--bs-tertiary-bg); border-radius: var(--bs-border-radius-lg); padding: .875rem 1rem; white-space: pre-line; overflow-wrap: anywhere; }
.pac-points-table td, .pac-points-table th { white-space: nowrap; }
.pac-points-table tr.is-active > td { background-color: rgba(var(--bs-primary-rgb), .08); }
.pac-swatch { width: .5rem; height: .5rem; border-radius: 50%; display: inline-block; background: var(--bs-border-color); }
.pac-fab { position: fixed; right: 1.5rem; bottom: var(--pac-fab-bottom, 1.5rem); z-index: 1040; width: 3.25rem; height: 3.25rem; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 1.35rem; box-shadow: 0 .5rem 1.5rem rgba(15, 23, 42, .22); }
.pac-bubble { position: fixed; right: 1.5rem; bottom: calc(var(--pac-fab-bottom, 1.5rem) + 4rem); z-index: 1040; width: min(23rem, calc(100vw - 2rem)); max-height: calc(100dvh - var(--pac-fab-bottom, 1.5rem) - 5.5rem); display: flex; flex-direction: column; background: var(--bs-body-bg) !important; backdrop-filter: none !important; box-shadow: 0 1rem 2.5rem rgba(15, 23, 42, .22); }
.pac-bubble > .card-header { flex-shrink: 0; }
.pac-bubble > .card-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.pac-results > .list-group-item { padding: .625rem var(--bs-card-spacer-x); }
.pac-mini-chart { position: relative; height: 7.5rem; }
.pac-info-menu { width: min(23rem, calc(100vw - 2rem)); max-height: min(32rem, 70dvh); overflow-y: auto; padding: .75rem 1rem; }
@media (max-width: 575.98px) {
    .pac-fab { right: 1rem; bottom: var(--pac-fab-bottom, 1rem); }
    .pac-bubble { right: 1rem; left: 1rem; width: auto; bottom: calc(var(--pac-fab-bottom, 1rem) + 4rem); }
}
/* Keep the PAC button above the report floating tools and, below lg, above the pinned wizard nav. */
body:has(.ui-float-actions) { --pac-fab-bottom: 4.75rem; }
@media (max-width: 991.98px) {
    body:has(.ui-wizard[data-ui-wizard-on] .ui-wizard-nav.ui-wizard-fixed) { --pac-fab-bottom: 5.25rem; }
    body:has(.ui-wizard[data-ui-wizard-on] .ui-wizard-nav.ui-wizard-fixed):has(.ui-float-actions) { --pac-fab-bottom: 9rem; }
}
