/*
 * Canvemo theme: design tokens and Bootstrap 5.3 overrides.
 *
 * Load order (canvemo/layout :: head): Inter -> bootstrap.min.css -> canvemo-theme.css -> canvemo-layout.css
 * (-> canvemo-modules.css on the authenticated shell). Bootstrap components are themed through
 * their CSS variables rather than !important, so utilities such as .border-0 or .form-control-sm keep working.
 *
 * Light/dark: <html data-bs-theme="light|dark"> is set by /js/canvemo-theme.js before first paint.
 * Every colour below is a token, and section 1b redefines the tokens for dark mode.
 * Rule of thumb: use --cv-surface for backgrounds of panels, --cv-white only for text/icons on a
 * coloured fill (it stays white in both themes).
 */

/* ------------------------------------------------------------------ */
/* 1. Tokens (light)                                                  */
/* ------------------------------------------------------------------ */
:root {
    /* Brand */
    --cv-primary: #418B45;
    --cv-primary-rgb: 65, 139, 69;
    --cv-primary-hover: #2F6E33;
    --cv-primary-active: #2A5E35;
    --cv-primary-text: #2A5E35;          /* primary-coloured text on surfaces (AA) */
    /* Filled primary buttons (white text): Canvemo Green, 4.2:1, accepted for bold button text */
    --cv-primary-btn: #418B45;
    --cv-primary-btn-hover: #2F6E33;
    --cv-primary-btn-active: #2A5E35;
    --cv-primary-subtle: #EAF4EA;
    --cv-primary-border-subtle: #BFDCC1;
    --cv-accent: #E23122;
    --cv-accent-rgb: 226, 49, 34;
    --cv-accent-hover: #BD1B0D;
    --cv-navy: #1D293F;                  /* brand navy: app header, CTA band */
    --cv-navy-rgb: 29, 41, 63;

    /* Neutrals */
    --cv-white: #FFFFFF;
    --cv-bg: #F6F8FA;
    --cv-surface: #FFFFFF;
    --cv-surface-muted: #F9FAFB;
    --cv-surface-sunken: #F1F3F6;
    --cv-border: #E2E5EA;
    --cv-border-strong: #CDD2D9;
    --cv-heading: #1D293F;
    --cv-text: #1D293F;
    --cv-text-muted: #5F6672;            /* 5.6:1 on white (AA for body text) */
    --cv-text-subtle: #8A9099;           /* decorative / large text only */
    --cv-input-bg: #F7F8FA;
    --cv-input-border: #CDD2D9;

    /* Status: fill colour, and text colour for soft (tinted) badges */
    --cv-success: #418B45;
    --cv-success-rgb: 65, 139, 69;
    --cv-success-text: #2A5E35;
    --cv-danger: #C62828;
    --cv-danger-rgb: 198, 40, 40;
    --cv-danger-text: #A32020;
    --cv-warning: #E0A100;
    --cv-warning-rgb: 224, 161, 0;
    --cv-warning-text: #7A5200;
    --cv-info: #2F7EA8;
    --cv-info-rgb: 47, 126, 168;
    --cv-info-text: #1F5E80;
    --cv-neutral-rgb: 95, 102, 114;
    --cv-neutral-text: #4B515B;

    /* Data visualisation (read by charts through getComputedStyle) */
    --cv-chart-1: #418B45;
    --cv-chart-2: #2F7EA8;
    --cv-chart-3: #E0A100;
    --cv-chart-4: #C62828;
    --cv-chart-5: #7B5EA7;
    --cv-chart-6: #8A9099;
    /* Categorical series (HR home widgets), in this fixed order; validated for colour-vision deficiency on the light
       and dark surfaces. Slot 5 is below 3:1 on white, so charts using it carry a legend and a data table. */
    --cv-series-1: #418B45;
    --cv-series-2: #2A78D6;
    --cv-series-3: #EB6834;
    --cv-series-4: #6250D6;
    --cv-series-5: #EDA100;
    --cv-series-other: #8A9099;
    /* Dashboard data (HR home): one hue, navy. data-1 is every main series, data-2 a second series or "planned",
       data-track the empty part of a bar. Green (--cv-primary) marks only "now" (today, this month); red and amber
       only alerts. data-1 is 10:1 on white, data-2 3.2:1 (graphics only, never text). */
    --cv-data-1: #34425E;
    --cv-data-1-rgb: 52, 66, 94;
    --cv-data-2: #8592A8;
    --cv-data-track: #E9EDF2;

    /* Initials avatars (white text on each is >= 4.5:1) */
    --cv-avatar-0: #2F6E33;
    --cv-avatar-1: #23658A;
    --cv-avatar-2: #8A5A00;
    --cv-avatar-3: #A32020;
    --cv-avatar-4: #6A4C93;
    --cv-avatar-5: #4B5563;

    /* Shape & elevation */
    --cv-radius-sm: 4px;
    --cv-radius: 6px;
    --cv-radius-lg: 10px;
    --cv-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --cv-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
    --cv-shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
    --cv-focus-ring: 0 0 0 0.2rem rgba(var(--cv-primary-rgb), 0.3);
    --cv-transition: 0.2s ease-in-out;

    /* Campaign emails (t180): the email's own palette, light and as a mail app in dark mode shows it
       (CampaignEmailRenderer); the campaign preview uses it in both app themes, so it is not redefined in 1b */
    --cv-mail-green: #418B45;
    --cv-mail-page: #F6F8FA;
    --cv-mail-card: #FFFFFF;
    --cv-mail-text: #1D293F;
    --cv-mail-muted: #5F6672;
    --cv-mail-border: #E2E5EA;
    --cv-mail-link: #2A5E35;
    --cv-mail-dark-page: #0F1623;
    --cv-mail-dark-card: #172033;
    --cv-mail-dark-text: #E2E7EE;
    --cv-mail-dark-muted: #A6B0BF;
    --cv-mail-dark-border: #2A3750;
    --cv-mail-dark-link: #8BD08F;

    /* Typography (Inter is self-hosted from /webjars/fontsource__inter) */
    --cv-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --cv-font-size: 14px;

    /* Bootstrap mapping: makes .text-primary, .bg-primary, .border-primary, links, focus, etc. on-brand */
    --bs-primary: var(--cv-primary);
    --bs-primary-rgb: var(--cv-primary-rgb);
    --bs-primary-text-emphasis: var(--cv-primary-text);
    --bs-primary-bg-subtle: var(--cv-primary-subtle);
    --bs-primary-border-subtle: var(--cv-primary-border-subtle);
    --bs-success: var(--cv-success);
    --bs-success-rgb: var(--cv-success-rgb);
    --bs-danger: var(--cv-danger);
    --bs-danger-rgb: var(--cv-danger-rgb);
    --bs-warning: var(--cv-warning);
    --bs-warning-rgb: var(--cv-warning-rgb);
    --bs-info: var(--cv-info);
    --bs-info-rgb: var(--cv-info-rgb);
    --bs-dark: var(--cv-navy);
    --bs-dark-rgb: var(--cv-navy-rgb);
    --bs-body-font-family: var(--cv-font);
    --bs-body-font-size: var(--cv-font-size);
    --bs-body-color: var(--cv-text);
    --bs-body-bg: var(--cv-bg);
    --bs-emphasis-color: var(--cv-heading);
    --bs-heading-color: var(--cv-heading);
    --bs-secondary-color: var(--cv-text-muted);
    --bs-secondary-bg: var(--cv-surface-sunken);
    --bs-tertiary-bg: var(--cv-surface-muted);
    --bs-border-color: var(--cv-border);
    --bs-border-radius: var(--cv-radius);
    --bs-border-radius-sm: var(--cv-radius-sm);
    --bs-border-radius-lg: var(--cv-radius-lg);
    --bs-link-color: var(--cv-primary-text);
    --bs-link-color-rgb: 42, 94, 53;
    --bs-link-hover-color: var(--cv-primary-hover);
    --bs-link-hover-color-rgb: 47, 110, 51;
    --bs-focus-ring-color: rgba(var(--cv-primary-rgb), 0.3);
    --bs-box-shadow-sm: var(--cv-shadow-sm);
    --bs-box-shadow: var(--cv-shadow);
    --bs-box-shadow-lg: var(--cv-shadow-lg);
}

/* ------------------------------------------------------------------ */
/* 1b. Tokens (dark). Same names, so every rule below adapts.         */
/* Declared after :root with equal specificity, so it wins on <html>.  */
/* ------------------------------------------------------------------ */
[data-bs-theme="dark"] {
    color-scheme: dark;

    --cv-primary: #4F9F54;
    --cv-primary-rgb: 79, 159, 84;
    --cv-primary-hover: #5DB062;
    --cv-primary-active: #6BBD70;
    --cv-primary-text: #8BD08F;
    /* White on the dark green (#4F9F54) was 3.27:1: buttons take a deeper green, 4.9:1, darker still on hover */
    --cv-primary-btn: #3B7F40;
    --cv-primary-btn-hover: #2F6E33;
    --cv-primary-btn-active: #2A5E35;
    --cv-primary-subtle: #1B2E20;
    --cv-primary-border-subtle: #2F5734;
    --cv-navy: #0B111C;
    --cv-navy-rgb: 11, 17, 28;

    --cv-bg: #0F1623;
    --cv-surface: #172033;
    --cv-surface-muted: #1C273B;
    --cv-surface-sunken: #131B2B;
    --cv-border: #2A3750;
    --cv-border-strong: #3A4966;
    --cv-heading: #F1F4F8;
    --cv-text: #E2E7EE;
    --cv-text-muted: #A6B0BF;
    --cv-text-subtle: #7C889B;
    --cv-input-bg: #111A2B;
    --cv-input-border: #34425C;

    --cv-success: #4F9F54;
    --cv-success-rgb: 79, 159, 84;
    --cv-success-text: #8BD08F;
    --cv-danger: #E05252;
    --cv-danger-rgb: 224, 82, 82;
    --cv-danger-text: #F19A9A;
    --cv-warning: #E8B020;
    --cv-warning-rgb: 232, 176, 32;
    --cv-warning-text: #F2CC6B;
    --cv-info: #4A9BC7;
    --cv-info-rgb: 74, 155, 199;
    --cv-info-text: #8EC6E4;
    --cv-neutral-rgb: 166, 176, 191;
    --cv-neutral-text: #C3CAD5;

    --cv-chart-1: #5DB062;
    --cv-chart-2: #4A9BC7;
    --cv-chart-3: #E8B020;
    --cv-chart-4: #E05252;
    --cv-chart-5: #A08BD0;
    --cv-chart-6: #7C889B;
    --cv-series-1: #4F9F54;
    --cv-series-2: #3987E5;
    --cv-series-3: #D95926;
    --cv-series-4: #9085E9;
    --cv-series-5: #C98500;
    --cv-series-other: #7C889B;
    --cv-data-1: #C3CDDD;
    --cv-data-1-rgb: 195, 205, 221;
    --cv-data-2: #6F7C93;
    --cv-data-track: #222D43;

    --cv-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --cv-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    --cv-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

    --bs-link-color-rgb: 139, 208, 143;
    --bs-link-hover-color-rgb: 168, 222, 171;
}

/* ------------------------------------------------------------------ */
/* 2. Base                                                            */
/* ------------------------------------------------------------------ */
body {
    background-color: var(--cv-bg);
    color: var(--cv-text);
    font-family: var(--cv-font);
    font-size: var(--cv-font-size);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--cv-heading);
    font-weight: 700;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.0625rem; }
h6 { font-size: 0.9375rem; }

a {
    color: var(--cv-primary-text);
    text-decoration: none;
    transition: color var(--cv-transition);
}

a:hover {
    color: var(--cv-primary-hover);
}

:focus-visible {
    outline: 2px solid var(--cv-primary);
    outline-offset: 2px;
}

.text-muted {
    color: var(--cv-text-muted) !important;
}

.text-primary {
    color: var(--cv-primary-text) !important;
}

/* Bootstrap's .bg-white is literal white; in the app it means "panel surface" */
.bg-white {
    background-color: var(--cv-surface) !important;
}

/* ------------------------------------------------------------------ */
/* 3. Buttons                                                         */
/* ------------------------------------------------------------------ */
.btn {
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--cv-radius);
    --bs-btn-focus-box-shadow: var(--cv-focus-ring);
    transition: background-color var(--cv-transition), border-color var(--cv-transition),
                color var(--cv-transition), box-shadow var(--cv-transition);
}

/* Buttons are as tall as the fields beside them (--cv-field-height), with body-size text */
.btn:not(.btn-sm):not(.btn-lg):not(.btn-link):not(.btn-close) {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-padding-x: 0.875rem;
    --bs-btn-font-size: var(--cv-font-size);
    --bs-btn-line-height: 1.4;
    min-height: var(--cv-field-height);
}

.btn-sm {
    --bs-btn-padding-y: 0.1875rem;
    --bs-btn-padding-x: 0.625rem;
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-line-height: 1.35;
}

@media (pointer: coarse) {
    .btn-sm {
        --bs-btn-padding-y: 0.3125rem;
    }
}

.btn-primary,
.btn-success {
    --bs-btn-bg: var(--cv-primary-btn);
    --bs-btn-border-color: var(--cv-primary-btn);
    --bs-btn-color: var(--cv-white);
    --bs-btn-hover-bg: var(--cv-primary-btn-hover);
    --bs-btn-hover-border-color: var(--cv-primary-btn-hover);
    --bs-btn-hover-color: var(--cv-white);
    --bs-btn-active-bg: var(--cv-primary-btn-active);
    --bs-btn-active-border-color: var(--cv-primary-btn-active);
    --bs-btn-active-color: var(--cv-white);
    --bs-btn-disabled-bg: var(--cv-primary-btn);
    --bs-btn-disabled-border-color: var(--cv-primary-btn);
    --bs-btn-disabled-color: var(--cv-white);
}

/* Secondary = neutral (Cancel / Close). Never brand red: that made "Cancel" look destructive. */
.btn-secondary {
    --bs-btn-bg: var(--cv-surface);
    --bs-btn-border-color: var(--cv-border-strong);
    --bs-btn-color: var(--cv-text);
    --bs-btn-hover-bg: var(--cv-surface-muted);
    --bs-btn-hover-border-color: var(--cv-text-subtle);
    --bs-btn-hover-color: var(--cv-heading);
    --bs-btn-active-bg: var(--cv-border);
    --bs-btn-active-border-color: var(--cv-text-subtle);
    --bs-btn-active-color: var(--cv-heading);
    --bs-btn-disabled-bg: var(--cv-surface);
    --bs-btn-disabled-border-color: var(--cv-border);
    --bs-btn-disabled-color: var(--cv-text-subtle);
}

/* Brand red, for marketing call-outs only (never for destructive actions; use .btn-danger) */
.btn-accent {
    --bs-btn-bg: var(--cv-accent);
    --bs-btn-border-color: var(--cv-accent);
    --bs-btn-color: var(--cv-white);
    --bs-btn-hover-bg: var(--cv-accent-hover);
    --bs-btn-hover-border-color: var(--cv-accent-hover);
    --bs-btn-hover-color: var(--cv-white);
    --bs-btn-active-bg: var(--cv-accent-hover);
    --bs-btn-active-border-color: var(--cv-accent-hover);
    --bs-btn-active-color: var(--cv-white);
}

.btn-danger {
    --bs-btn-bg: var(--cv-danger);
    --bs-btn-border-color: var(--cv-danger);
    --bs-btn-hover-bg: #A32020;
    --bs-btn-hover-border-color: #A32020;
    --bs-btn-active-bg: #8E1C1C;
    --bs-btn-active-border-color: #8E1C1C;
}

.btn-outline-primary {
    --bs-btn-color: var(--cv-primary-text);
    --bs-btn-border-color: var(--cv-primary);
    --bs-btn-hover-bg: var(--cv-primary);
    --bs-btn-hover-border-color: var(--cv-primary);
    --bs-btn-hover-color: var(--cv-white);
    --bs-btn-active-bg: var(--cv-primary-active);
    --bs-btn-active-border-color: var(--cv-primary-active);
    --bs-btn-active-color: var(--cv-white);
}

.btn-outline-secondary {
    --bs-btn-color: var(--cv-text-muted);
    --bs-btn-border-color: var(--cv-border-strong);
    --bs-btn-hover-bg: var(--cv-surface-muted);
    --bs-btn-hover-border-color: var(--cv-text-subtle);
    --bs-btn-hover-color: var(--cv-heading);
    --bs-btn-active-bg: var(--cv-primary-subtle);
    --bs-btn-active-border-color: var(--cv-primary);
    --bs-btn-active-color: var(--cv-primary-text);
}

.btn-outline-danger {
    --bs-btn-color: var(--cv-danger-text);
    --bs-btn-border-color: var(--cv-danger);
    --bs-btn-hover-bg: var(--cv-danger);
    --bs-btn-hover-border-color: var(--cv-danger);
    --bs-btn-active-bg: var(--cv-danger);
    --bs-btn-active-border-color: var(--cv-danger);
}

.btn-link {
    --bs-btn-color: var(--cv-primary-text);
    --bs-btn-hover-color: var(--cv-primary-hover);
}

/* Request in flight (set by canvemo-app.js): spinner replaces the label, clicks are blocked */
.btn.is-busy {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn.is-busy::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 1rem;
    height: 1rem;
    margin: auto;
    border: 2px solid var(--bs-btn-color);
    border-right-color: transparent;
    border-radius: 50%;
    animation: cv-spin 0.7s linear infinite;
}

@keyframes cv-spin {
    to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* 4. Forms                                                           */
/* ------------------------------------------------------------------ */
.form-control,
.form-select {
    background-color: var(--cv-input-bg);
    border-color: var(--cv-input-border);
    color: var(--cv-text);
}

/*
 * Compact fields: body-size text (Bootstrap's 1rem is larger than the 14px UI text) and slim padding.
 * Every single-line control (text, date, time, select, input-group addon and button) is exactly
 * --cv-field-height tall, whatever the browser does with date and time pickers, so a row of mixed
 * controls lines up. -sm steps down to --cv-field-height-sm; -lg is left as Bootstrap has it.
 * On touch screens fields grow to a comfortable target and 16px text (iOS zooms into smaller text).
 */
:root {
    --cv-field-height: 1.875rem;         /* 30px */
    --cv-field-height-sm: 1.625rem;      /* 26px */
    --cv-field-font-size: var(--cv-font-size);
}

@media (pointer: coarse) {
    :root {
        --cv-field-height: 2.375rem;
        --cv-field-height-sm: 2.125rem;
        --cv-field-font-size: 16px;
    }
}

.form-control:where(:not(.form-control-lg)),
.form-select:where(:not(.form-select-lg)),
.input-group-text,
.input-group > .btn:where(:not(.btn-sm):not(.btn-lg)) {
    font-size: var(--cv-field-font-size);
    line-height: 1.4;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.form-control:where(:not(textarea):not(.form-control-lg):not(.form-control-sm):not([type="file"]):not([type="color"])),
.form-select:where(:not(.form-select-lg):not(.form-select-sm):not([multiple]):not([size])),
.input-group:where(:not(.input-group-sm):not(.input-group-lg)) > .input-group-text,
.input-group:where(:not(.input-group-sm):not(.input-group-lg)) > .btn:where(:not(.btn-sm):not(.btn-lg)) {
    height: var(--cv-field-height);
}

/* Inputs styled as a read-only box (e.g. the COR selector's value) keep the text on one line */
span.form-control {
    display: block;
    line-height: calc(var(--cv-field-height) - 0.5rem - 2px);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.form-control:where(:not(.form-control-lg)),
.input-group-text,
.input-group > .btn:where(:not(.btn-sm):not(.btn-lg)) {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
}

.form-select:where(:not(.form-select-lg)) {
    padding-left: 0.625rem;
    padding-right: 2rem;
    background-position: right 0.625rem center;
}

textarea.form-control {
    min-height: calc(1.5em + 0.5rem + calc(var(--bs-border-width) * 2));
}

.form-control-sm,
.form-select-sm,
.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    font-size: 0.8125rem;
    padding-top: 0.1875rem;
    padding-bottom: 0.1875rem;
}

.form-control-sm,
.input-group-sm > .form-control,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.form-select-sm,
.input-group-sm > .form-select {
    padding-left: 0.5rem;
    padding-right: 1.75rem;
    background-position: right 0.5rem center;
}

.form-control-sm,
textarea.form-control-sm {
    min-height: calc(1.5em + 0.375rem + calc(var(--bs-border-width) * 2));
}

input.form-control-sm:where(:not([type="file"])),
.form-select-sm,
.input-group-sm > .form-control:where(:not(textarea)),
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
    height: var(--cv-field-height-sm);
}

@media (pointer: coarse) {
    .form-control-sm,
    .form-select-sm,
    .input-group-sm > .form-control,
    .input-group-sm > .form-select {
        font-size: 16px;
    }
}

.form-control:focus,
.form-select:focus {
    background-color: var(--cv-surface);
    border-color: var(--cv-primary);
    box-shadow: var(--cv-focus-ring);
    color: var(--cv-text);
}

.form-control::placeholder {
    color: var(--cv-text-subtle);
}

/* Disabled controls read as read-only: sunken, muted text, no dropdown affordance on hover */
.form-control:disabled,
.form-select:disabled {
    background-color: var(--cv-surface-sunken);
    border-color: var(--cv-border);
    color: var(--cv-text-muted);
    opacity: 1;
    cursor: not-allowed;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--cv-heading);
    margin-bottom: 0.25rem;
}

/* .form-label.small was used for compact forms; labels are compact everywhere now */
.form-label.small {
    font-size: 0.8125rem;
}

.form-text {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--cv-text-muted);
}

/* A field wrapper (label + control) in a plain stack of fields: 12px between fields rather than 16px */
.mb-3:has(> .form-label) {
    margin-bottom: 0.75rem !important;
}

.form-check {
    min-height: 1.25rem;
    margin-bottom: 0.25rem;
}

.form-check-input {
    background-color: var(--cv-input-bg);
    border-color: var(--cv-input-border);
}

.form-check-input:checked {
    background-color: var(--cv-primary);
    border-color: var(--cv-primary);
}

.form-check-input:focus {
    border-color: var(--cv-primary);
    box-shadow: var(--cv-focus-ring);
}

.form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%2865, 139, 69, 0.5%29'/%3e%3c/svg%3e");
}

.input-group-text {
    background-color: var(--cv-surface-muted);
    border-color: var(--cv-input-border);
    color: var(--cv-text-muted);
}

.form-control-plaintext {
    color: var(--cv-text);
}

/* ------------------------------------------------------------------ */
/* 4b. Form layout: sections and the field grid                       */
/*                                                                    */
/*   <section class="form-section">                                   */
/*     <header class="form-section-head">                             */
/*       <div><h3 class="form-section-title">…</h3>                   */
/*            <p class="form-section-desc">…</p></div>                */
/*       <div class="form-section-actions">buttons</div>              */
/*     </header>                                                      */
/*     <div class="form-grid">                                        */
/*       <div class="field"> label, control, [.form-text] </div>      */
/*     </div>                                                         */
/*   </section>                                                       */
/*                                                                    */
/* The grid's columns follow the width of the section (a container    */
/* query), not the viewport: 1 column on a phone or in a narrow       */
/* column, up to 4 on a wide screen. Each .field takes three rows of  */
/* the grid (label, control, help) through subgrid, so labels that    */
/* wrap or help texts never push a neighbour's control out of line.   */
/* Spans: .field-short (dates, times, codes: two side by side even on */
/* a phone), .field-wide (two columns), .field-full (the whole row).  */
/* ------------------------------------------------------------------ */
.form-section,
.form-grid-host,
.modal-body {
    container-type: inline-size;
}

/* On a page, each section is a card with its title in a header row (design: HR > Employee profile,
   Manage > Settings). Inside dialogs sections stay flat. */
#content .form-section {
    padding: 1.25rem;
    background-color: var(--cv-surface);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius-lg);
    box-shadow: var(--cv-shadow-sm);
}

#content .form-section > .form-section-head {
    margin: -1.25rem -1.25rem 1.125rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--cv-border);
}

/* Settings-style pages (Manage, REGES, timesheet and payroll settings) give each titled section its own card too.
   .section-plain opts a section out when it already holds cards (Time off balances). */
#content section[aria-labelledby]:has(> .form-section-title, > div > .form-section-title):not(.form-section):not(.section-plain) {
    padding: 1.25rem;
    background-color: var(--cv-surface);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius-lg);
    box-shadow: var(--cv-shadow-sm);
}

/* Two settings cards side by side, the second twice as wide (Manage > Settings: working week | public holidays) */
.settings-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (min-width: 992px) {
    .settings-pair {
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    }
}

.form-section + .form-section,
.form-section-pair + .form-section,
.form-section + .form-section-pair {
    margin-top: 1.25rem;
}

.modal .form-section + .form-section,
.modal .form-section-pair + .form-section,
.modal .form-section + .form-section-pair {
    padding-top: 1.25rem;
    border-top: 1px solid var(--cv-border);
}

.form-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.875rem;
}

.form-section-head > :first-child {
    min-width: 0;
    flex: 1 1 16rem;
}

.form-section-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--cv-heading);
}

.form-section-title > .fa-solid {
    margin-right: 0.5rem;
    color: var(--cv-primary-text);
    font-size: 0.875rem;
}

.form-section-title > .badge {
    margin-left: 0.5rem;
    vertical-align: 0.0625rem;
}

.form-section-desc {
    max-width: 60rem;
    margin: 0.125rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--cv-text-muted);
}

.form-section-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* A heading inside a section's grid (e.g. "Work permit"), on a row of its own */
.form-subhead {
    grid-column: 1 / -1;
    margin: 0.25rem 0 0.625rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--cv-border);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cv-heading);
}

.form-subhead > h4 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

.form-subhead .form-section-desc {
    font-weight: 400;
}

/* Two sections side by side when each gets at least 24rem (e.g. Bank details | Emergency contact), else stacked */
.form-section-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
    gap: 1.25rem;
}

.form-section-pair > .form-section + .form-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

#content .form-section-pair > .form-section + .form-section {
    padding-top: 1.25rem;
    border-top: 1px solid var(--cv-border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1rem;
    row-gap: 0;
    align-items: start;
}

/* Anything that is not a field (a note, an alert, a sub-heading) takes a row of its own */
.form-grid > :not(.field):not(.field-group) {
    grid-column: 1 / -1;
}

/* Wraps fields shown and hidden together (e.g. the termination date and its legal basis) */
.field-group {
    display: contents;
}

.field {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    grid-column: 1 / -1;
    min-width: 0;
    padding-bottom: 0.75rem;
}

.field > * {
    grid-row: 2;
    min-width: 0;
}

.field > .form-label {
    grid-row: 1;
    align-self: end;
}

.field > .form-text,
.field > .invalid-feedback {
    grid-row: 3;
}

/* A help icon right after a field's label sits on the label's line, not in the control's row */
.field:has(> .help-icon) {
    grid-template-columns: auto minmax(0, 1fr);
}

.field:has(> .help-icon) > * {
    grid-column: 1 / -1;
}

.field:has(> .help-icon) > .form-label {
    grid-column: 1;
}

.field > .help-icon {
    grid-row: 1;
    grid-column: 2;
    justify-self: start;
    align-self: end;
    /* centred on the label's line: the 30px button over an 18px label and its .25rem margin */
    margin: 0 0 calc(0.25rem - 6px) 0.25rem;
}

/* A read-only value in place of an input: as tall as an input, so rows keep their rhythm */
.field > .form-control-plaintext {
    min-height: var(--cv-field-height);
    padding: 0.25rem 0;
    font-weight: 600;
    line-height: 1.4;
}

/* A read-only value that is not set reads as a dash, not as a gap */
.field > .form-control-plaintext:empty::before {
    content: "—";
    font-weight: 400;
    color: var(--cv-text-subtle);
}

.field > .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--cv-field-height);
    margin: 0;
}

.field > .form-check .form-check-input {
    margin-top: 0;
}

.field-short {
    grid-column: span 1;
}

@container (min-width: 28rem) {
    .field {
        grid-column: span 1;
    }

    .field-wide {
        grid-column: span 2;
    }

    .field-full {
        grid-column: 1 / -1;
    }
}

@container (min-width: 44rem) {
    .form-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* A form that reads better in two columns, whatever the width (e.g. a modal) */
    .form-grid.form-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container (min-width: 60rem) {
    .form-grid:not(.form-grid-2):not(.form-grid-3):not(.form-stack) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ------------------------------------------------------------------ */
/* A one-column form (employee profile, onboarding): every field on a */
/* row of its own, read top to bottom. .half puts two fields that     */
/* belong together side by side (first and last name, county and      */
/* locality) once the section is 28rem wide; .keep keeps a short pair */
/* side by side even on a phone (series and number, start and end).   */
/* Inputs are as wide as their data: .input-xs … .input-lg.           */
/* ------------------------------------------------------------------ */
.form-grid.form-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-stack > .field,
.form-stack > .field-group > .field,
.form-stack > [data-show-when] > .field {
    grid-column: 1 / -1;
}

.form-stack > .field.keep,
.form-stack > .field-group > .field.keep,
.form-stack > [data-show-when] > .field.keep {
    grid-column: span 1;
}

@container (min-width: 28rem) {
    .form-stack > .field.half,
    .form-stack > .field-group > .field.half,
    .form-stack > [data-show-when] > .field.half {
        grid-column: span 1;
    }
}

/* A field with more lines than label, control and help (an error, a note, "Needed for REGES-Online") takes more
   rows, so they stack under the control instead of opening a column beside it: everything after the control
   takes the next free row (.field > * would put it on the control's row) */
.field > .form-label ~ :not(.help-icon) ~ * { grid-row: auto; }
.field:has(> :nth-child(4)) { grid-row: span 4; }
.field:has(> :nth-child(5)) { grid-row: span 5; }
.field:has(> :nth-child(6)) { grid-row: span 6; }

.field > .choice-seg {
    justify-self: start;
}

/* Fields shown or hidden together inside a stack (data-show-when) keep the stack's grid */
.form-stack > [data-show-when] {
    display: contents;
}

.form-stack > [data-show-when].d-none {
    display: none !important;
}

.input-xs { max-width: 6.5rem; }
.input-sm { max-width: 10.5rem; }
.input-md { max-width: 16rem; }
.input-lg { max-width: 28rem; }

/* "required" (where most fields are optional, the profile) or "optional" (where most are required, onboarding) */
.field-mark {
    margin-left: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cv-text-muted);
}

/* Where a value came from (birth date from the CNP, the bank from the IBAN) */
.field-source {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cv-text-muted);
}

.field-note {
    display: flex;
    gap: 0.375rem;
    align-items: baseline;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--cv-text-muted);
}

/* Something a later step needs (REGES-Online): a status, with an icon and words */
.field-need {
    display: flex;
    gap: 0.375rem;
    align-items: baseline;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cv-warning-text);
}

/* A field the server or the browser refused: red border, and the message under it with an icon */
.field-error {
    display: flex;
    gap: 0.375rem;
    align-items: baseline;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cv-danger-text);
}

.form-control[aria-invalid="true"],
.form-select[aria-invalid="true"],
.choice-seg[aria-invalid="true"] {
    border-color: var(--cv-danger);
    box-shadow: 0 0 0 1px var(--cv-danger);
}

/* Two to five options, all in view: real radio buttons, the labels drawn as one segmented control */
.choice-seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    background-color: var(--cv-surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--cv-radius);
}

.choice-seg > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choice-seg > label {
    display: inline-flex;
    align-items: center;
    min-height: calc(var(--cv-field-height) - 8px);
    padding: 0 0.875rem;
    border-radius: var(--cv-radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--cv-text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.choice-seg > input:checked + label {
    background-color: var(--cv-surface);
    color: var(--cv-text);
    box-shadow: var(--cv-shadow-sm);
}

.choice-seg > input:focus-visible + label {
    outline: 2px solid var(--cv-focus-ring);
    outline-offset: 1px;
}

.choice-seg > input:disabled + label {
    cursor: default;
    opacity: 0.6;
}

/* Long option labels stack on a phone instead of wrapping inside the pill */
@container (max-width: 27.99rem) {
    .choice-seg.choice-stack {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
}

/* A searchable list (data-init="combobox" on a <select>): a text box that filters the options as you type */
.combobox {
    position: relative;
}

.combobox > .fa-magnifying-glass {
    position: absolute;
    left: 0.75rem;
    top: calc(var(--cv-field-height) / 2);
    transform: translateY(-50%);
    font-size: 0.8125rem;
    color: var(--cv-text-muted);
    pointer-events: none;
}

.combobox > .form-control {
    padding-left: 2.125rem;
}

.combobox-list {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background-color: var(--cv-surface);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    box-shadow: var(--cv-shadow-lg);
}

.combobox-list > li {
    padding: 0.4375rem 0.625rem;
    border-radius: var(--cv-radius-sm);
    cursor: pointer;
}

.combobox-list > li[aria-selected="true"],
.combobox-list > li:hover {
    background-color: var(--cv-surface-sunken);
}

.combobox-list > li.combobox-empty {
    color: var(--cv-text-muted);
    cursor: default;
}

/* An inline form's submit button: it sits in the grid like a field, level with the controls
   (<div class="field field-action"><button …></div>) */
.field-action > .btn {
    grid-row: 2;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: var(--cv-field-height);
    --bs-btn-padding-y: 0;
}

.field-action > .btn.w-100 {
    justify-self: stretch;
}

/* ------------------------------------------------------------------ */
/* 5. Surfaces                                                        */
/* ------------------------------------------------------------------ */
.card {
    --bs-card-border-color: var(--cv-border);
    --bs-card-border-radius: var(--cv-radius-lg);
    --bs-card-inner-border-radius: calc(var(--cv-radius-lg) - 1px);
    --bs-card-bg: var(--cv-surface);
    --bs-card-cap-bg: var(--cv-surface-muted);
    --bs-card-color: var(--cv-text);
    box-shadow: var(--cv-shadow);
}

.modal {
    --bs-modal-bg: var(--cv-surface);
    --bs-modal-color: var(--cv-text);
    --bs-modal-border-radius: var(--cv-radius-lg);
    --bs-modal-border-color: var(--cv-border);
    --bs-modal-header-border-color: var(--cv-border);
    --bs-modal-footer-border-color: var(--cv-border);
    --bs-modal-box-shadow: var(--cv-shadow-lg);
    --bs-modal-padding: 1.25rem;
    --bs-modal-header-padding: 0.875rem 1.25rem;
    --bs-modal-footer-gap: 0.5rem;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    background-color: var(--cv-surface-muted);
    border-bottom-left-radius: var(--bs-modal-inner-border-radius);
    border-bottom-right-radius: var(--bs-modal-inner-border-radius);
}

.modal-content {
    background-color: var(--cv-surface);
    box-shadow: var(--cv-shadow-lg);
}

.modal-footer {
    gap: 0.5rem;
}

.modal-footer > * {
    margin: 0;
}

.dropdown-menu {
    --bs-dropdown-bg: var(--cv-surface);
    --bs-dropdown-color: var(--cv-text);
    --bs-dropdown-link-color: var(--cv-text);
    --bs-dropdown-link-hover-bg: var(--cv-surface-muted);
    --bs-dropdown-link-active-bg: var(--cv-primary);
    --bs-dropdown-border-color: var(--cv-border);
    --bs-dropdown-box-shadow: var(--cv-shadow);
}

.list-group {
    --bs-list-group-bg: var(--cv-surface);
    --bs-list-group-color: var(--cv-text);
    --bs-list-group-border-color: var(--cv-border);
    --bs-list-group-action-hover-bg: var(--cv-surface-muted);
    --bs-list-group-action-hover-color: var(--cv-heading);
}

.bg-light {
    background-color: var(--cv-surface-muted) !important;
}

.bg-dark,
.navbar-dark.bg-dark {
    background-color: var(--cv-navy) !important;
}

/* ------------------------------------------------------------------ */
/* 6. Data display                                                    */
/* ------------------------------------------------------------------ */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--cv-text);
    --bs-table-hover-bg: rgba(var(--cv-primary-rgb), 0.06);
    --bs-table-hover-color: var(--cv-text);
    --bs-table-striped-bg: var(--cv-surface-muted);
    --bs-table-striped-color: var(--cv-text);
    --bs-table-border-color: var(--cv-border);
}

.table > thead.table-light,
.table > thead .table-light {
    --bs-table-bg: var(--cv-surface-muted);
    --bs-table-color: var(--cv-text-muted);
    --bs-table-border-color: var(--cv-border);
}

.table > thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Status badge: one meaning per colour, used for every state in the product.
 *   status-success  live / healthy        (Active, Enabled, Visible)
 *   status-neutral  off / not in use      (Inactive, Disabled)
 *   status-warning  needs attention       (Cancels on ..., Private document, Missing)
 *   status-danger   failed / blocked      (Suspended, Overdue)
 *   status-info     informational state   (Public, Monthly / Yearly)
 * Use .tag-badge for user-defined labels (document tags), which carry no state. */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375em;
    padding: 0.35em 0.65em;
    border-radius: 999px;
    border: 1px solid rgba(var(--sb-rgb), 0.35);
    background-color: rgba(var(--sb-rgb), 0.12);
    color: var(--sb-text);
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 0.45em;
    height: 0.45em;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}

.status-success { --sb-rgb: var(--cv-success-rgb); --sb-text: var(--cv-success-text); }
.status-neutral { --sb-rgb: var(--cv-neutral-rgb); --sb-text: var(--cv-neutral-text); }
.status-warning { --sb-rgb: var(--cv-warning-rgb); --sb-text: var(--cv-warning-text); }
.status-danger  { --sb-rgb: var(--cv-danger-rgb);  --sb-text: var(--cv-danger-text); }
.status-info    { --sb-rgb: var(--cv-info-rgb);    --sb-text: var(--cv-info-text); }

/* A user's role (Settings > Users): info colours, no state dot */
.role-badge { --sb-rgb: var(--cv-info-rgb); --sb-text: var(--cv-info-text); }
.role-badge::before { content: none; }

.tag-badge {
    padding: 0.35em 0.6em;
    border: 1px solid var(--cv-border-strong);
    border-radius: var(--cv-radius-sm);
    background-color: var(--cv-surface-muted);
    color: var(--cv-text-muted);
    font-weight: 500;
}

/* Initials avatar (canvemo/layout :: avatar, com.canvemo.platform.web.Avatars) */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: var(--cv-avatar-5);
    color: var(--cv-white);
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    user-select: none;
}

.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.75rem; }

/* Profile picture in place of the initials (canvemo/layout :: photoAvatar) */
.avatar-photo {
    object-fit: cover;
    background-color: var(--cv-surface-muted);
}

.avatar-color-0 { background-color: var(--cv-avatar-0); }
.avatar-color-1 { background-color: var(--cv-avatar-1); }
.avatar-color-2 { background-color: var(--cv-avatar-2); }
.avatar-color-3 { background-color: var(--cv-avatar-3); }
.avatar-color-4 { background-color: var(--cv-avatar-4); }
.avatar-color-5 { background-color: var(--cv-avatar-5); }

.pagination {
    --bs-pagination-bg: var(--cv-surface);
    --bs-pagination-color: var(--cv-primary-text);
    --bs-pagination-hover-bg: var(--cv-surface-muted);
    --bs-pagination-hover-color: var(--cv-primary-hover);
    --bs-pagination-focus-color: var(--cv-primary-hover);
    --bs-pagination-focus-box-shadow: var(--cv-focus-ring);
    --bs-pagination-active-bg: var(--cv-primary);
    --bs-pagination-active-border-color: var(--cv-primary);
    --bs-pagination-border-color: var(--cv-border);
    --bs-pagination-disabled-bg: var(--cv-surface-muted);
    --bs-pagination-disabled-color: var(--cv-text-subtle);
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--cv-border);
    --bs-nav-tabs-link-active-bg: var(--cv-surface);
    --bs-nav-tabs-link-active-border-color: var(--cv-border) var(--cv-border) var(--cv-surface);
    --bs-nav-tabs-link-hover-border-color: var(--cv-border) var(--cv-border) var(--cv-border);
}

.nav-tabs .nav-link {
    color: var(--cv-text-muted);
}

.nav-tabs .nav-link.active {
    color: var(--cv-primary-text);
    font-weight: 600;
}

.alert {
    --bs-alert-padding-x: 0.875rem;
    --bs-alert-padding-y: 0.75rem;
    --bs-alert-margin-bottom: 1rem;
    border-radius: var(--cv-radius);
}

/* Alerts in the status colours (tinted fill, readable text), the same in light and dark mode */
.alert-info    { --al-rgb: var(--cv-info-rgb);    --al-text: var(--cv-info-text); }
.alert-success { --al-rgb: var(--cv-success-rgb); --al-text: var(--cv-success-text); }
.alert-warning { --al-rgb: var(--cv-warning-rgb); --al-text: var(--cv-warning-text); }
.alert-danger  { --al-rgb: var(--cv-danger-rgb);  --al-text: var(--cv-danger-text); }
.alert-secondary,
.alert-light   { --al-rgb: var(--cv-neutral-rgb); --al-text: var(--cv-neutral-text); }

.alert-info,
.alert-success,
.alert-warning,
.alert-danger,
.alert-secondary,
.alert-light {
    --bs-alert-color: var(--al-text);
    --bs-alert-bg: rgba(var(--al-rgb), 0.08);
    --bs-alert-border-color: rgba(var(--al-rgb), 0.3);
    --bs-alert-link-color: var(--al-text);
}

.alert .alert-link,
.alert a:not(.btn) {
    color: var(--al-text, inherit);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.tooltip {
    --bs-tooltip-bg: var(--cv-navy);
}

/* Contextual help (canvemo/layout :: help): a quiet (?) after a label or title, its text in a popover */
.help-icon {
    --bs-btn-padding-x: 0.15rem;
    --bs-btn-padding-y: 0;
    --bs-btn-border-width: 0;
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-hover-color: var(--bs-primary);
    --bs-btn-active-color: var(--bs-primary);
    font-size: 0.875rem;
    line-height: 1;
    vertical-align: baseline;
    margin-left: 0.15rem;
}

h1 .help-icon, h2 .help-icon, h3 .help-icon, .h1 .help-icon, .h2 .help-icon, .h3 .help-icon {
    font-size: 1rem;
    vertical-align: middle;
}

.help-icon[aria-describedby] {
    color: var(--bs-primary);
}

.help-popover {
    --bs-popover-max-width: 320px;
    --bs-popover-body-padding-y: 0.6rem;
    --bs-popover-body-padding-x: 0.8rem;
    --bs-popover-font-size: 0.85rem;
    white-space: pre-line;
}

/* ------------------------------------------------------------------ */
/* 7. Responsive tables: <table class="table table-stack"> becomes     */
/*    label/value cards on phones. canvemo-app.js copies each header   */
/*    text into the cells' data-label attribute.                       */
/* ------------------------------------------------------------------ */
@media (max-width: 767.98px) {
    .table-stack thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.875rem;
        background-color: var(--cv-surface);
        border: 1px solid var(--cv-border);
        border-radius: var(--cv-radius-lg);
    }

    .table-stack.table > :not(caption) > * > * {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.4rem 0 !important;
        border-bottom: 1px solid var(--cv-border);
        box-shadow: none;
        text-align: right !important;
        max-width: none;
    }

    .table-stack.table > :not(caption) > * > *:last-child {
        border-bottom: 0;
    }

    .table-stack td[data-label]::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--cv-text-muted);
        text-align: left;
    }

    .table-stack.table > :not(caption) > * > .cell-full {
        display: block;
        text-align: center !important;
    }
}

/* ------------------------------------------------------------------ */
/* 8. Utilities                                                       */
/* ------------------------------------------------------------------ */
.cursor-pointer {
    cursor: pointer;
}

/* Lets flex/grid children shrink below their content width (wide tables, charts) */
.min-w-0 {
    min-width: 0;
}

/* Small uppercase field caption (e.g. "Unit", "Location" above a value) */
.field-caption {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cv-text-muted);
}

/* Narrow select used next to an amount input */
.currency-select {
    max-width: 100px;
}

/* Table cell that truncates long text instead of widening the table */
.cell-truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fixed-size image/placeholder thumbnails */
.thumb-40 {
    width: 40px;
    height: 40px;
    object-fit: cover;
    flex-shrink: 0;
}

.img-preview {
    max-height: 100px;
}

/* Icon sizes */
.icon-md { font-size: 2rem; }
.icon-lg { font-size: 3rem; }
.icon-xl { font-size: 3.5rem; }
.icon-xxl { font-size: 5rem; }

/* Light/dark switch: shows the icon of the theme it switches TO */
.theme-icon-to-light { display: none; }
[data-bs-theme="dark"] .theme-icon-to-light { display: inline-block; }
[data-bs-theme="dark"] .theme-icon-to-dark { display: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .btn.is-busy::after {
        animation: none;
        border-right-color: var(--bs-btn-color);
        border-style: dotted;
    }
}

/* --- tour: W3 --- */
/* The product tour (panel, spotlight, step popover, pill, dialogs) and the demo bar: W3 of docs/plans/demo-tour.md. */
/* Design: Product tour page (Tour, RoleSwitch). Shown by /js/canvemo-tour.js and /js/canvemo-demo.js. */
:root {
    --cv-tour-ring: #8BD08F;
    --cv-tour-dim: rgba(15, 22, 35, 0.58);
    --cv-tour-bar-bg: #E5F0F6;
    --cv-tour-bar-border: #B9D5E6;
    --cv-tour-bar-tag: var(--cv-info-text);
    --cv-tour-bar-tag-text: #FFFFFF;
    --cv-tour-purple-bg: #F0EAF7;
    --cv-tour-purple-text: #55397A;
    --cv-tour-pop-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    --cv-tour-dialog-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    --cv-tour-qr-bg: #FFFFFF;              /* a code reads on white in both themes */
}
[data-bs-theme="dark"] {
    --cv-tour-dim: rgba(4, 8, 15, 0.7);
    --cv-tour-bar-bg: #143049;
    --cv-tour-bar-border: #24496A;
    --cv-tour-bar-tag-text: #0F1623;
    --cv-tour-purple-bg: #2C2240;
    --cv-tour-purple-text: #CDB8EC;
}

/* Shared bits */
.tour-kicker, .demo-menu-kicker {
    font-size: 11px; font-weight: 700; color: var(--cv-text-muted);
    text-transform: uppercase; letter-spacing: 0.08em;
}
.tour-kicker-primary { color: var(--cv-primary-text); }
.tour-sub { font-size: 13px; color: var(--cv-text-muted); }
.tour-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tour-btn-ghost { border-color: transparent; background: transparent; color: var(--cv-text-muted); }
.tour-btn-ghost:hover, .tour-btn-ghost:focus-visible { background: var(--cv-surface-sunken); color: var(--cv-text); }
.tour-icon-btn {
    width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; color: var(--cv-text-muted); background: transparent;
}
.tour-icon-btn:hover, .tour-icon-btn:focus-visible { background: var(--cv-surface-sunken); color: var(--cv-text); }
.tour-link {
    background: none; border: 0; padding: 0; min-height: 32px;
    font-weight: 600; font-size: 13px; color: var(--cv-primary-text); cursor: pointer;
}
.tour-link:hover { text-decoration: underline; }
.tour-role {
    display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--cv-surface-sunken); color: var(--cv-text-muted);
}
.tour-role-hr-admin { background: var(--cv-primary-subtle); color: var(--cv-primary-text); }
.tour-role-employee { background: var(--cv-tour-bar-bg); color: var(--cv-info-text); }
.tour-role-manager { background: var(--cv-tour-purple-bg); color: var(--cv-tour-purple-text); }
.tour-medal {
    width: 48px; height: 48px; border-radius: 50%; flex: none; font-size: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cv-primary); color: var(--cv-surface);
    box-shadow: 0 0 0 6px rgba(var(--cv-primary-rgb), 0.18);
}
.tour-medal-lg { width: 56px; height: 56px; font-size: 26px; }

/* The panel: a column beside the page on wide screens, a card over it on tablets, a sheet on phones */
.tour-host { display: contents; }
.tour { min-width: 0; }
.tour-panel {
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--cv-surface); border: 1px solid var(--cv-border); border-radius: var(--cv-radius-lg);
    box-shadow: var(--cv-shadow-lg); color: var(--cv-text);
}
.tour-panel[hidden], .tour-pill[hidden], .tour-overlay[hidden], .tour-win[hidden] { display: none; }
@media (min-width: 1200px) {
    .row > .tour-host.is-open { display: block; flex: 0 0 380px; width: 380px; max-width: 380px; }
    .tour-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
@media (max-width: 1199.98px) {
    .tour-panel {
        position: fixed; z-index: 1040; right: 16px; bottom: 16px; width: 380px;
        max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); overflow-y: auto;
    }
}
@media (max-width: 767.98px) {
    .tour-panel {
        /* below the header and the demo bar (about 240px on a phone): their lines are never half covered */
        left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; max-height: min(78vh, calc(100vh - 256px));
        border-radius: 16px 16px var(--cv-radius-lg) var(--cv-radius-lg);
    }
}
.tour-head { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--cv-border); }
.tour-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-head-actions { display: flex; gap: 2px; margin-right: -8px; }
.tour-title { font-size: 18px; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 4px; }
.tour-progress { height: 8px; border-radius: 999px; background: var(--cv-surface-sunken); overflow: hidden; }
.tour-progress-bar { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--cv-primary); transition: width 0.4s ease; }
.tour-win {
    padding: 18px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
    background: var(--cv-primary-subtle); border-bottom: 1px solid var(--cv-border);
}
.tour-win-title { font-size: 17px; font-weight: 800; margin: 0; }
.tour-win-text { font-size: 14px; color: var(--cv-text-muted); margin: 0; }
.tour-missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tour-mission { display: flex; gap: 12px; padding: 12px 18px; align-items: flex-start; }
.tour-mission + .tour-mission { border-top: 1px solid var(--cv-border); }
.tour-mission:not(.is-current) { cursor: pointer; }
.tour-mission:not(.is-current):hover { background: var(--cv-surface-muted); }
.tour-mission.is-current { background: var(--cv-surface-muted); }
.tour-state {
    width: 28px; height: 28px; border-radius: 50%; flex: none; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
    border: 2px solid var(--cv-border-strong); color: var(--cv-text-muted);
}
.tour-mission.is-done .tour-state { background: var(--cv-primary); border-color: var(--cv-primary); color: var(--cv-surface); }
.tour-mission.is-current .tour-state { border-color: var(--cv-primary); color: var(--cv-primary-text); background: var(--cv-primary-subtle); }
.tour-mission.is-current.is-done .tour-state { background: var(--cv-primary); color: var(--cv-surface); }
.tour-mission-body { flex: 1; min-width: 0; }
.tour-mission-title { font-weight: 700; font-size: 14px; }
.tour-mission-open {
    display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left;
    font-weight: 700; font-size: 14px; color: var(--cv-text); cursor: pointer;
}
.tour-mission.is-done .tour-mission-open { color: var(--cv-text-muted); font-weight: 600; }
.tour-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 3px; }
.tour-skipped { font-style: italic; }
.tour-steps { list-style: none; margin: 10px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tour-step { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.tour-step > i {
    width: 16px; height: 16px; flex: none; margin-top: 2px; border-radius: 50%; box-sizing: border-box;
    border: 1.5px solid var(--cv-border-strong); display: flex; align-items: center; justify-content: center;
    font-size: 8px; color: var(--cv-surface);
}
.tour-step > i > span { visibility: hidden; }
.tour-step.is-done { color: var(--cv-text-muted); }
.tour-step.is-done > i { background: var(--cv-primary); border-color: var(--cv-primary); }
.tour-step.is-done > i > span { visibility: visible; }
.tour-step.is-now { font-weight: 600; }
.tour-step.is-now > i { border-color: var(--cv-primary); border-width: 5px; }
.tour-switch-note { font-size: 13px; color: var(--cv-text-muted); margin: 0 0 8px; }
.tour-foot {
    padding: 12px 18px; border-top: 1px solid var(--cv-border);
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
}

/* The pill */
.tour-pill {
    position: fixed; z-index: 1041; right: 24px; bottom: 24px;
    display: flex; align-items: center; gap: 12px; min-height: 56px; max-width: calc(100vw - 32px);
    padding: 8px 16px 8px 10px; border-radius: 999px; border: 1px solid var(--cv-border);
    background: var(--cv-surface); color: var(--cv-text); box-shadow: var(--cv-shadow-lg);
    font-weight: 600; font-size: 14px; text-align: left; cursor: pointer;
}
.tour-pill:focus-visible { outline: 3px solid var(--cv-tour-ring); outline-offset: 2px; }
.tour-ring {
    width: 38px; height: 38px; border-radius: 50%; flex: none; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
    color: var(--cv-primary-text); background: var(--cv-primary-subtle); border: 3px solid var(--cv-primary);
}
.tour-pill-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.tour-pill-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-pill-text .tour-sub { font-weight: 500; }
.tour-pill-chevron { flex: none; margin-left: 4px; }
@media (max-width: 767.98px) {
    .tour-pill { left: 12px; right: 12px; bottom: 12px; border-radius: 14px; max-width: none; }
}

/* Spotlight and step popover */
.tour-spotlight {
    position: fixed; z-index: 1045; pointer-events: none; border-radius: 8px;
    box-shadow: 0 0 0 4px var(--cv-tour-ring), 0 0 0 9999px var(--cv-tour-dim);
    transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tour-pop {
    --tour-arrow-x: 34px;
    position: fixed; z-index: 1046; width: 320px; max-width: calc(100vw - 24px); box-sizing: border-box;
    padding: 16px 18px; border-radius: 12px; background: var(--cv-surface); color: var(--cv-text);
    border: 1px solid var(--cv-border); box-shadow: var(--cv-tour-pop-shadow);
    display: flex; flex-direction: column; gap: 8px;
}
.tour-pop:focus { outline: none; }
.tour-pop::before {
    content: ""; position: absolute; top: -8px; left: var(--tour-arrow-x); width: 14px; height: 14px;
    background: var(--cv-surface); border-left: 1px solid var(--cv-border); border-top: 1px solid var(--cv-border);
    transform: rotate(45deg);
}
.tour-pop.is-above::before { top: auto; bottom: -8px; transform: rotate(225deg); }
.tour-pop.is-floating { right: 24px; bottom: 96px; }
.tour-pop.is-floating::before { display: none; }
.tour-pop.is-tucked, .tour-spotlight.is-tucked { visibility: hidden; }
.tour-pop-body { display: flex; flex-direction: column; gap: 6px; }
.tour-pop-title { font-size: 16px; font-weight: 700; margin: 0; }
.tour-pop-text { font-size: 14px; color: var(--cv-text-muted); margin: 0; overflow-wrap: anywhere; }
.tour-pop-foot { display: flex; flex-direction: column; align-items: stretch; gap: 10px; margin-top: 4px; }
/* Skip on the left, Back and the main button on the right: the three fit on one line in both languages */
.tour-pop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.tour-pop-actions [data-tour-step-skip] { margin-right: auto; padding-left: 0; }
.tour-pop-actions [hidden] { display: none; }
.tour-dots { display: flex; gap: 5px; align-items: center; }
.tour-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--cv-border-strong); }
.tour-dots span.is-on { background: var(--cv-primary); width: 18px; border-radius: 999px; }
@media (max-width: 767.98px) {
    .tour-pop.is-floating { left: 12px; right: 12px; bottom: 84px; width: auto; max-width: none; }
}

/* The toast after a mission */
.tour-toast {
    position: fixed; z-index: 1050; top: 84px; right: 24px; max-width: calc(100vw - 32px);
    display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--cv-radius-lg);
    background: var(--cv-text); color: var(--cv-surface); font-weight: 600; box-shadow: var(--cv-shadow-lg);
    animation: tour-toast-in 0.25s ease-out;
}
.tour-toast.is-leaving { opacity: 0; transition: opacity 0.4s ease; }
@keyframes tour-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Dialogs: welcome, finish, feedback */
.tour-dialog-open { overflow: hidden; }
.tour-overlay {
    position: fixed; inset: 0; z-index: 1055; background: var(--cv-tour-dim); overflow-y: auto;
    display: flex; justify-content: center; align-items: flex-start; padding: 110px 16px 24px; box-sizing: border-box;
}
.tour-dialog {
    width: 100%; max-width: 620px; border-radius: 14px; overflow: hidden;
    background: var(--cv-surface); color: var(--cv-text); border: 1px solid var(--cv-border);
    box-shadow: var(--cv-tour-dialog-shadow);
}
.tour-dialog-narrow { max-width: 520px; }
.tour-dialog-body { padding: 28px 30px; display: flex; flex-direction: column; gap: 14px; }
.tour-dialog-body-start { align-items: flex-start; }
.tour-dialog-body-head { padding-bottom: 0; gap: 6px; }
.tour-dialog-title { font-size: 26px; font-weight: 800; line-height: 1.2; margin: 0; }
.tour-dialog-narrow .tour-dialog-title { font-size: 20px; }
.tour-dialog-lead { font-size: 15px; color: var(--cv-text-muted); margin: 0; }
.tour-dialog-foot {
    padding: 16px 30px; border-top: 1px solid var(--cv-border); background: var(--cv-surface-muted);
    display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
}
.tour-dialog-foot-end { justify-content: flex-end; }
.tour-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tour-card {
    display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--cv-radius-lg);
    border: 1px solid var(--cv-border); background: var(--cv-surface-muted); font-weight: 600; font-size: 13px;
}
.tour-card-icon {
    width: 32px; height: 32px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center;
    background: var(--cv-primary-subtle); color: var(--cv-primary-text);
}
.tour-card-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.tour-card-meta { font-weight: 500; font-size: 12px; color: var(--cv-text-muted); }
.tour-wins { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.tour-wins li { display: flex; gap: 8px; align-items: center; }
.tour-wins i { color: var(--cv-primary); flex: none; }
.tour-fb-body { gap: 16px; }
.tour-fb-body-ruled { padding-top: 0; }
.tour-fb-body-ruled > .tour-rate-set { padding-top: 18px; border-top: 1px solid var(--cv-border); }
.tour-rate-set { border: 0; margin: 0; padding: 0; min-width: 0; }
.tour-fb-label { font-weight: 700; font-size: 15px; margin-bottom: 8px; display: block; }
.tour-fb-optional { font-size: 13px; font-weight: 500; color: var(--cv-text-muted); }
.tour-fb-comment { display: flex; flex-direction: column; }
.tour-rates { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tour-rate {
    min-height: 64px; padding: 6px 4px; border-radius: var(--cv-radius-lg); border: 1px solid var(--cv-border-strong);
    background: var(--cv-surface); color: var(--cv-text); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tour-rate:hover { border-color: var(--cv-primary); }
.tour-rate:focus-visible { outline: 3px solid var(--cv-tour-ring); outline-offset: 2px; }
.tour-rate-n { font-size: 18px; font-weight: 800; }
.tour-rate-label { font-size: 11px; color: var(--cv-text-muted); text-align: center; line-height: 1.2; }
.tour-rate.is-on { border-color: var(--cv-primary); background: var(--cv-primary-subtle); box-shadow: 0 0 0 2px var(--cv-primary) inset; }
.tour-rate.is-on .tour-rate-n { color: var(--cv-primary-text); }
.tour-thanks {
    padding: 16px; border-radius: 12px; border: 1px solid var(--cv-primary); background: var(--cv-primary-subtle);
    display: flex; flex-direction: column; gap: 8px;
}
@media (max-width: 767.98px) {
    .tour-overlay { padding: 24px 8px; }
    .tour-dialog-body { padding: 22px 18px; }
    .tour-dialog-foot { padding: 14px 18px; }
    .tour-dialog-title { font-size: 22px; }
    .tour-cards { grid-template-columns: minmax(0, 1fr); }
    .tour-rates { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
    .tour-rate-label { font-size: 10px; }
    .tour-dialog-foot .tour-actions { width: 100%; }
    .tour-dialog-foot .tour-actions .btn { flex: 1 1 auto; }
}

/* The demo bar */
.demo-bar { position: relative; z-index: 1030; background: var(--cv-tour-bar-bg); border-bottom: 1px solid var(--cv-tour-bar-border); color: var(--cv-text); }
.demo-bar-inner { padding-top: 8px; padding-bottom: 8px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.demo-bar-tag {
    display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
    background: var(--cv-tour-bar-tag); color: var(--cv-tour-bar-tag-text); font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
}
[data-bs-theme="dark"] .demo-bar-tag { background: var(--cv-info-text); }
.demo-bar-who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.demo-bar-ends { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--cv-text-muted); }
.demo-bar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.demo-bar-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-weight: 600;
    border: 1px solid var(--cv-border-strong); background: var(--cv-surface); color: var(--cv-text);
}
.demo-bar-btn:hover, .demo-bar-btn:focus-visible { border-color: var(--cv-primary); color: var(--cv-text); background: var(--cv-surface); }
.demo-bar-btn[hidden] { display: none; }
.demo-bar-chevron { font-size: 11px; }
.demo-menu { width: 340px; max-width: calc(100vw - 32px); padding: 6px; border-radius: 12px; box-shadow: var(--cv-tour-pop-shadow); }
.demo-menu-kicker { display: block; padding: 6px 10px 4px; }
.demo-menu-loading { display: block; padding: 10px; font-size: 13px; color: var(--cv-text-muted); }
.demo-menu-sep { height: 1px; background: var(--cv-border); margin: 6px 4px; }
.demo-menu-note { padding: 6px 10px 8px; margin: 0; font-size: 12px; color: var(--cv-text-muted); }
.demo-account {
    display: flex; gap: 10px; align-items: center; min-height: 52px; padding: 6px 10px; border-radius: 8px;
    white-space: normal; color: var(--cv-text);
}
.demo-account.is-current { background: var(--cv-surface-muted); }
.demo-account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.demo-account-name { font-weight: 600; }
.demo-account-sees { font-size: 13px; color: var(--cv-text-muted); }
.demo-phone-icon { background: var(--cv-surface-sunken); color: var(--cv-text); }
@media (max-width: 767.98px) {
    .demo-bar-actions, .demo-switch { margin-left: 0; width: 100%; }
    .demo-bar-actions .demo-bar-btn, .demo-switch .demo-bar-btn { width: 100%; justify-content: center; }
}

/* The phone sign-in code */
.demo-qr-dialog { max-width: 520px; }
.demo-qr { border-radius: 14px; overflow: hidden; box-shadow: var(--cv-tour-dialog-shadow); }
.demo-qr-body { padding: 26px 28px; display: flex; flex-wrap: wrap; gap: 20px 24px; align-items: center; }
.demo-qr-code {
    width: 184px; height: 184px; flex: none; box-sizing: border-box; padding: 12px; border-radius: 12px;
    border: 1px solid var(--cv-border); background: var(--cv-tour-qr-bg); display: flex; align-items: center; justify-content: center;
}
.demo-qr-code svg { width: 100%; height: 100%; }
.demo-qr-code.is-expired svg { opacity: 0.15; }
.demo-qr-text { flex: 1 1 200px; display: flex; flex-direction: column; gap: 8px; }
.demo-qr-title { font-size: 20px; font-weight: 800; line-height: 1.25; margin: 0; }
.demo-qr-lead, .demo-qr-text .tour-sub { margin: 0; }
.demo-qr-expired { margin: 0; font-weight: 600; color: var(--cv-warning-text); }
.demo-qr-foot {
    padding: 14px 28px; border-top: 1px solid var(--cv-border); background: var(--cv-surface-muted);
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
}
@media (max-width: 767.98px) {
    .demo-qr-body { justify-content: center; padding: 22px 18px; }
    .demo-qr-foot { padding: 14px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .tour-progress-bar, .tour-spotlight, .tour-toast, .tour-toast.is-leaving { transition: none; animation: none; }
}
/* --- end tour: W3 --- */
