/*
 * Design system: warm brass-on-neutral light theme, deep slate dark theme. Palette is applied
 * two ways -
 *   1) Bootstrap's own theme variables (--bs-primary, --bs-success, --bs-body-bg, etc.) are
 *      redefined here so every Bootstrap component (buttons, badges, alerts, links, tables)
 *      picks up the new palette automatically, without fighting Bootstrap's !important utility
 *      classes one by one.
 *   2) A smaller set of app-specific tokens (--surface, --ink, --muted, --font-*, ...) drive the
 *      custom shell/card/table styling below.
 *
 * Theme resolution follows the 3-state pattern: bare :root is the light default; the dark media
 * query is guarded with :not([data-theme="light"]) so an explicit light choice always beats the
 * OS preference; [data-theme="dark"] repeats the same values so the toggle wins in both
 * directions. See js/theme.js for the toggle itself.
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Bootstrap theme variables */
    --bs-primary: #A6702A;
    --bs-primary-rgb: 166, 112, 42;
    --bs-secondary: #5B6672;
    --bs-secondary-rgb: 91, 102, 114;
    --bs-success: #2E7D6B;
    --bs-success-rgb: 46, 125, 107;
    --bs-warning: #B8791A;
    --bs-warning-rgb: 184, 121, 26;
    --bs-danger: #B93B32;
    --bs-danger-rgb: 185, 59, 50;
    --bs-info: #3C6E9C;
    --bs-info-rgb: 60, 110, 156;
    --bs-body-bg: #E7EAEE;
    --bs-body-bg-rgb: 231, 234, 238;
    --bs-body-color: #17212A;
    --bs-body-color-rgb: 23, 33, 42;
    --bs-border-color: #DEE1E4;
    --bs-border-color-translucent: rgba(23, 33, 42, 0.15);
    --bs-tertiary-bg: #EDEEF0;
    --bs-secondary-bg: #EDEEF0;
    --bs-secondary-color: #5B6672;
    --bs-secondary-color-rgb: 91, 102, 114;
    --bs-tertiary-color: #7C8792;
    --bs-tertiary-color-rgb: 124, 135, 146;
    --bs-emphasis-color: #17212A;
    --bs-emphasis-color-rgb: 23, 33, 42;
    --bs-light: #EDEEF0;
    --bs-light-rgb: 237, 238, 240;
    --bs-link-color: #A6702A;
    --bs-link-color-rgb: 166, 112, 42;
    --bs-link-hover-color: #8A5C22;

    /* App tokens - Liquid Glass: every "surface" is a translucent frosted panel (backdrop-filter
       is applied per-selector below, since it can't be smuggled into a color variable) floating
       over the animated gradient mesh painted on body::before. */
    --surface: rgba(255, 255, 255, 0.58);
    --surface-menu: rgba(255, 255, 255, 0.97); /* menus that open over other panels (can't blur them) */
    --surface-alt: rgba(255, 255, 255, 0.38);
    --ink: #17212A;
    --muted: #5B6672;
    --border: rgba(255, 255, 255, 0.45);
    --accent: #A6702A;
    --accent-ink: #FFFFFF;
    --shadow: 0 10px 34px rgba(23, 33, 42, 0.14), 0 2px 10px rgba(23, 33, 42, 0.08);

    /* Liquid Glass primitives, reused by every frosted surface below. */
    --glass-blur: blur(22px) saturate(180%);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    --glass-bg: var(--bs-body-bg);

    --bs-border-radius-sm: 0.65rem;
    --bs-border-radius: 1rem;
    --bs-border-radius-lg: 1.35rem;
    --bs-border-radius-xl: 1.7rem;
    --bs-border-radius-2xl: 2.1rem;
    --bs-border-radius-pill: 50rem;

    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;

    /* Brand-identity red, matching ShopperUI's own --red/--red-dark - used only for the logo mark
       and the profile avatar, kept separate from --accent (the brass tone every functional
       control - buttons, active nav, links - still uses) so this stays a logo/branding update,
       not a site-wide re-theme. */
    --brand-red: #BE0D0D;
    --brand-red-dark: #930A0A;
    --brand-red-rgb: 190, 13, 13;

    /* Purple accent for the Survey Detail page's "Action Log" summary card (see .survey-flag-card)
       - Bootstrap has no built-in purple theme color, so this is a standalone token, not a
       redefinition of an existing --bs-* variable. */
    --brand-purple: #6B4FA0;
    --brand-purple-rgb: 107, 79, 160;

    --sidebar-width: 248px;
    --sidebar-width-collapsed: 72px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bs-primary: #D9A54B;
        --bs-primary-rgb: 217, 165, 75;
        --bs-secondary: #93A1AC;
        --bs-secondary-rgb: 147, 161, 172;
        --bs-success: #4FA98E;
        --bs-success-rgb: 79, 169, 142;
        --bs-warning: #E0A63D;
        --bs-warning-rgb: 224, 166, 61;
        --bs-danger: #E0685D;
        --bs-danger-rgb: 224, 104, 93;
        --bs-info: #6FA0C9;
        --bs-info-rgb: 111, 160, 201;
        --bs-body-bg: #10161B;
        --bs-body-bg-rgb: 16, 22, 27;
        --bs-body-color: #E9ECEE;
        --bs-body-color-rgb: 233, 236, 238;
        --bs-border-color: #2B363F;
        --bs-border-color-translucent: rgba(255, 255, 255, 0.15);
        --bs-tertiary-bg: #212B33;
        --bs-secondary-bg: #212B33;
        --bs-secondary-color: #93A1AC;
        --bs-secondary-color-rgb: 147, 161, 172;
        --bs-tertiary-color: #6E7A85;
        --bs-tertiary-color-rgb: 110, 122, 133;
        --bs-emphasis-color: #E9ECEE;
        --bs-emphasis-color-rgb: 233, 236, 238;
        --bs-light: #212B33;
        --bs-light-rgb: 33, 43, 51;
        --bs-link-color: #D9A54B;
        --bs-link-color-rgb: 217, 165, 75;
        --bs-link-hover-color: #EBC077;

        --surface: rgba(26, 34, 42, 0.55);

        --surface-menu: rgba(26, 34, 42, 0.97);
        --surface-alt: rgba(33, 43, 51, 0.45);
        --ink: #E9ECEE;
        --muted: #93A1AC;
        --border: rgba(255, 255, 255, 0.12);
        --accent: #D9A54B;
        --accent-ink: #17212A;
        --shadow: 0 10px 34px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.35);

        --brand-purple: #9B87C4;
        --brand-purple-rgb: 155, 135, 196;
    }
}

:root[data-theme="dark"] {
    --bs-primary: #D9A54B;
    --bs-primary-rgb: 217, 165, 75;
    --bs-secondary: #93A1AC;
    --bs-secondary-rgb: 147, 161, 172;
    --bs-success: #4FA98E;
    --bs-success-rgb: 79, 169, 142;
    --bs-warning: #E0A63D;
    --bs-warning-rgb: 224, 166, 61;
    --bs-danger: #E0685D;
    --bs-danger-rgb: 224, 104, 93;
    --bs-info: #6FA0C9;
    --bs-info-rgb: 111, 160, 201;
    --bs-body-bg: #10161B;
    --bs-body-bg-rgb: 16, 22, 27;
    --bs-body-color: #E9ECEE;
    --bs-body-color-rgb: 233, 236, 238;
    --bs-border-color: #2B363F;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.15);
    --bs-tertiary-bg: #212B33;
    --bs-secondary-bg: #212B33;
    --bs-secondary-color: #93A1AC;
    --bs-secondary-color-rgb: 147, 161, 172;
    --bs-tertiary-color: #6E7A85;
    --bs-tertiary-color-rgb: 110, 122, 133;
    --bs-emphasis-color: #E9ECEE;
    --bs-emphasis-color-rgb: 233, 236, 238;
    --bs-light: #212B33;
    --bs-light-rgb: 33, 43, 51;
    --bs-link-color: #D9A54B;
    --bs-link-color-rgb: 217, 165, 75;
    --bs-link-hover-color: #EBC077;

    --surface: rgba(26, 34, 42, 0.55);

    --surface-menu: rgba(26, 34, 42, 0.97);
    --surface-alt: rgba(33, 43, 51, 0.45);
    --ink: #E9ECEE;
    --muted: #93A1AC;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #D9A54B;
    --accent-ink: #17212A;
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.35);

    --brand-purple: #9B87C4;
    --brand-purple-rgb: 155, 135, 196;
}

body {
    /* No background-color of its own on purpose - the Liquid Glass mesh (body::before, below)
       carries its own solid fallback color as the bottom layer of its gradient stack, so nothing
       opaque sits between it and the viewport. body::before's fixed position means it never needs
       a positioned ancestor, so body itself stays position:static. */
    color: var(--ink);
    font-family: var(--font-body);
    min-height: 100vh;
}

/* ── Liquid Glass animated mesh backdrop - every frosted "surface" token above shows THIS through
   its blur, which is the whole visual premise of glassmorphism (a flat page behind blurred glass
   just looks like grey mist). Uses the theme's own --bs-*-rgb tokens so it re-tints automatically
   in dark mode with no separate block needed, same precedent as .profile-dropdown/.ai-assistant-*. */
body::before {
    content: "";
    position: fixed;
    inset: -15%;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(circle at 15% 20%, rgba(var(--bs-primary-rgb), 0.38), transparent 42%),
        radial-gradient(circle at 85% 12%, rgba(var(--bs-info-rgb), 0.32), transparent 46%),
        radial-gradient(circle at 78% 82%, rgba(var(--bs-success-rgb), 0.3), transparent 46%),
        radial-gradient(circle at 20% 88%, rgba(var(--brand-red-rgb), 0.22), transparent 42%),
        var(--bs-body-bg);
    filter: blur(70px) saturate(150%);
    animation: glassMeshDrift 28s ease-in-out infinite alternate;
}

@keyframes glassMeshDrift {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-3%, 2%, 0) scale(1.1); }
    100% { transform: translate3d(3%, -2%, 0) scale(1); }
}

/* ── Shared Liquid Glass entrance animations - reused by .login-card, .card, .stat-card/
   .chart-card above, and .glass-page-enter below, so every surface in the app enters the same way. */
@keyframes glassPopIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glassFadeUp {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Applied by shell.js to .page-body right as the #pageLoadOverlay fades out, so page-to-page
   navigation (this is a traditional multi-page app, not an SPA) always has a soft entrance instead
   of content just appearing. Re-triggers correctly on every navigation since it's added fresh by
   JS each time, never left on the element from a previous page. */
.glass-page-enter {
    animation: glassFadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .login-card, .card, .stat-card, .chart-card, .glass-page-enter {
        animation: none !important;
    }
    .btn, .btn:active {
        transition: none !important;
        transform: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before { animation: none; }
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
}

.btn {
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:active {
    transform: scale(0.96);
}

/* Bootstrap 5.3's compiled .btn-{variant} rules hardcode their own --bs-btn-bg/--bs-btn-border-
   color/etc as literal hex values (e.g. #0d6efd for primary) rather than reading --bs-primary -
   so without this, every themed button on the site silently renders Bootstrap's stock blue/green/
   red instead of this app's actual brass/teal/red palette, regardless of the --bs-primary/
   --bs-success/--bs-danger overrides at :root above. Re-pointing each variant's own component-
   scoped tokens at this app's real accent colors is the fix Bootstrap's own variable system
   expects for exactly this situation. */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--bs-link-hover-color);
    --bs-btn-hover-border-color: var(--bs-link-hover-color);
    --bs-btn-active-bg: var(--bs-link-hover-color);
    --bs-btn-active-border-color: var(--bs-link-hover-color);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
    color: var(--accent-ink);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
    box-shadow: 0 6px 16px rgba(var(--bs-primary-rgb), 0.35), var(--glass-highlight);
}
.btn-primary:hover {
    filter: brightness(1.06);
    box-shadow: 0 8px 22px rgba(var(--bs-primary-rgb), 0.42), var(--glass-highlight);
}

.btn-success {
    --bs-btn-bg: var(--bs-success);
    --bs-btn-border-color: var(--bs-success);
    --bs-btn-hover-bg: var(--bs-success);
    --bs-btn-hover-border-color: var(--bs-success);
    --bs-btn-active-bg: var(--bs-success);
    --bs-btn-active-border-color: var(--bs-success);
    --bs-btn-disabled-bg: var(--bs-success);
    --bs-btn-disabled-border-color: var(--bs-success);
}
.btn-success:hover { filter: brightness(1.08); }

.btn-danger {
    --bs-btn-bg: var(--bs-danger);
    --bs-btn-border-color: var(--bs-danger);
    --bs-btn-hover-bg: var(--bs-danger);
    --bs-btn-hover-border-color: var(--bs-danger);
    --bs-btn-active-bg: var(--bs-danger);
    --bs-btn-active-border-color: var(--bs-danger);
    --bs-btn-disabled-bg: var(--bs-danger);
    --bs-btn-disabled-border-color: var(--bs-danger);
}
.btn-danger:hover { filter: brightness(1.08); }

/* Same hardcoded-token issue as the solid variants above, for every .btn-outline-* used across
   the app's list pages (Edit/Delete row actions, Cancel-style secondary actions, etc). */
.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent);
    --bs-btn-active-border-color: var(--accent);
    --bs-btn-disabled-color: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-secondary {
    --bs-btn-color: var(--bs-secondary);
    --bs-btn-border-color: var(--bs-secondary);
    --bs-btn-hover-bg: var(--bs-secondary);
    --bs-btn-hover-border-color: var(--bs-secondary);
    --bs-btn-active-bg: var(--bs-secondary);
    --bs-btn-active-border-color: var(--bs-secondary);
    --bs-btn-disabled-color: var(--bs-secondary);
    --bs-btn-disabled-border-color: var(--bs-secondary);
}
.btn-outline-success {
    --bs-btn-color: var(--bs-success);
    --bs-btn-border-color: var(--bs-success);
    --bs-btn-hover-bg: var(--bs-success);
    --bs-btn-hover-border-color: var(--bs-success);
    --bs-btn-active-bg: var(--bs-success);
    --bs-btn-active-border-color: var(--bs-success);
    --bs-btn-disabled-color: var(--bs-success);
    --bs-btn-disabled-border-color: var(--bs-success);
}
.btn-outline-danger {
    --bs-btn-color: var(--bs-danger);
    --bs-btn-border-color: var(--bs-danger);
    --bs-btn-hover-bg: var(--bs-danger);
    --bs-btn-hover-border-color: var(--bs-danger);
    --bs-btn-active-bg: var(--bs-danger);
    --bs-btn-active-border-color: var(--bs-danger);
    --bs-btn-disabled-color: var(--bs-danger);
    --bs-btn-disabled-border-color: var(--bs-danger);
}
.btn-outline-warning {
    --bs-btn-color: var(--bs-warning);
    --bs-btn-border-color: var(--bs-warning);
    --bs-btn-hover-bg: var(--bs-warning);
    --bs-btn-hover-border-color: var(--bs-warning);
    --bs-btn-active-bg: var(--bs-warning);
    --bs-btn-active-border-color: var(--bs-warning);
    --bs-btn-disabled-color: var(--bs-warning);
    --bs-btn-disabled-border-color: var(--bs-warning);
}
.btn-outline-info {
    --bs-btn-color: var(--bs-info);
    --bs-btn-border-color: var(--bs-info);
    --bs-btn-hover-bg: var(--bs-info);
    --bs-btn-hover-border-color: var(--bs-info);
    --bs-btn-active-bg: var(--bs-info);
    --bs-btn-active-border-color: var(--bs-info);
    --bs-btn-disabled-color: var(--bs-info);
    --bs-btn-disabled-border-color: var(--bs-info);
}

.login-card {
    max-width: 380px;
    margin: 8rem auto 0;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-color: var(--border);
    box-shadow: var(--shadow), var(--glass-highlight);
    animation: glassPopIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.login-brand .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-brand .title {
    font-family: var(--font-display);
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--ink);
}

.login-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
}

.table-actions {
    white-space: nowrap;
}

/* A second horizontal scrollbar above a wide table (js/table-top-scroll.js). While it shows, it
   takes the table's top gap, so it sits right on the table. min-height leaves room for an overlay
   scrollbar (macOS), which is drawn inside the box. */
.table-top-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    min-height: 12px;
    margin-top: .5rem;
}
.table-top-scroll > div { height: 1px; }
.table-top-scroll:not(.d-none) + .table-responsive { margin-top: 0 !important; }

/* An open answer as typed (Submitted Surveys), with its AI follow-up questions and replies as a
   small thread under it (submissions.js freeTextHtml). */
.answer-text { white-space: pre-line; }
.answer-probe {
    border-inline-start: 3px solid var(--bs-info-border-subtle, #9eeaf9);
    padding-inline-start: .6rem;
    margin-top: .5rem;
}
.answer-probe__question { font-size: .875rem; color: var(--bs-secondary-color, #6c757d); }

/* ── Page-load overlay ──────────────────────────────────────────────────────
   Covers the empty #shell-sidebar/#shell-topbar/.page-body skeleton during the brief window
   between HTML parse and Shell.render() actually populating them - present by default in every
   page's raw markup (see pages/*.html, right after <body>) and removed by Shell.render() itself
   (shell.js) once the sidebar/topbar are built, the one place every authenticated page already
   calls. Pure CSS, no Bootstrap/JS dependency, so it paints correctly on the very first frame -
   site.css is a render-blocking <head> stylesheet, so this never itself flashes unstyled, and the
   inline dark/light pre-paint script at the top of <head> means its background is never the
   wrong theme either. */
.page-load-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--bs-body-bg-rgb), 0.65);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    opacity: 1;
    transition: opacity 0.25s ease;
}

/* Added by shell.js right before removing the overlay from the DOM, so the handoff to the real
   page is a fade rather than an instant pop - see Shell.render's own doc comment. */
.page-load-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.page-load-spinner {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: page-load-spin 0.7s linear infinite;
}

@keyframes page-load-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .page-load-spinner {
        animation: none;
    }
}

/* App shell: left sidebar + main content column */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border);
    box-shadow: var(--glass-highlight);
    display: flex;
    flex-direction: column;
    transition: width 0.15s ease, transform 0.2s ease;
    position: relative;
    z-index: 1;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 1.75rem 1.25rem 1.4rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
    overflow: hidden;
}

.sidebar-brand .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 800;
    font-size: 1rem;
}

.sidebar-brand .brand-text {
    line-height: 1.2;
}

.sidebar-brand .brand-text .title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    color: var(--ink);
}

.sidebar-brand .brand-text .subtitle {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-top: 0.15rem;
}

.sidebar.collapsed .sidebar-brand {
    padding: 1.75rem 0.5rem 1.4rem;
}

.sidebar.collapsed .sidebar-brand .brand-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.sidebar-nav .nav-item-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 1.25rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav .nav-item-link i {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-item-link:hover {
    background: var(--surface-alt);
    color: var(--ink);
}

.sidebar-nav .nav-item-link {
    transition: background 0.15s ease, color 0.15s ease, border-left-color 0.15s ease;
}

.sidebar-nav .nav-item-link.active {
    background: rgba(var(--bs-primary-rgb), 0.16);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.sidebar.collapsed .sidebar-nav .nav-item-link span {
    display: none;
}

/* ── Collapsible sidebar sections (see Shell.navSections/render) - groups the sidebar's 16 links
   under 4 headings so the list doesn't have to be scanned top to bottom every time. Built on
   Bootstrap's own Collapse component (.collapse/.collapse.show, data-bs-toggle="collapse") rather
   than hand-rolled JS - Shell.render's initial markup already sets the correct starting
   expanded/collapsed state per page load, and Bootstrap's own delegated click handling (already
   loaded on every page) takes over from there with zero extra listeners needed here. ── */
.nav-section {
    margin-top: 0.35rem;
}

.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.nav-section-header:hover {
    color: var(--ink);
}

/* Marks the one section containing the page the admin is currently on - distinct from (and in
   addition to) that specific link's own .active highlight below it, so the right section is
   visually obvious even while it's still collapsed on some other page. */
.nav-section-header.has-active {
    color: var(--accent);
}

.nav-section-chevron {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

/* Bootstrap adds/removes "collapsed" on the toggle button itself to reflect its target's state -
   reusing that class (rather than tracking expanded/collapsed with a class of our own) is what
   lets the chevron rotate correctly after a click with no extra JS on our side. */
.nav-section-header:not(.collapsed) .nav-section-chevron {
    transform: rotate(180deg);
}

/* Collapsing the WHOLE sidebar to its icon-only rail (the pre-existing, unrelated
   collapse-toggle/#collapseToggleBtn feature) always shows every link's icon regardless of which
   sections were expanded/collapsed - the two collapsing mechanisms are independent, and forcing
   every section's icons visible here is what keeps the icon rail exactly as it always behaved. */
.sidebar.collapsed .nav-section-header {
    display: none;
}
.sidebar.collapsed .nav-section-body {
    display: block !important;
}

/* Unread-conversation count on the Chat & Notifications nav link (see
   Shell.refreshChatUnreadBadge) - a count of CONVERSATIONS with unread messages, not messages
   themselves. margin-left:auto pushes it to the link's trailing edge in the normal (expanded)
   sidebar; collapsed mode repositions it as a small corner badge over the icon instead, since the
   label (and the space margin-left:auto would push into) is hidden there. */
/* Survey Detail page - "Survey Type / Show Review Screen / Action Log / Email Alerts" summary
   cards (see survey-detail.html's own comment - a pure HTML/CSS visual reorganization, every input
   keeps its original id and stays inside #surveyDetailsForm, so no JS behavior changes). Each card
   is a tinted, left-accented box with an icon chip; the three single-toggle cards (green/purple/
   orange) put a Bootstrap form-switch at the header's trailing edge instead of a plain checkbox +
   label, matching the more compact "flip this feature on/off" framing those three have (Survey
   Type keeps its two plain checkboxes, since Task-Assigned/Standalone aren't mutually exclusive). */
/* Bootstrap grid columns are flex items (children of .row, which is display:flex), and a flex
   item's default min-width is auto - not 0 - meaning if ANY content inside one of these 5 cards
   (a <select>'s widest option text, a long alert/warning sentence, the disclaimer textarea's
   placeholder, etc.) is wider than the column's Bootstrap-calculated percentage width, the column
   refuses to shrink to fit and the whole .row overflows horizontally instead of wrapping onto a
   new line like it's supposed to. .page-body's own overflow-x: hidden then silently clips
   whatever got pushed past the right edge - in source order, that's always the LAST card(s) in
   the row (Survey Type/Standalone Branding), which is exactly the "last two tabs disappear"
   symptom this fixes. min-width: 0 is the standard, well-known fix for this flexbox default -
   it lets each column shrink to its intended width and wrap its own content instead. */
#surveyDetailsCard .row > [class*="col-"] {
    min-width: 0;
}

.survey-flag-card {
    padding: 1rem 1.1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    overflow-wrap: anywhere;
}
.survey-flag-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.survey-flag-card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.survey-flag-card-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 1rem;
}
.survey-flag-card-title strong {
    font-size: 0.9rem;
    color: var(--ink);
}
.survey-flag-card-desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}
.survey-flag-card.variant-blue { background: rgba(var(--bs-info-rgb), 0.1); border-color: rgba(var(--bs-info-rgb), 0.25); }
.survey-flag-card.variant-blue .survey-flag-card-icon { background: var(--bs-info); }
.survey-flag-card.variant-green { background: rgba(var(--bs-success-rgb), 0.1); border-color: rgba(var(--bs-success-rgb), 0.25); }
.survey-flag-card.variant-green .survey-flag-card-icon { background: var(--bs-success); }
.survey-flag-card.variant-purple { background: rgba(var(--brand-purple-rgb), 0.1); border-color: rgba(var(--brand-purple-rgb), 0.25); }
.survey-flag-card.variant-purple .survey-flag-card-icon { background: var(--brand-purple); }
.survey-flag-card.variant-orange { background: rgba(var(--bs-warning-rgb), 0.1); border-color: rgba(var(--bs-warning-rgb), 0.25); }
.survey-flag-card.variant-orange .survey-flag-card-icon { background: var(--bs-warning); }
.survey-flag-card.variant-red { background: rgba(var(--bs-danger-rgb), 0.1); border-color: rgba(var(--bs-danger-rgb), 0.25); }
.survey-flag-card.variant-red .survey-flag-card-icon { background: var(--bs-danger); }

/* Section heading above Name/Description/Display Mode/Languages - larger/bolder than a plain
   card-header, so this half of the page reads as its own clearly-labeled section rather than an
   unbroken continuation of the four summary cards above it. */
.survey-details-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

.nav-unread-badge {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
}
.sidebar.collapsed .sidebar-nav .nav-item-link {
    position: relative;
}
.sidebar.collapsed .sidebar-nav .nav-item-link .nav-unread-badge {
    margin-left: 0;
    position: absolute;
    top: 2px;
    right: 6px;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.6rem;
}

.sidebar-footer .collapse-toggle {
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    color: var(--muted);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer .collapse-toggle:hover {
    background: var(--surface-alt);
    border-radius: 6px;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--glass-highlight);
    gap: 1rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar .page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    margin: 0;
    color: var(--ink);
}

.topbar .page-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ── Profile badge + dropdown (topbar, top-right) ───────────────────────────── */
.profile-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 50px;
    padding: 0.3rem 0.65rem 0.3rem 0.3rem;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s;
}

.profile-badge:hover, .profile-badge[aria-expanded="true"] {
    background: var(--surface-alt);
    border-color: var(--border);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.75rem;
}

.profile-avatar.profile-avatar-lg {
    width: 40px;
    height: 40px;
    font-size: 0.85rem;
}

.profile-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
}

.profile-chevron {
    font-size: 0.7rem;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.profile-badge[aria-expanded="true"] .profile-chevron {
    transform: rotate(180deg);
}

.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--shadow), var(--glass-highlight);
    z-index: 1200;
    overflow: hidden;
}

.profile-dropdown.show {
    display: block;
    animation: profileDropdownFade 0.15s ease;
}

@keyframes profileDropdownFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--surface-alt);
}

.profile-dropdown-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink);
}

.profile-dropdown-role {
    font-size: 0.78rem;
    color: var(--muted);
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.profile-dropdown-item i {
    width: 1rem;
    text-align: center;
    color: var(--muted);
}

.profile-dropdown-item:hover {
    background: var(--surface-alt);
}

.profile-dropdown-logout {
    color: var(--bs-danger);
}

.profile-dropdown-logout i {
    color: var(--bs-danger);
}

.page-body {
    padding: 1.5rem;
    flex: 1;
    max-width: 100%;
    overflow-x: hidden;
}

.theme-toggle-btn, .help-toggle-btn, .mobile-nav-toggle {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--bs-border-radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.15s ease;
}
.theme-toggle-btn:active, .help-toggle-btn:active, .mobile-nav-toggle:active {
    transform: scale(0.92);
}

.theme-toggle-btn:hover, .help-toggle-btn:hover, .mobile-nav-toggle:hover {
    background: var(--surface-alt);
}

/* Pressed (help currently OFF) - a visibly different state from the default "on", not just a
   title-text difference, since aria-pressed alone isn't visible to a sighted mouse user. */
.help-toggle-btn[aria-pressed="false"] {
    background: var(--surface-alt);
    color: var(--muted);
}

/* Global help/description toggle (see help-visibility.js) - hides every first-visit tip banner,
   Info button/panel, and persistent page-description banner at once. Every such element carries
   this class; nothing else needs to know the toggle exists. !important because some of these
   elements (an open Bootstrap .collapse panel) carry their own display:block from a "show" class
   that would otherwise win. */
html.help-hidden .help-section {
    display: none !important;
}

.mobile-nav-toggle {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

/* Dashboard-style stat cards */
.stat-card, .chart-card {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--bs-border-radius-lg);
    padding: 1.1rem 1.25rem;
    height: 100%;
    box-shadow: var(--shadow), var(--glass-highlight);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
    animation: glassFadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stat-card:hover, .chart-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow), var(--glass-highlight), 0 16px 40px rgba(23, 33, 42, 0.16);
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink);
    margin-top: 0.35rem;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--bs-primary-rgb), 0.14);
    color: var(--accent);
}

.chart-card .chart-card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.card {
    background-color: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-color: var(--border);
    box-shadow: var(--glass-highlight);
    animation: glassFadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.card-header {
    font-family: var(--font-display);
    font-weight: 600;
    background-color: var(--surface-alt);
    border-bottom-color: var(--border);
}

/* ── Nav tabs (Survey Detail's Mapped Questions/Conditional Rules/Question Grids/Randomize
   Groups, Audit Log's Admin/Shopper Log, Chat's Shopper Chats/Notifications) - frosted pill tabs
   instead of Bootstrap's flat underline-tab default, matching the rest of the Liquid Glass
   surface language. Works identically whether the tabs sit on a tinted .card-header (Survey
   Detail, via .card-header-tabs) or straight on the page's own gradient mesh backdrop (Audit
   Log/Chat, plain .nav-tabs). ── */
.nav-tabs {
    border-bottom: none;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.card-header-tabs {
    margin-bottom: 0 !important;
}

.nav-tabs .nav-link {
    border: 1px solid transparent;
    border-radius: var(--bs-border-radius-pill);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
}

.nav-tabs .nav-link:hover {
    isolation: isolate; /* keeps the hover background from showing through a translucent sibling */
    border-color: transparent;
    background: var(--surface-alt);
    color: var(--ink);
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active:hover {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--ink);
    border-color: var(--border);
    box-shadow: var(--shadow), var(--glass-highlight);
}

.nav-tabs .nav-link:active {
    transform: scale(0.96);
}

.nav-tabs .nav-link .badge {
    transition: background-color 0.18s ease, color 0.18s ease;
}

/* The active tab's own count badge picks up the accent color so the currently-open tab reads
   clearly at a glance, even across a wrapped/multi-row tab bar - every inactive tab's badge stays
   the plain muted gray Bootstrap's bg-secondary already gives it. */
.nav-tabs .nav-link.active .badge {
    background-color: var(--accent) !important;
    color: var(--accent-ink);
}

.table {
    --bs-table-color: var(--ink);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    --bs-table-hover-bg: var(--surface-alt);
    --bs-table-hover-color: var(--ink);
}

.table td, .table th {
    vertical-align: middle;
}

.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom-width: 1px;
}

/* Standalone list-page tables (not nested in a .card) use .shadow-sm as their marker for
   "render like a raised surface" - give them an actual themed background to match, instead of
   the Bootstrap bg-white utility this used to lean on (which stayed white in dark mode). */
.table.shadow-sm {
    background-color: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    box-shadow: var(--glass-highlight);
}

.form-control, .form-select {
    background-color: var(--surface-alt);
    border-color: var(--border);
    color: var(--ink);
    transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--surface);
    color: var(--ink);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.2);
}

.form-control::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.modal-content {
    background-color: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--ink);
    border-color: var(--border);
    box-shadow: var(--shadow), var(--glass-highlight);
}

/* Bootstrap's own .modal.fade transform/opacity transition stays, this just gives it the
   spring-like "pop" Liquid Glass surfaces use elsewhere (login card, cards' own entrance). */
.modal.fade .modal-dialog {
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.dropdown-menu {
    background-color: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--ink);
    border-color: var(--border);
    box-shadow: var(--shadow), var(--glass-highlight);
}

/* KPI calculation preview */
.calc-preview {
    background: var(--surface-alt);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
}

.calc-preview table {
    font-size: 0.82rem;
}

.calc-preview .calc-formula {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    margin: 0.35rem 0;
    overflow-x: auto;
    white-space: nowrap;
}

.calc-preview .calc-result {
    font-weight: 700;
    color: var(--accent);
}

/* Numeric-heavy table columns line up cleanly */
.table .text-numeric, .table td.numeric {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* ---- Skeleton loading rows (ListToolkit.setLoading) ---- */
tr.list-skeleton-row td {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.skeleton-bar {
    height: 0.85rem;
    border-radius: var(--bs-border-radius-sm);
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.18) 25%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0.18) 75%);
    background-size: 200% 100%;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton-bar {
        animation: none;
        background: var(--surface-alt);
    }
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Responsive: off-canvas sidebar drawer + stacked-card tables below 880px/640px ---- */

@media (max-width: 880px) {
    .mobile-nav-toggle {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1040;
        width: min(var(--sidebar-width), 82vw);
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }

    .sidebar.collapsed {
        width: min(var(--sidebar-width), 82vw);
    }

    .sidebar.collapsed .sidebar-brand .brand-text,
    .sidebar.collapsed .sidebar-nav .nav-item-link span {
        display: block;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-footer {
        display: none;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1030;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .page-body {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    table.table-responsive-stack {
        border: none;
    }

    table.table-responsive-stack thead {
        display: none;
    }

    table.table-responsive-stack, table.table-responsive-stack tbody, table.table-responsive-stack tr {
        display: block;
        width: 100%;
    }

    table.table-responsive-stack tr {
        margin-bottom: 0.85rem;
        border: 1px solid var(--border);
        border-radius: var(--bs-border-radius);
        padding: 0.35rem 0;
        background: var(--surface);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        box-shadow: var(--shadow);
    }

    table.table-responsive-stack td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.4rem 0.75rem;
        border: none;
        text-align: right;
    }

    table.table-responsive-stack td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        text-align: left;
        margin-right: auto;
    }

    table.table-responsive-stack td:empty {
        display: none;
    }
}

/* ── Chat widget (floating footer widget, persists across page navigation) ───────── */
.chat-widget {
    position: fixed;
    right: 20px;
    bottom: 0;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--bs-border-radius-lg) var(--bs-border-radius-lg) 0 0;
    box-shadow: var(--shadow), var(--glass-highlight);
    z-index: 1400;
    display: flex;
    flex-direction: column;
    max-height: 460px;
}

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-widget-header .btn-icon {
    background: none;
    border: none;
    color: var(--accent-ink);
    opacity: 0.85;
    padding: 0 0.25rem;
}

.chat-widget-header .btn-icon:hover { opacity: 1; }

.chat-widget-header-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--bs-danger);
    margin-left: 6px;
    vertical-align: middle;
    border: 1.5px solid var(--accent);
}

.chat-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 220px;
    max-height: 300px;
}

.chat-widget.collapsed .chat-widget-body,
.chat-widget.collapsed .chat-widget-input-row,
.chat-widget.collapsed .chat-widget-load-more {
    display: none;
}

.chat-widget-load-more {
    text-align: center;
    font-size: 0.78rem;
    padding: 0.25rem 0 0.4rem;
}

.chat-msg {
    max-width: 82%;
    padding: 0.4rem 0.65rem;
    border-radius: 10px;
    font-size: 0.82rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.chat-msg-admin {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-ink);
    border-bottom-right-radius: 2px;
}

.chat-msg-shopper {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--ink);
    border-bottom-left-radius: 2px;
}

.chat-msg-sender {
    font-size: 0.68rem;
    opacity: 0.75;
    margin-bottom: 0.15rem;
    font-weight: 600;
}

.chat-msg-time {
    font-size: 0.65rem;
    opacity: 0.65;
    margin-top: 0.15rem;
}

.chat-msg-attachment img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 0.25rem;
    display: block;
}

/* Platform admins only: which tenant thread a reply goes into (chat-widget.js), and the tenant
   each message belongs to when the shopper works for several. */
.chat-widget-reply-tenant-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem 0;
    font-size: 0.75rem;
    border-top: 1px solid var(--border, #dee2e6);
}
.chat-widget-reply-tenant-row label { opacity: 0.75; white-space: nowrap; }
.chat-widget-reply-tenant {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border, #dee2e6);
    border-radius: 6px;
    background: transparent;
    color: inherit;
}
.chat-widget-readonly {
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    opacity: 0.75;
    border-top: 1px solid var(--border, #dee2e6);
}
.chat-msg-tenant {
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 0.15rem;
}

.chat-widget-input-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    border-top: 1px solid var(--border);
}

.chat-widget-input-row input[type="text"] {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    background: var(--surface);
    color: var(--ink);
}

.chat-widget-input-row .btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.05rem;
    padding: 0.2rem 0.35rem;
}

.chat-widget-input-row .btn-send {
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Chat module page (shopper list + unread badge, notification composer) ───────── */
.chat-unread-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--bs-danger);
    margin-right: 6px;
}

.chat-shopper-row { cursor: pointer; }
.chat-shopper-row-disabled { opacity: 0.55; cursor: not-allowed; }

/* Covers a form section (type/config/follow-up rules on a locked question) whose inputs are
   dynamically rendered, so individually disabling every input isn't reliable - pointer-events
   blocks interaction while the dimmed look signals "read-only" at a glance. */
.form-section-locked { opacity: 0.6; pointer-events: none; }

/* #configSectionWrap carves an exception out of the blanket rule above for the Input Style
   control (.ui-variant-wrap, see question-config-editors.js's optionsEditor) - switching between
   checkbox/radio and a dropdown-select is a rendering-only choice that never changes an already-
   locked question's stored answers, unlike everything else in its config, so it should stay
   editable while the rest of the section stays frozen. Opacity/pointer-events can't be selectively
   undone on one descendant once a shared ancestor has them (they apply to the whole rendered
   subtree as a group), so this un-locks the wrapper itself and re-applies the dimmed/inert
   treatment to every child except that one control instead. */
#configSectionWrap.form-section-locked {
    opacity: 1;
    pointer-events: auto;
}
#configSectionWrap.form-section-locked > label,
#configSectionWrap.form-section-locked #configEditorContainer > *:not(.ui-variant-wrap) {
    opacity: 0.6;
    pointer-events: none;
}

/* ── Toast - top-right, frosted Liquid Glass pill. Fired on every save/update/delete across the
   app (see each module's showAlert helper) as well as the shared survey-runner engine's own
   file-rejection messages. Toast.js (common-js) owns the show/auto-dismiss timing (adds "show" on
   display, removes it ~3s later, then deletes the element from the DOM ~200ms after that) - the
   transition durations below are tuned to finish within that same 200ms window so the element is
   never yanked out mid-animation. ── */
.toast-stack {
    position: fixed; top: 20px; right: 20px; left: auto; transform: none;
    width: 100%; max-width: 380px; padding: 0 16px; z-index: 1300;
    display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.app-toast {
    display: flex; align-items: center; gap: 10px; background: var(--surface);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--bs-border-radius); box-shadow: var(--shadow), var(--glass-highlight); padding: 12px 16px;
    font-size: 0.88rem; font-weight: 600; color: var(--ink);
    border-left: 4px solid var(--bs-success);
    opacity: 0; transform: translateX(24px) scale(0.96);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.app-toast.show { opacity: 1; transform: translateX(0) scale(1); }
.app-toast.app-toast-danger { border-left-color: var(--bs-danger); }
.app-toast-icon { font-size: 1.1rem; color: var(--bs-success); flex-shrink: 0; }
.app-toast-danger .app-toast-icon { color: var(--bs-danger); }

@media (max-width: 480px) {
    .toast-stack { right: 10px; left: 10px; max-width: none; padding: 0; }
}

/* ── Searchable select (text input + filtered dropdown panel) ── */
.searchable-select { position: relative; }
/* Glass panels (backdrop-filter) are each their own stacking context, so an open menu's z-index only
   counts inside its own panel and the next panel down is painted over it - lift the panel holding an
   open menu above its neighbours. */
.card:has(.searchable-select-menu:not(.d-none)) { position: relative; z-index: 30; }
.searchable-select-menu {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
    max-height: 280px; overflow-y: auto;
    background: var(--surface-menu, var(--surface)); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border); border-radius: var(--bs-border-radius);
    box-shadow: var(--shadow), var(--glass-highlight); padding: 4px;
}
.searchable-select-item {
    display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
    background: none; border: none; border-radius: 6px; padding: 8px 10px;
    font-size: 0.9rem; color: var(--ink);
}
.searchable-select-item:hover, .searchable-select-item:focus { background: var(--surface-alt); }
.searchable-select-empty { padding: 10px; }

/* ── Rich-text editor toolbar (Question Header / Description formatting) ── */
.rich-text-toolbar button.active { background: var(--surface-alt); }
.rich-text-editable {
    min-height: 2.5rem; height: auto; white-space: pre-wrap; word-break: break-word;
}
.rich-text-editable[data-single-line="true"] { min-height: 0; }
.rich-text-editable mark { background: #fff2a8; padding: 0 1px; }

/* ── AI Assistant chat widget (ai-chat-widget.js) - a self-mounting FLOATING widget, independent
   of the topbar's own per-page redraw: both the round trigger button (.ai-assistant-fab) and the
   panel it opens are injected straight into <body> with position:fixed, top-right, just below the
   topbar - not inside shell.js's topbar markup at all (that's what "doesn't close when pages
   change" actually means in a traditional multi-page app: there's no single persistent DOM to
   keep alive across a real navigation, so the widget's open/closed state AND its full message
   history are persisted to localStorage per admin instead, and replayed back on every page's own
   load - see ai-chat-widget.js's STORAGE_KEY). Themed entirely via existing tokens - no separate
   dark-mode block needed, same as .profile-dropdown. ── */
.ai-assistant-fab {
    position: fixed;
    top: 4.75rem;
    right: 1.5rem;
    z-index: 1300; /* above .profile-dropdown's 1200 */
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: var(--shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: grab;
    touch-action: none; /* lets a touch drag move the button instead of scrolling the page */
    user-select: none;
}
.ai-assistant-fab:hover {
    filter: brightness(1.08);
}
/* Switched off for the company or this admin: still there (greyed, struck through), and it opens
   a panel saying why (ai-chat-widget.js setAssistantOff). */
.ai-assistant-fab.ai-assistant-fab--off {
    background: var(--bs-secondary-bg, #e9ecef);
    color: var(--bs-secondary-color, #6c757d);
    opacity: 0.85;
}
/* ...and its panel shows only why: no "Ask about..." invitation. */
.ai-assistant-panel-wrap--off .ai-assistant-empty-state {
    display: none;
}
.ai-assistant-fab.ai-assistant-fab--off::after {
    content: "";
    position: absolute;
    width: 1.9rem;
    height: 2px;
    background: currentColor;
    transform: rotate(-45deg);
    border-radius: 1px;
}
/* Dragging follows the pointer exactly; on release it glides to the nearer side edge. */
.ai-assistant-fab.dragging {
    cursor: grabbing;
    transition: none;
    box-shadow: var(--shadow), 0 10px 24px rgba(0, 0, 0, 0.25);
}
.ai-assistant-fab.snapping {
    transition: left 0.22s ease, top 0.22s ease;
}
/* The panel opens on the button's side, below or above it (ai-chat-widget.js positionPanel). */
.ai-assistant-panel-wrap[data-placement="above"] {
    transform: translateY(8px) scale(0.98);
}
.ai-assistant-panel-wrap[data-placement="above"].open {
    transform: translateY(0) scale(1);
}
.ai-assistant-panel-wrap {
    position: fixed;
    top: 8rem;
    right: 1.5rem;
    z-index: 1300;
    width: min(380px, calc(100vw - 2rem));
    max-height: 70vh;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--shadow), var(--glass-highlight);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.ai-assistant-panel-wrap.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.ai-assistant-panel {
    padding: 0.9rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}
.ai-assistant-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ai-assistant-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.ai-assistant-clear-btn {
    border: none;
    background: none;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0.15rem 0.35rem;
}
.ai-assistant-clear-btn:hover {
    color: var(--ink);
}
/* The model picker under the header (BuzzQAI-serve / BuzzQAI-vary-1.1 - ai-chat-widget.js renderModelPicker). */
.ai-assistant-model-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: -0.25rem;
}
.ai-assistant-model-row label {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
}
.ai-assistant-model-row select {
    width: auto;
    max-width: 100%;
    font-size: 0.8rem;
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
}
/* A chart card's preview (sample numbers) and its edit fields - ai-chat-widget.js renderChartPreview. */
.ai-assistant-chart-preview {
    border: 1px dashed rgba(127, 127, 127, 0.45);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    margin-top: 0.5rem;
    background: var(--surface-alt);
}
.ai-assistant-chart-title { font-weight: 600; font-size: 0.85rem; }
.ai-assistant-chart-caption { font-size: 0.75rem; color: var(--muted); }
.ai-assistant-chart-canvas { position: relative; height: 170px; margin-top: 0.35rem; }
.ai-assistant-chart-number { font-size: 2rem; font-weight: 700; text-align: center; padding: 0.4rem 0; }
.ai-assistant-chart-table { font-size: 0.75rem; }
.ai-assistant-chart-calc { font-size: 0.75rem; margin-top: 0.35rem; }
.ai-assistant-chart-sample { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
.ai-assistant-chart-edit { margin-top: 0.4rem; font-size: 0.8rem; }
.ai-assistant-chart-edit summary { cursor: pointer; color: var(--accent); }
.ai-assistant-chart-colors { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ai-assistant-chart-colors input { width: 2rem; height: 1.6rem; padding: 0.1rem; }
/* Reference pictures waiting to go with the next message. */
.ai-assistant-attachments { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ai-assistant-attachment {
    display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%;
    border: 1px solid var(--border); border-radius: 6px; padding: 0.15rem 0.3rem; font-size: 0.72rem;
}
.ai-assistant-attachment img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.ai-assistant-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }
.ai-assistant-attachment .btn-close { font-size: 0.55rem; }
.ai-assistant-msg-pictures { font-size: 0.7rem; opacity: 0.85; margin-top: 0.25rem; }
/* Screenshots from the user guides under an answer - each opens full size. */
.ai-assistant-screenshots { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.ai-assistant-screenshot { display: block; text-decoration: none; color: inherit; }
.ai-assistant-screenshot img {
    display: block; width: 100%; height: auto; border-radius: 6px;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.12)); background: #fff;
}
.ai-assistant-screenshot-caption { display: block; font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem; }
/* Which model answered - under the answer. */
.ai-assistant-msg-model {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.3rem;
    white-space: normal;
}
.ai-assistant-messages {
    max-height: 45vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.ai-assistant-msg {
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    max-width: 85%;
    font-size: 0.9rem;
    white-space: pre-wrap;
}
.ai-assistant-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-ink);
}
.ai-assistant-msg-assistant {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--ink);
}
.ai-assistant-msg-error {
    align-self: flex-start;
    background: var(--surface-alt);
    color: var(--bs-danger);
}
/* An answer the assistant flagged - off-topic, beyond the person's role, or private data
   (AskAiAssistantResultDto.notice). */
.ai-assistant-msg-notice {
    border-left: 3px solid var(--bs-warning);
}
.ai-assistant-notice-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bs-warning-text-emphasis, #997404);
    margin-bottom: 0.15rem;
}
.ai-assistant-goto-btn {
    align-self: flex-start;
    font-size: 0.8rem;
}
/* A change the AI prepared - before/after rows, then Apply/Cancel (ai-chat-widget.js renderProposal). */
.ai-assistant-proposal {
    align-self: stretch;
    border: 1px solid rgba(127, 127, 127, 0.35);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
    background: var(--surface);
    color: var(--ink);
}
.ai-assistant-proposal-title {
    font-weight: 600;
    margin-bottom: 0.4rem;
}
.ai-assistant-proposal-row {
    padding: 0.3rem 0;
    border-top: 1px solid rgba(127, 127, 127, 0.2);
}
.ai-assistant-proposal-label {
    font-size: 0.75rem;
    color: var(--muted, inherit);
    opacity: 0.85;
}
.ai-assistant-proposal-before {
    text-decoration: line-through;
    opacity: 0.7;
    overflow-wrap: anywhere;
}
.ai-assistant-proposal-after {
    font-weight: 600;
    overflow-wrap: anywhere;
}
.ai-assistant-proposal-notes {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.78rem;
    opacity: 0.85;
}
.ai-assistant-proposal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.6rem;
}
.ai-assistant-proposal-status {
    font-size: 0.8rem;
    font-weight: 600;
}
.ai-assistant-proposal-status.applied { color: var(--bs-success); }
.ai-assistant-proposal-status.failed { color: var(--bs-danger); }
.ai-assistant-proposal-status.outdated { color: var(--bs-secondary-color); }
.ai-assistant-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}
/* A textarea that wraps and grows with the question (ai-chat-widget.js autoSizeInput), up to about
   6 lines - then it scrolls. */
#aiAssistantInput {
    resize: none;
    overflow-y: auto;
    max-height: 9.5rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ai-assistant-empty-state {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Points an admin at a specific known element (see ai-highlight-registry.json) - a pure additive
   class, no layout side effects (outline doesn't reflow), safe on any existing element regardless
   of its own styling. Removed automatically a few seconds after being applied. */
.ai-assistant-highlight {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
    animation: aiAssistantPulse 1.4s ease-in-out 3;
}
@keyframes aiAssistantPulse {
    0%, 100% { outline-color: var(--accent); }
    50% { outline-color: transparent; }
}

/* Assign Tasks page - visual (wire diagram) view: two flex columns (Tasks left, Shoppers right,
   the latter wrapping into a grid so a large shopper roster doesn't force one tall column) with an
   absolutely-positioned SVG overlay drawn on top by assignments.js, connecting each task to every
   shopper it's currently (non-Completed) assigned to. Read-only by design - no inputs in here. */
.assign-diagram {
    position: relative;
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}
.assign-diagram-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.assign-diagram-col {
    position: relative;
    z-index: 1;
}
.assign-diagram-tasks {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.assign-diagram-shoppers {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.5rem;
    min-width: 0;
}
.assign-diagram-node {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}
.assign-diagram-node.task-node {
    box-shadow: var(--shadow);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.assign-diagram-node.shopper-node {
    border-width: 2px;
    text-align: center;
    min-width: 140px;
    cursor: default;
}
/* Shopper box color reflects the shopper's own IsActive flag, independent of any task status. */
.assign-diagram-node.shopper-node.status-active {
    border-color: var(--bs-success);
}
.assign-diagram-node.shopper-node.status-inactive {
    border-color: var(--bs-danger);
    opacity: 0.65;
}
/* Above DIAGRAM_COMPACT_SHOPPER_THRESHOLD shoppers, boxes shrink to an email-only chip so the
   diagram stays legible instead of spilling into an unreadable wall of full-size cards - the full
   name/status/current-tasks detail is still available via the box's title (hover) tooltip. */
.assign-diagram-node.shopper-node.compact {
    min-width: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.assign-diagram-wire {
    fill: none;
    stroke-width: 1.5;
    opacity: 0.7;
}
.assign-diagram-wire.wire-pending {
    stroke: var(--bs-warning);
}
.assign-diagram-wire.wire-in-progress {
    stroke: var(--bs-info);
}
.assign-diagram-swatch {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 0.2rem;
    border: 2px solid var(--bs-success);
}
.assign-diagram-swatch.status-inactive {
    border-color: var(--bs-danger);
    opacity: 0.65;
}

/* Tenant Management's theme-color picker (tenants.html) - a row of round preset swatches plus a
   native <input type="color"> for a fully custom value. The "Default" pill (no color of its own,
   just text) is styled by the ordinary .btn-outline-secondary classes already on it in the markup. */
.color-swatch-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid transparent;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
}
.color-swatch-btn.color-swatch-default {
    width: auto;
    height: auto;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
}
.color-swatch-btn:not(.color-swatch-default).active {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}
.color-swatch-btn.color-swatch-default.active {
    border-color: var(--ink) !important;
    color: var(--ink) !important;
}
#tenantColorCustom {
    width: 2.5rem;
    height: 2.5rem;
    padding: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════════════════
   Survey Detail workspace (pages/survey-detail.html, body.sd-page) - section nav + one panel at a
   time. Nav is a sticky vertical list from lg up, a horizontally scrollable pill bar below.
   ══════════════════════════════════════════════════════════════════════════════════════════ */

/* .page-body's overflow-x: hidden makes it a scroll container, which breaks position: sticky for
   the nav and the Save bars; clip hides the same overflow without creating one. */
body.sd-page .page-body { overflow-x: clip; }

.min-w-0 { min-width: 0; }

.sd-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
}
.sd-header-title { display: flex; align-items: flex-start; gap: .75rem; min-width: 0; flex: 1 1 18rem; }
.sd-header-title h4 { font-family: var(--font-display); }
.sd-header-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.sd-back-link {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--bs-border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
}
.sd-back-link:hover { color: var(--accent); }

.sd-layout {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.sd-nav {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: .5rem;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--bs-border-radius);
    box-shadow: var(--glass-highlight);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}
.sd-nav-group {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: .65rem .65rem .25rem;
}
.sd-nav-group:first-child { padding-top: .25rem; }
.sd-nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .65rem;
    border-radius: var(--bs-border-radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-size: .925rem;
    white-space: nowrap;
}
.sd-nav-link > i { color: var(--muted); width: 1.1rem; text-align: center; }
.sd-nav-link:hover { background: rgba(var(--bs-primary-rgb), .08); color: var(--ink); }
.sd-nav-link.active { background: rgba(var(--bs-primary-rgb), .14); color: var(--accent); font-weight: 600; }
.sd-nav-link.active > i { color: var(--accent); }
.sd-nav-count {
    margin-left: auto;
    background: rgba(var(--bs-secondary-rgb), .14);
    color: var(--ink);
    font-weight: 600;
}
.sd-nav-link.active .sd-nav-count { background: rgba(var(--bs-primary-rgb), .2); color: var(--accent); }
.sd-dirty-dot {
    display: none;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--bs-warning);
    flex: 0 0 auto;
}
.sd-nav-link.is-dirty .sd-dirty-dot { display: inline-block; }
.sd-nav-link:not(:has(.sd-nav-count:not(.d-none))).is-dirty .sd-dirty-dot { margin-left: auto; }

.sd-panel { min-width: 0; }
.sd-panel-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .9rem;
}
.sd-panel-head > div:first-child { flex: 1 1 20rem; min-width: 0; }
.sd-panel-title {
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .25rem;
}
.sd-panel-title > i { color: var(--accent); }
.sd-panel-desc { color: var(--muted); margin-bottom: 0; font-size: .925rem; }
.sd-panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* Save/Discard bar - only rendered while its section has unsaved changes; sticks to the bottom of
   the viewport while scrolling a long section. */
.sd-savebar {
    position: sticky;
    bottom: 1rem;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-top: 1rem;
    padding: .65rem .9rem;
    border-radius: var(--bs-border-radius);
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(var(--bs-warning-rgb), .55);
    box-shadow: var(--shadow), var(--glass-highlight);
    animation: glassFadeUp .25s cubic-bezier(.22, 1, .36, 1) both;
}

.sd-inline-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    margin-bottom: 0;
}
.sd-pager-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border-top: 1px solid var(--bs-border-color);
}
.sd-search { max-width: 22rem; flex: 1 1 14rem; }
.sd-filter { max-width: 18rem; flex: 1 1 12rem; width: auto; }
.sd-narrow-input { max-width: 16rem; }
.sd-truncate { max-width: 16rem; vertical-align: bottom; }

.sd-language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: .15rem .75rem;
}
.sd-chip { min-width: 3.25rem; }

/* Overview tiles */
.sd-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
    gap: .75rem;
}
.sd-tile {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    text-align: left;
    padding: .9rem;
    border-radius: var(--bs-border-radius);
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    box-shadow: var(--glass-highlight);
    color: var(--ink);
    transition: transform .15s ease, box-shadow .15s ease;
}
.sd-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow), var(--glass-highlight); }
.sd-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sd-tile-icon {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: .65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.05rem;
}
.sd-tile-icon.tone-blue { background: var(--bs-info); }
.sd-tile-icon.tone-green { background: var(--bs-success); }
.sd-tile-icon.tone-orange { background: var(--bs-warning); }
.sd-tile-icon.tone-red { background: var(--bs-danger); }
.sd-tile-icon.tone-purple { background: var(--brand-purple); }
.sd-tile-icon.tone-grey { background: var(--bs-secondary); }
.sd-tile-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.sd-tile-title { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sd-tile-value { font-weight: 600; }
.sd-tile-detail { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.sd-tile-go { color: var(--muted); align-self: center; }

/* Logos (Branding) */
.sd-logo-row { padding: .75rem 0; border-bottom: 1px solid var(--bs-border-color); display: grid; gap: .4rem; }
.sd-logo-row:last-of-type { border-bottom: 0; }
.sd-logo-label { color: var(--muted); }
.sd-logo-preview { min-height: 3rem; display: flex; align-items: center; }
.sd-logo-preview img { max-height: 48px; max-width: 180px; object-fit: contain; }
.sd-file-input { max-width: 18rem; }

/* Question pickers in the Combine-into-grid / Randomize modals */
.sd-picker-list { max-height: 18rem; overflow-y: auto; }
.sd-picker-row {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--bs-border-color);
    cursor: pointer;
    margin: 0;
}
.sd-picker-row:last-child { border-bottom: 0; }
.sd-picker-row:hover { background: rgba(var(--bs-primary-rgb), .06); }
.sd-picker-row .form-check-input { margin-top: .2rem; flex: 0 0 auto; }

@media (max-width: 991.98px) {
    .sd-layout { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
    /* Nav becomes a single scrollable row of pills, pinned under the top of the viewport. */
    .sd-nav {
        top: 0;
        z-index: 20;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        padding: .4rem;
        scrollbar-width: thin;
    }
    .sd-nav-group { display: none; }
    .sd-nav-link { padding: .4rem .7rem; font-size: .875rem; }
    .sd-nav-link.d-none { display: none !important; }
}

@media (max-width: 575.98px) {
    .sd-tiles { grid-template-columns: minmax(0, 1fr); }
    .sd-panel-actions { width: 100%; }
    .sd-panel-actions > .btn,
    .sd-panel-actions > a.btn { flex: 1 1 auto; }
    .sd-savebar { bottom: .5rem; }
    .sd-savebar > span:last-child { width: 100%; }
    .sd-savebar > span:last-child .btn { flex: 1; }
}

/* ══════════════════════════════════════════════════════════════════════════════════════════
   List-table row actions (Surveys, Question Bank) - one visible primary action + a "more" menu,
   instead of a long run of inline buttons.
   ══════════════════════════════════════════════════════════════════════════════════════════ */
.row-actions { display: inline-flex; align-items: center; gap: .35rem; justify-content: flex-end; }
.row-actions .row-actions-more { padding-left: .45rem; padding-right: .45rem; line-height: 1; }
.row-actions .row-actions-more::after { display: none; }
/* Styled by its own class - while open, the menu is moved to <body> (see row-actions-menu.js). */
.row-actions-menu { min-width: 12rem; }
.row-actions-menu .dropdown-item { display: flex; align-items: center; gap: .55rem; }
.row-actions-menu .dropdown-item > i { width: 1rem; text-align: center; color: var(--muted); }
.row-actions-menu .dropdown-item.text-danger > i { color: inherit; }
.row-actions-menu .dropdown-item:disabled { opacity: .55; }
.table-actions .row-actions { white-space: nowrap; }
.list-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.list-toolbar > div { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
/* Question Bank: long rich-text question headers capped at two lines (full text on the Edit modal). */
.q-text-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 32rem;
}
.q-text-clamp p { margin-bottom: 0; }

/* ---- Guest complaint (GCM) rules - shared by Complaint Setup, Survey Detail and the Question Bank ---- */
.gcm-rule-card { border: 1px solid var(--bs-border-color); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--bs-body-bg); }
.gcm-rule-card.inactive { opacity: .6; }
.gcm-rule-summary { font-size: .9rem; color: var(--bs-secondary-color); overflow-wrap: anywhere; }
.gcm-option-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--bs-border-color); border-radius: 8px; padding: 8px 10px; }
.gss-flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: gssflow; }
.gss-flow li { display: flex; gap: 10px; align-items: flex-start; position: relative; }
.gss-flow-icon { flex: 0 0 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); }
.gss-status { padding-top: 8px; border-top: 1px solid var(--bs-border-color); }
.gcm-q-badge { font-size: .7rem; vertical-align: middle; }
@media (max-width: 991.98px) { .gss-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .gss-flow { grid-template-columns: 1fr; } }

/* ---- Shopper Admin (pages/shopper-admin.html) ---- */
.sa-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.sa-stat { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .75rem 1rem; text-align: left;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--bs-border-radius); box-shadow: var(--glass-highlight);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); color: var(--ink); }
.sa-stat:not(.is-static):hover { border-color: var(--accent); }
.sa-stat.is-static { cursor: default; opacity: 1; }
.sa-stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.sa-stat-label { font-size: .78rem; color: var(--muted); }
.sa-shopper { min-width: 0; overflow-wrap: anywhere; }
.sa-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.sa-tag { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); white-space: nowrap; }
.sa-tag > .bi-star-fill { color: var(--accent); font-size: .68rem; }
.sa-tag.is-paused { background: transparent; border-style: dashed; color: var(--muted); }
.sa-tag.is-tenant-off { text-decoration: line-through; color: var(--muted); }
.sa-tag.is-unassigned { background: color-mix(in srgb, var(--bs-warning) 18%, transparent); border-color: color-mix(in srgb, var(--bs-warning) 45%, transparent); }
.sa-tag-note { font-weight: 400; font-size: .7rem; }
.sa-tenant-checklist { display: flex; flex-direction: column; gap: .5rem; }
.sa-tenant-row { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface-alt); }
.sa-tenant-row .form-check-label { min-width: 0; }
.min-w-0 { min-width: 0; }
@media (max-width: 767.98px) { .sa-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- KPI dashboards (pages/kpi-v2.html, js/modules/kpi-v2-dashboard.js) ---- */
:root {
    --kpi-tile-0: #35b4c9; --kpi-tile-1: #b55553; --kpi-tile-2: #b79ad6;
    --kpi-tile-3: #9d9c99; --kpi-tile-4: #8fbf61; --kpi-tile-5: #7cb3df;
    --kpi-good: #1f9d3a; --kpi-warn: #e8740c;
}
.kpi-data-status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.kpi-layout { --kpi-row-h: 120px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.kpi-layout > .kpi-section { grid-column: span var(--w, 12); min-width: 0; }
/* KPIs inside a section sit on their own 12-column grid - widths/heights set per KPI (Arrange). */
.kpi-items { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .75rem; }
.kpi-items > * { grid-column: span var(--w, 12); min-width: 0; min-height: calc(var(--kpi-row-h) * var(--h, 1)); }
@media (max-width: 991.98px) {
    .kpi-layout > .kpi-section { grid-column: 1 / -1; }
    .kpi-items > * { grid-column: span var(--w-md, 12); }
}
@media (max-width: 575.98px) { .kpi-items > * { grid-column: span var(--w-sm, 12); } }
.kpi-section-title { font-weight: 700; margin: 0 0 .5rem; }
.kpi-explain-btn { border: 0; background: transparent; color: var(--muted); padding: 0 .25rem; line-height: 1; }
.kpi-explain-btn:hover, .kpi-explain-btn:focus-visible { color: var(--accent); }
.kpi-explain-btn.btn { color: inherit; padding: .25rem .5rem; }
.kpi-explain-corner { position: absolute; top: .4rem; right: .4rem; }
.kpi-pending { font-size: .8rem; color: var(--muted); font-weight: 400; }

.kpi-stat-card { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 1rem .9rem .8rem; text-align: center; border-radius: var(--bs-border-radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--glass-highlight); }
.kpi-stat-value { font-size: 1.6rem; font-weight: 700; color: var(--kpi-warn); line-height: 1.2; }
.kpi-stat-name { font-weight: 600; }
.kpi-stat-period { font-size: .78rem; color: var(--muted); }

.kpi-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 2rem; padding: 1rem 1.25rem; border-radius: var(--bs-border-radius);
    background: color-mix(in srgb, #f5a3b4 30%, var(--surface)); border: 1px solid var(--border); }
.kpi-banner-title { font-weight: 700; font-size: 1.05rem; min-width: 9rem; }
.kpi-banner-item { display: flex; align-items: center; gap: .5rem; }
.kpi-banner-value { font-size: 1.5rem; font-weight: 700; }
.kpi-banner-value.is-good { color: var(--kpi-good); }
.kpi-banner-value.is-warn { color: var(--kpi-warn); }
.kpi-banner-label { font-size: .85rem; max-width: 9rem; line-height: 1.2; }

.kpi-tile { position: relative; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 1rem .75rem; border-radius: var(--bs-border-radius); border: 1px solid var(--border); }
.kpi-tile-row.is-ring .kpi-tile { background: var(--surface); }
.kpi-tile-row.is-block .kpi-tile { background: var(--tile-color); color: #fff; }
.kpi-tile-row.is-block .kpi-explain-btn, .kpi-tile-row.is-block .kpi-tile-sub, .kpi-tile-row.is-block .kpi-pending { color: rgba(255,255,255,.85); }
.kpi-ring { position: relative; width: 96px; height: 96px; margin: 0 auto .5rem; }
.kpi-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.kpi-ring-track { fill: none; stroke: color-mix(in srgb, var(--tile-color) 22%, transparent); stroke-width: 3.2; }
.kpi-ring-fill { fill: none; stroke: var(--tile-color); stroke-width: 3.2; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.kpi-ring-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.15rem; color: var(--tile-color); }
.kpi-block-value { font-size: 2rem; font-weight: 700; margin: .5rem 0; }
.kpi-tile-name { font-weight: 600; }
.kpi-tile-sub, .kpi-tile-n { font-size: .78rem; }
.kpi-tile-sub { color: var(--muted); }

.kpi-trend-card, .kpi-rank-card { position: relative; border-radius: var(--bs-border-radius); background: var(--surface); border: 1px solid var(--border); padding: .75rem; }
.kpi-trend-canvas { height: 260px; }
.kpi-rank-card { min-height: calc(var(--kpi-row-h, 120px) * var(--h, 1)); }
.kpi-chart-card { position: relative; border-radius: var(--bs-border-radius); background: var(--surface); border: 1px solid var(--border); padding: .6rem .75rem .75rem; }
.kpi-chart-name { font-weight: 600; padding-right: 3.5rem; margin-bottom: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-chart-body { position: relative; min-height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.kpi-chart-body canvas { position: absolute; inset: 0; }
.kpi-chart-value { font-size: 2.2rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.kpi-rank-card thead th { font-size: .8rem; }
.kpi-rank-card.is-top thead th { color: var(--kpi-good); }
.kpi-rank-card.is-bottom thead th { color: var(--kpi-warn); }
.kpi-rank-row { cursor: pointer; }
.kpi-rank-row:hover, .kpi-rank-row:focus-visible { background: color-mix(in srgb, var(--accent) 8%, transparent); outline: none; }

.kpi-explain { --bs-offcanvas-width: min(640px, 100vw); }
.kpi-explain-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.kpi-explain-steps li { margin-bottom: .25rem; }
.kpi-explain-questions li { margin-bottom: .25rem; }
.kpi-sources-table tr.is-excluded td { color: var(--muted); }
.kpi-counted { font-size: .75rem; padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; background: color-mix(in srgb, var(--muted) 15%, transparent); }
.kpi-counted-numerator, .kpi-counted-promoter, .kpi-counted-value { background: color-mix(in srgb, var(--kpi-good) 18%, transparent); }
.kpi-counted-detractor { background: color-mix(in srgb, var(--kpi-warn) 22%, transparent); }

.kpi-gen-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.kpi-gen-option { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface-alt); cursor: pointer; }
.kpi-gen-option:has(input:checked) { border-color: var(--accent); }
.gen-section { border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); padding: .6rem .75rem; margin-bottom: .6rem; }
.gen-section-head { margin-bottom: .4rem; }
.gen-metric { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; border-top: 1px dashed var(--border); }
.gen-metric .form-check-input { margin-top: .45rem; flex-shrink: 0; }

/* ---- KPI exports, Reports page, My activity (kpi-export.js, reports.js, report-activity.js) ---- */
.kpi-corner-tools { position: absolute; top: .35rem; right: .35rem; display: flex; align-items: center; gap: .1rem; z-index: 2; }
.kpi-export-btn { border: 0; background: transparent; color: var(--muted); padding: 0 .3rem; line-height: 1; }
.kpi-export-btn:hover, .kpi-export-btn:focus-visible { color: var(--accent); }
.kpi-export-btn:disabled { opacity: .6; }
.kpi-tile-row.is-block .kpi-export-btn { color: rgba(255,255,255,.85); }
.kpi-banner-item .kpi-export-menu { display: inline-block; }
.kpi-export-menu .dropdown-menu { min-width: 10rem; }
.kpi-rank-card, .kpi-trend-card { padding-top: 2rem; }
.kpi-explain-rules li { display: flex; gap: .5rem; align-items: baseline; margin-bottom: .35rem; }
.kpi-rule-kind { flex-shrink: 0; min-width: 7.5rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
@media (max-width: 575.98px) { .kpi-explain-rules li { flex-direction: column; gap: 0; } }
.report-card-value { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.report-card-chart { height: 220px; margin-top: .5rem; }
.report-activity-list { list-style: none; padding: 0; margin: 0; }
.report-activity-list li { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.report-activity-list li:last-child { border-bottom: 0; }
.report-activity-icon { flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
@media (max-width: 575.98px) { .report-activity-list li { flex-wrap: wrap; } .report-activity-list time { margin-left: 2.75rem !important; } }
.report-survey-list { max-height: 14rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); padding: .4rem .6rem; background: var(--surface-alt); }
.report-survey-row { display: flex; gap: .5rem; align-items: center; padding: .2rem 0; cursor: pointer; }

/* ---- KPI layout editor - Arrange (js/modules/kpi-layout-editor.js) ---- */
.kle-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 991.98px) { .kle-wrap { grid-template-columns: minmax(0, 1fr); } }
.kle-palette { position: sticky; top: 1rem; }
@media (max-width: 991.98px) { .kle-palette { position: static; } }
.kle-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.kle-add-grid .btn { text-align: left; white-space: normal; line-height: 1.2; }
.kle-palette-list { display: flex; flex-direction: column; gap: .4rem; min-height: 3.5rem; max-height: 50vh; overflow-y: auto; padding: .25rem; border-radius: var(--bs-border-radius-sm); background: var(--surface-alt); }
.kle-palette-list:not(:has(.kle-chip))::before { content: attr(data-empty); color: var(--muted); font-size: .85rem; padding: .75rem .5rem; text-align: center; }
.kle-chip { display: flex; align-items: center; gap: .5rem; padding: .4rem .55rem; font-size: .85rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface); cursor: grab; }
.kle-canvas { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.kle-canvas-empty { grid-column: 1 / -1; padding: 3rem 1rem; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--bs-border-radius); }
.kle-section { grid-column: span var(--w, 12); position: relative; min-width: 0; padding: .5rem; border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: var(--bs-border-radius); background: var(--surface-alt); }
@media (max-width: 991.98px) { .kle-section { grid-column: 1 / -1; } }
.kle-section-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.kle-section-head .kle-title { flex: 1 1 8rem; min-width: 8rem; width: auto; }
.kle-section-head .form-select { width: auto; }
.kle-section-head .kle-limit { width: 4.5rem; display: inline-block; }
.kle-inline { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.kle-type { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); white-space: nowrap; }
.kle-grip { cursor: grab; color: var(--muted); padding: .1rem .15rem; touch-action: none; font-size: 1.1rem; }
.kle-items { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .5rem; min-height: 4.5rem; padding: .25rem; border-radius: var(--bs-border-radius-sm); }
.kle-items:not(:has([data-mid]))::before { content: attr(data-empty); grid-column: 1 / -1; padding: 1.1rem .5rem; text-align: center; color: var(--muted); font-size: .85rem; border: 2px dashed var(--border); border-radius: var(--bs-border-radius-sm); }
.kle-items.is-banner > .kle-item { grid-column: span 4; }
.kle-items > .kle-chip { grid-column: span 3; }
.kle-item { grid-column: span var(--w, 12); position: relative; min-width: 0; min-height: calc(56px * var(--h, 1) + 8px * (var(--h, 1) - 1)); display: flex; flex-direction: column; gap: .1rem;
    padding: .45rem 1.4rem .45rem .55rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface); cursor: grab; touch-action: manipulation; }
@media (max-width: 991.98px) { .kle-item { grid-column: span var(--w-md, 12); } }
@media (max-width: 575.98px) { .kle-item { grid-column: span var(--w-sm, 12); } }
.kle-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kle-item.is-mismatch { border-color: var(--kpi-warn); }
.kle-item-name { font-weight: 600; font-size: .82rem; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kle-item-value { font-weight: 700; color: var(--accent); }
.kle-item-warn { font-size: .72rem; color: var(--kpi-warn); line-height: 1.2; }
.kle-item-size { margin-top: auto; font-size: .7rem; color: var(--muted); }
.kle-item-remove { position: absolute; top: .2rem; right: .2rem; border: 0; background: transparent; color: var(--muted); padding: 0 .15rem; line-height: 1; font-size: .75rem; }
.kle-item-remove:hover, .kle-item-remove:focus-visible { color: var(--bs-danger); }
.kle-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; border-bottom-right-radius: inherit;
    background: linear-gradient(135deg, transparent 0 55%, color-mix(in srgb, var(--accent) 70%, transparent) 55% 62%, transparent 62% 72%, color-mix(in srgb, var(--accent) 70%, transparent) 72% 79%, transparent 79%); }
.kle-resize-x { position: absolute; top: .75rem; bottom: .75rem; right: -7px; width: 12px; cursor: ew-resize; touch-action: none; border-radius: 6px; }
.kle-resize-x::after { content: ""; position: absolute; top: 50%; left: 4px; width: 4px; height: 2.25rem; transform: translateY(-50%); border-radius: 2px; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.kle-section:hover .kle-resize-x::after { background: var(--accent); }
@media (max-width: 991.98px) { .kle-resize-x { display: none; } }
.kle-ghost { opacity: .35; }
.kle-chosen { box-shadow: 0 0 0 2px var(--accent); }
body.kle-resizing, body.kle-resizing * { cursor: nwse-resize !important; user-select: none; }

/* ---- AI Survey Builder - review step (js/modules/survey-builder.js) ---- */
.sb-source-tabs .nav-link { padding: .35rem .8rem; }
.sb-review-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (min-width: 1200px) { .sb-review-grid.with-source { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.sb-source { position: sticky; top: 1rem; }
@media (max-width: 1199.98px) { .sb-source { position: static; } }
.sb-source-body { max-height: calc(100vh - 12rem); overflow-y: auto; display: flex; flex-direction: column; gap: .25rem; padding-right: .25rem; }
@media (max-width: 1199.98px) { .sb-source-body { max-height: 26rem; } }
.sb-key.is-missed { padding: 0 .3rem; border-radius: 3px; background: color-mix(in srgb, var(--kpi-warn, #e8740c) 25%, transparent); }
div.sb-block { display: flex; gap: .5rem; align-items: flex-start; padding: .3rem .45rem; border-radius: var(--bs-border-radius-sm); border-left: 3px solid transparent; font-size: .85rem; cursor: pointer; }
div.sb-block:hover, div.sb-block:focus-visible { background: color-mix(in srgb, var(--accent) 6%, transparent); outline: none; }
.sb-block.sb-heading .sb-block-text { font-weight: 700; }
.sb-block-id { flex-shrink: 0; min-width: 2.4rem; font-family: var(--bs-font-monospace); font-size: .72rem; color: var(--muted); padding-top: .1rem; font-weight: 400; }
.sb-block-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sb-block.is-cited { border-left-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.sb-block.is-missed { border-left-color: var(--kpi-warn, #e8740c); background: color-mix(in srgb, var(--kpi-warn, #e8740c) 12%, transparent); }
.sb-block-uses { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.sb-block-uses .badge { font-weight: 500; }
.sb-block-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .35rem; }
.sb-block-actions .form-select { width: auto; max-width: 12rem; }
.sb-missed-label { color: var(--kpi-warn, #e8740c); flex-basis: 100%; }
.sb-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); margin: .25rem 0; }
.sb-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.sb-table tr.sb-block { cursor: pointer; border-left: 3px solid transparent; }
.sb-table tr.sb-block + tr.sb-block { border-top: 1px solid var(--border); }
.sb-table th, .sb-table td { padding: .3rem .45rem; vertical-align: top; overflow-wrap: anywhere; }
.sb-table tr.sb-block:hover, .sb-table tr.sb-block:focus-visible { background: color-mix(in srgb, var(--accent) 6%, transparent); outline: none; }
.sb-table tr.is-missed > * { background: color-mix(in srgb, var(--kpi-warn, #e8740c) 12%, transparent); }
.sb-table tr.is-cited > th { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.sb-table tr.is-missed > th { box-shadow: inset 3px 0 0 var(--kpi-warn, #e8740c); }
.sb-row-meta:empty { display: none; }
.sb-row-meta { min-width: 9rem; }
.sb-source-body[data-filter="missed"] .sb-block:not(.is-missed),
.sb-source-body[data-filter="unused"] .sb-block.is-cited { display: none; }
.sb-source-body[data-filter="missed"] .sb-table-wrap:not(:has(.is-missed)),
.sb-source-body[data-filter="unused"] .sb-table-wrap:not(:has(.sb-block:not(.is-cited))) { display: none; }
@keyframes sb-flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.sb-flash { animation: sb-flash 1.6s ease-out; }

.sb-ref-chips { display: inline-flex; flex-wrap: wrap; gap: .2rem; align-items: center; }
.sb-ref { cursor: pointer; font-family: var(--bs-font-monospace); font-weight: 500; }
.sb-ref:hover, .sb-ref:focus-visible { border-color: var(--accent) !important; color: var(--accent) !important; }

.question-card .qb-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.qb-grip { cursor: grab; color: var(--muted); font-size: 1.15rem; padding: 0 .1rem; touch-action: none; }
.qb-number { flex-shrink: 0; min-width: 1.6rem; height: 1.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: .75rem; font-weight: 700;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.qb-head-name { flex: 1 1 14rem; }
.qb-head-name .badge { font-weight: 500; }
.qb-head-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-head-actions { display: inline-flex; gap: .3rem; margin-left: auto; }
#questionCardsContainer.sb-compact .qb-body { display: none; }
#questionCardsContainer.sb-compact .question-card .qb-head { border-bottom: 0; }

/* AI Survey Builder - Flow tab (survey-builder.js renderFlow) */
.sb-flow-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.sb-flow-search { max-width: 26rem; flex: 1 1 16rem; }
.sb-flow-summary { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; color: var(--muted); }
.sb-flow-chip { font-size: .8rem; padding: .15rem .6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.sb-flow-chip.is-bad { color: var(--bs-danger); border-color: var(--bs-danger); }
.sb-flow-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: .6rem; }
.sb-flow-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .3rem; vertical-align: middle; background: var(--accent); }
.sb-flow-dot.is-start { background: var(--bs-success); }
.sb-flow-dot.is-end { background: var(--kpi-good, #1f9d3a); box-shadow: 0 0 0 2px color-mix(in srgb, var(--kpi-good, #1f9d3a) 30%, transparent); }
.sb-flow-dot.is-unreachable { background: transparent; border: 2px dashed var(--bs-danger); }
.sb-flow { display: flex; flex-direction: column; gap: .6rem; }
.sb-flow-node { position: relative; padding: .7rem .9rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--bs-border-radius); background: var(--surface); }
.sb-flow-node + .sb-flow-node::before { content: ""; position: absolute; left: 1.55rem; top: -.65rem; height: .6rem; border-left: 2px solid var(--border); }
.sb-flow-node.is-start { border-left-color: var(--bs-success); }
.sb-flow-node.is-end { border-left-color: var(--kpi-good, #1f9d3a); }
.sb-flow-node.is-unreachable { border-color: var(--bs-danger); border-style: dashed; }
.sb-flow-head { display: flex; align-items: flex-start; gap: .6rem; }
.sb-flow-text { color: var(--muted); margin-top: .15rem; }
.sb-flow-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .6rem; margin: .45rem 0 0 2.2rem; font-size: .85rem; }
.sb-flow-label { flex: 0 0 6.5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; color: var(--muted); }
.sb-flow-items { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1 1 18rem; min-width: 0; }
.sb-flow-cond { padding: .15rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.sb-flow-or { align-self: center; font-size: .7rem; color: var(--muted); text-transform: uppercase; }
.sb-flow-q { border: 0; background: none; padding: 0; font-weight: 600; color: var(--accent); }
.sb-flow-q:hover { text-decoration: underline; }
.sb-flow-stop { margin: .4rem 0 0 2.2rem; font-size: .85rem; color: var(--bs-danger); }
.sb-flow-end { margin: .4rem 0 0 2.2rem; font-size: .85rem; color: var(--kpi-good, #1f9d3a); }
.sb-flow-why { color: var(--muted); }
@media (max-width: 575.98px) {
    .sb-flow-line, .sb-flow-stop, .sb-flow-end { margin-left: 0; }
    .sb-flow-label { flex-basis: 100%; }
    .sb-flow-head { flex-wrap: wrap; }
}

/* AI Survey Builder - follow-up rules pop-up (openBuilderRulesModal) and AI notes pop-up */
.sb-rq-head { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius); background: var(--surface); }
.sb-rule-row { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .7rem; margin-bottom: .4rem; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--bs-border-radius-sm); background: var(--surface); }
.sb-rule-row.is-terminate { border-left-color: var(--bs-danger); }
.sb-rule-row.is-piping { border-left-color: #2563eb; }
.sb-flow-pipe-rule { align-self: center; font-size: .8rem; color: var(--muted); }
.sb-rule-if { font-weight: 500; }
.sb-rule-target { font-weight: 600; color: var(--accent); }
.sb-rule-builder { padding: .75rem; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--bs-border-radius); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.sb-rule-step { display: flex; gap: .6rem; margin-bottom: .75rem; }
.sb-rule-step-no { flex-shrink: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.sb-answer-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.sb-answer-chip { border-radius: 999px; }
.sb-rule-children { max-height: 16rem; overflow-y: auto; background: var(--surface); }
.sb-rule-child { display: flex; align-items: flex-start; gap: .5rem; padding: .4rem .6rem; margin: 0; cursor: pointer; border-bottom: 1px solid var(--border); }
.sb-rule-child:last-child { border-bottom: 0; }
.sb-rule-child:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.sb-rule-child.is-used { opacity: .6; cursor: default; }
.sb-rule-child .form-check-input { margin-top: .2rem; flex-shrink: 0; }
.qb-number.qb-number-sm { min-width: 1.3rem; height: 1.3rem; font-size: .68rem; }
.sb-ai-notes { padding-left: 1.2rem; margin-bottom: .5rem; }
.sb-ai-notes li { margin-bottom: .35rem; }

/* Survey Builder - "Lists & questions": reference lists (left) linked to the questions that use
   them (right). --c is the list's colour, --g the grid/random group's. Lines are an SVG drawn in
   the gap column (survey-builder.js drawLinks); in a narrow layout the colour chips carry the link. */
.sb-dot { flex-shrink: 0; width: .7rem; height: .7rem; border-radius: 50%; background: var(--c, var(--muted)); }
.sb-map { margin-bottom: 1rem; }
.sb-map-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; min-height: 2.2rem; margin-bottom: .5rem; }
.sb-map-selection { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .25rem .5rem; border-radius: var(--bs-border-radius); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sb-map-cols { position: relative; display: grid; grid-template-columns: minmax(0, 5fr) 3.5rem minmax(0, 7fr); grid-template-areas: "hl . hq" "lists links questions"; align-items: start; row-gap: .4rem; }
.sb-map-head { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sb-map-head-lists { grid-area: hl; }
.sb-map-head-questions { grid-area: hq; }
.sb-map-lists { grid-area: lists; position: sticky; top: .75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; padding: 2px; }
.sb-map-questions { grid-area: questions; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.sb-map-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 1; }
.sb-map-links path { fill: none; stroke: var(--c); stroke-width: 1.5; opacity: .32; transition: opacity .15s, stroke-width .15s; }
.sb-map-links circle { fill: var(--c); opacity: .5; }
.sb-map-links .is-hot, .sb-map-links .is-hover { opacity: 1; stroke-width: 2.75; }
.sb-map-links .is-faint { opacity: .06; }
.sb-map-cols.is-narrow { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hl" "lists" "hq" "questions"; }
.sb-map-cols.is-narrow .sb-map-lists { position: static; max-height: none; }
.sb-map-cols.is-narrow .sb-map-links { display: none; }

.sb-map-list { border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: var(--bs-border-radius-sm); background: var(--surface); padding: .45rem .6rem; cursor: pointer; transition: opacity .15s, box-shadow .15s; }
.sb-map-list:hover, .sb-map-list:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); outline: none; }
.sb-map-list.is-focus { box-shadow: 0 0 0 2px var(--c); }
.sb-map-list-head { display: flex; gap: .4rem; align-items: center; min-width: 0; }
.sb-map-list-head strong { overflow-wrap: anywhere; }
.sb-map-items { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.sb-map-pill { font-size: .75rem; padding: .05rem .45rem; border-radius: 1rem; border: 1px solid var(--border); background: color-mix(in srgb, var(--c) 8%, transparent); }
.sb-map-more { font-size: .75rem; padding: 0 .3rem; }
.sb-map-items.is-detail { flex-direction: column; flex-wrap: nowrap; gap: .1rem; cursor: default; }
.sb-map-item { display: flex; align-items: center; gap: .4rem; font-size: .82rem; padding: .1rem .25rem; border-radius: var(--bs-border-radius-sm); }
.sb-map-item:hover { background: color-mix(in srgb, var(--c) 8%, transparent); }
.sb-map-item.is-off .sb-map-item-name { text-decoration: line-through; color: var(--muted); }
.sb-map-item .btn { padding: 0 .3rem; line-height: 1.3; font-size: .78rem; color: var(--muted); border-color: transparent; }
.sb-map-item .btn.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.sb-map-detail-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; font-size: .78rem; color: var(--muted); margin: .4rem 0 .15rem; }

.sb-map-q { display: flex; gap: .5rem; align-items: flex-start; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface); cursor: pointer; transition: opacity .15s, box-shadow .15s; }
.sb-map-q:hover, .sb-map-q:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, var(--accent)) 40%, transparent); outline: none; }
.sb-map-q.is-focus { box-shadow: 0 0 0 2px var(--c, var(--accent)); }
.sb-map-q.is-selected { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.sb-map-q.in-group { margin-left: .9rem; border-left: 3px solid var(--g); }
.sb-map-q .form-check-input { margin-top: .3rem; flex-shrink: 0; }
.sb-map-q-text { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-map-cond { font-size: .76rem; color: var(--muted); }
.sb-map-q-list { flex: 0 0 11.5rem; display: flex; gap: .3rem; align-items: center; }
.sb-map-q-list .form-select { border-left: 4px solid var(--c, var(--border)); }
.sb-map-q-list .sb-map-nolist { font-size: .76rem; color: var(--muted); }
@media (max-width: 575.98px) { .sb-map-q { flex-wrap: wrap; } .sb-map-q-list { flex-basis: 100%; } }
.sb-map-cols.has-focus .sb-map-list:not(.is-focus):not(.is-related),
.sb-map-cols.has-focus .sb-map-q:not(.is-focus):not(.is-related) { opacity: .4; }
.sb-map-group { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .35rem 0 0; font-size: .8rem; color: var(--g); font-weight: 600; }
.sb-map-group .sb-map-why { font-weight: 400; color: var(--muted); }
.sb-badge-grid, .sb-badge-random { font-weight: 500; border: 1px solid var(--g); color: var(--g); background: color-mix(in srgb, var(--g) 10%, transparent); }

.sb-structure-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .4rem 0; border-top: 1px solid var(--border); }
.sb-structure-row:first-child { border-top: 0; }
.sb-structure-row > i { color: var(--g, var(--accent)); }
.sb-structure-row .form-control { width: auto; min-width: 10rem; flex: 0 1 18rem; }
.sb-structure-members { display: flex; flex-wrap: wrap; gap: .25rem; }
.sb-structure-why { flex-basis: 100%; font-size: .78rem; color: var(--muted); }
.sb-structure-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: .5rem; }

/* AI Survey Builder - the AI optimized document step: a plain-text editor with line numbers. */
.sb-optimized-tip { color: var(--muted); }
.sb-doc-summary { color: var(--muted); }
.sb-doc-editor { display: flex; height: min(70vh, 44rem); border: 1px solid var(--border); border-radius: var(--bs-border-radius); background: var(--surface); overflow: hidden; }
.sb-doc-gutter, .sb-doc-text { font-family: var(--bs-font-monospace); font-size: .8rem; line-height: 1.5; margin: 0; padding: .6rem .5rem; }
/* The extra bottom padding matches the editor's horizontal scrollbar, so the numbers stay level. */
.sb-doc-gutter { flex: 0 0 auto; min-width: 3.2rem; padding-bottom: 1.6rem; text-align: right; color: var(--muted); background: var(--surface-alt); border-right: 1px solid var(--border); overflow: hidden; user-select: none; white-space: pre; }
.sb-doc-text { flex: 1 1 auto; min-width: 0; border: 0; resize: none; background: transparent; color: var(--ink); white-space: pre; overflow: auto; tab-size: 4; }
.sb-doc-text:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.sb-doc-guide { white-space: pre-wrap; max-height: 24rem; overflow: auto; padding: .75rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface-alt); color: var(--ink); }
.sb-doc-notes summary { cursor: pointer; }
@media (max-width: 575.98px) { .sb-doc-editor { height: 60vh; } .sb-doc-gutter { min-width: 2.4rem; } .sb-doc-gutter, .sb-doc-text { font-size: .75rem; } }

/* Points: scored questions, points rules, option points. */
.sb-badge-points { font-weight: 500; border: 1px solid #2f8f5b; color: #2f8f5b; background: color-mix(in srgb, #2f8f5b 10%, transparent); }
.sb-badge-piped { font-weight: 500; border: 1px solid #2563eb; color: #2563eb; background: color-mix(in srgb, #2563eb 10%, transparent); }
.sb-map-pts { font-size: .68rem; font-weight: 600; color: #2f8f5b; }
.qb-points .form-text { font-size: .75rem; }

/* Tenant Management > Details (tenants.js openDetailsModal). */
.tenant-stat {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border, #dee2e6);
    border-radius: 10px;
    height: 100%;
}
.tenant-stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tenant-stat-label { font-size: 0.8rem; opacity: 0.75; }

/* Survey detail: a question deactivated for the survey (kept for its answers) - greyed, its Reactivate button stays clear. */
.mapped-question-inactive > td:not(.table-actions) { opacity: 0.55; }


/* ---- Open-end coding (open-end-coding.html) ---- */
.oec-tree { max-height: 70vh; overflow-y: auto; }
.oec-tree-project { padding: 0.25rem 0.25rem; font-weight: 600; font-size: 0.9rem; }
.oec-tree-question { font-size: 0.85rem; padding: 0.2rem 0.4rem; border-radius: 6px; }
.oec-tree-question:hover { background: var(--surface-alt); }
.oec-tree-question.active { background: var(--accent); color: var(--accent-ink); }
.oec-answer { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 48ch; }
.oec-code-chip { background: var(--surface-alt); color: var(--ink); border: 1px solid rgba(127, 127, 127, 0.35); font-weight: 500; white-space: normal; text-align: left; }
.oec-code-pick { max-height: 45vh; overflow-y: auto; }
.oec-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0.75rem; }
.oec-code-num { min-width: 3rem; font-weight: 700; }
.oec-values { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.oec-value-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.8rem;
    background: var(--surface-alt); border: 1px solid rgba(127, 127, 127, 0.3); cursor: pointer; user-select: none; max-width: 100%; overflow-wrap: anywhere; }
.oec-value-chip.verbatim { font-style: italic; }
.oec-value-chip.selected { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.oec-value-remove { border: 0; background: transparent; color: inherit; opacity: 0.6; padding: 0 0.1rem; line-height: 1; font-size: 1rem; }
.oec-value-remove:hover { opacity: 1; }
.oec-value-add { width: 10rem; height: 1.6rem; font-size: 0.8rem; }
@media (max-width: 640px) {
    .oec-codes { grid-template-columns: 1fr; }
    .oec-answer { max-width: none; }
}

/* ── Report-style KPI widgets (js/kpi-report-view.js) - drawn like the AMEX Mystery Shopper report pages ── */
:root {
    --rv-title: #1f4e79; --rv-head: #843c0c; --rv-label: #1f4e79; --rv-grey: #f2f2f2; --rv-grey2: #d9d9d9; --rv-ink: #262626;
    --rv-green: #c6e0b4; --rv-green-ink: #375623; --rv-amber: #ffe699; --rv-amber-ink: #7f6000; --rv-red: #f8cbad; --rv-red-ink: #843c0c;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --rv-title: #9cc0ff; --rv-head: #f0b48a; --rv-label: #a9c4ec; --rv-grey: #262f3d; --rv-grey2: #36404f; --rv-ink: #e6eaf0;
        --rv-green: #2d4a2a; --rv-green-ink: #b7e3a3; --rv-amber: #4a3f17; --rv-amber-ink: #f5d77a; --rv-red: #4d2a22; --rv-red-ink: #ffb79a; }
}
:root[data-theme="dark"] { --rv-title: #9cc0ff; --rv-head: #f0b48a; --rv-label: #a9c4ec; --rv-grey: #262f3d; --rv-grey2: #36404f; --rv-ink: #e6eaf0;
    --rv-green: #2d4a2a; --rv-green-ink: #b7e3a3; --rv-amber: #4a3f17; --rv-amber-ink: #f5d77a; --rv-red: #4d2a22; --rv-red-ink: #ffb79a; }

.rv { color: var(--rv-ink); font-size: 12.5px; }
.rv .cc-g, .rv-legend .cc-g { background: var(--rv-green); color: var(--rv-green-ink); }
.rv .cc-a, .rv-legend .cc-a { background: var(--rv-amber); color: var(--rv-amber-ink); }
.rv .cc-r, .rv-legend .cc-r { background: var(--rv-red); color: var(--rv-red-ink); }
.rv .cc-n, .rv-legend .cc-n { background: var(--rv-grey); color: var(--muted, #888); }
.rv .rv-g { color: var(--rv-green-ink); } .rv .rv-a { color: var(--rv-amber-ink); } .rv .rv-r { color: var(--rv-red-ink); }
.rv-title { text-align: center; font-weight: 700; font-size: 14px; text-transform: uppercase; margin-bottom: 10px; }
.rv-title .rv-yes { color: #00a650; }
.rv-sub { font-weight: 700; color: var(--rv-title); margin-bottom: 8px; }
.rv-na { color: var(--muted, #888); }
.rv-avg { border-collapse: collapse; font-size: 11.5px; margin: 0 0 12px; }
.rv-avg th, .rv-avg td { border: 2px solid transparent; padding: 3px 12px; text-align: center; }
.rv-avg th { background: var(--rv-grey); font-weight: 600; }
.rv-avg th.cap { font-weight: 700; }
.rv-yt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.rv-yt th { padding: 4px 4px 8px; text-align: center; }
.rv-yt th span { display: block; background: var(--rv-grey); padding: 4px 0; font-weight: 700; }
.rv-yt td { padding: 3px 4px; vertical-align: middle; }
.rv-yt td.lab { text-align: right; color: var(--rv-label); width: 42%; padding-right: 12px; line-height: 1.25; }
.rv-yt tr.hdr td { background: var(--rv-grey); text-align: right; color: var(--rv-label); font-size: 11px; letter-spacing: .03em; padding: 6px 12px; }
.rv .ycell { display: flex; align-items: center; gap: 5px; min-width: 62px; }
.rv .ybar { height: 16px; border-radius: 2px; flex: 0 0 auto; }
.rv .yval { font-size: 11.5px; white-space: nowrap; }
.rv .rt-wrap { display: flex; gap: 18px; align-items: flex-start; }
.rv .rt-legend { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; padding-top: 60px; min-width: 100px; }
.rv .rt-legend i { display: inline-block; width: 14px; height: 14px; vertical-align: middle; margin-right: 6px; }
.rv .rt-groups { display: flex; gap: 22px; overflow-x: auto; padding-bottom: 4px; }
.rv .rt-group .gl { text-align: center; font-weight: 700; color: var(--rv-label); background: var(--rv-grey); padding: 5px 8px; margin-bottom: 6px; }
.rv .rt-cols { display: flex; gap: 3px; }
.rv .rt-col { width: 48px; display: flex; flex-direction: column; }
.rv .rt-yr { font-size: 10.5px; font-weight: 700; color: var(--rv-label); text-align: center; background: var(--rv-grey); padding: 2px 0; }
.rv .rt-t2b { font-size: 12px; font-weight: 700; text-align: center; padding: 3px 0; margin: 2px 0; }
.rv .rt-pos, .rv .rt-neg { height: 110px; display: flex; flex-direction: column; }
.rv .rt-pos { justify-content: flex-end; border-bottom: 1px solid #a6a6a6; }
.rv .rt-neg { justify-content: flex-start; }
.rv .rt-seg { display: flex; align-items: center; justify-content: center; font-size: 10.5px; color: #262626; overflow: hidden; }
.rv-tile { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 14px; align-items: center; }
.rv-tile-yrs { display: grid; gap: 6px; text-align: center; }
.rv-tile-yrs .y { font-size: 15px; color: var(--rv-title); font-weight: 700; background: var(--rv-grey); padding: 3px 0; }
.rv-tile-yrs .n b { display: block; font-size: 34px; line-height: 1.05; color: var(--rv-title); }
.rv-tile-yrs .n small { display: block; font-size: 13px; color: var(--rv-title); font-weight: 700; }
.rv-tile-lab { color: var(--rv-title); font-weight: 700; font-size: 13px; text-align: center; line-height: 1.35; }
.rv-yc { display: flex; gap: 16px; align-items: flex-end; height: 170px; border-bottom: 1px solid #a6a6a6; padding: 0 6px; overflow-x: auto; }
.rv-yc-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 46px; }
.rv-yc-col .b { width: 26px; border-radius: 2px 2px 0 0; }
.rv-yc-col .v { font-size: 11.5px; margin-bottom: 3px; }
.rv-yc-yrs { display: flex; gap: 16px; padding: 4px 6px 0; font-size: 11.5px; }
.rv-yc-yrs span { min-width: 46px; text-align: center; }
.rv-ds { display: flex; gap: 22px; align-items: flex-end; overflow-x: auto; padding: 18px 2px 4px; }
.rv-ds-cat { flex: 0 0 auto; text-align: center; }
.rv-ds-bars { display: flex; gap: 2px; align-items: flex-end; height: 150px; border-bottom: 1px solid #a6a6a6; padding: 0 4px; }
.rv-ds-bar { width: 22px; position: relative; border-radius: 2px 2px 0 0; }
.rv-ds-bar.rv-ds-none { height: 1px; }
.rv-ds-bar b { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 9.5px; font-weight: 400; white-space: nowrap; }
.rv-ds-lab { font-size: 11.5px; margin-top: 5px; max-width: 200px; }
.rv-ds-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; margin-top: 8px; justify-content: center; }
.rv-ds-legend i { display: inline-block; width: 11px; height: 11px; margin-right: 4px; vertical-align: middle; }
.rv-st, .rv-ss { border-collapse: collapse; width: 100%; font-size: 13px; }
.rv-st th, .rv-st td, .rv-ss th, .rv-ss td { border: 1px solid var(--rv-grey2); padding: 8px 10px; vertical-align: middle; }
.rv-st thead tr:first-child th, .rv-ss thead th { background: #d6dce4; color: #262626; font-size: 12px; text-transform: uppercase; }
.rv-st .grp td { background: var(--rv-grey); }
.rv-st .grp td:first-child { color: #c00000; font-weight: 700; }
.rv-st td.lab { color: var(--rv-label); font-weight: 700; width: 30%; }
.rv-st td.v { text-align: center; }
.rv-meas { font-weight: 400; font-size: 11.5px; color: var(--muted, #777); }
.rv-ss th, .rv-ss td { text-align: center; padding: 6px 8px; font-size: 12.5px; }
.rv-ss td.l { text-align: left; color: var(--rv-label); }
.rv-ss tr.sec td { background: var(--rv-grey); text-align: left; font-weight: 700; color: var(--rv-label); }
.rv-ss tr.tot td { font-weight: 700; }
.kpi-page-head .rv-crumb { font-size: 11px; color: var(--muted, #888); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.kpi-page-head .rv-h2 { margin: 0 0 8px; color: var(--rv-title); font-size: 22px; font-weight: 700; text-transform: uppercase; }
.kpi-page-head .rv-headline { color: var(--rv-head); font-weight: 700; font-size: 15px; line-height: 1.35; margin: 0 0 8px; }
.rv-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; }
.rv-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: middle; border-radius: 2px; }
.kpi-page-foot { margin-top: 12px; font-size: 11.5px; }
.kpi-page-foot .rv-note { color: #1f4fa8; }
.kpi-page-foot .rv-base { color: var(--muted, #888); border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.kpi-page-nav { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.kpi-page-nav .pn-sec { padding: 8px 14px; font-weight: 700; font-size: 12.5px; background: var(--surface-alt); }
.kpi-page-nav .pn-sub { padding: 6px 14px 2px; font-size: 10.5px; color: var(--muted, #888); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.kpi-page-nav a { display: block; padding: 5px 14px 5px 22px; color: var(--ink); font-size: 13px; text-decoration: none; border-left: 3px solid transparent; }
.kpi-page-nav a:hover { background: var(--surface-alt); }
.kpi-page-nav a.on { border-left-color: var(--accent); font-weight: 700; background: var(--surface-alt); }
@media (max-width: 991.98px) { .rv-tile { grid-template-columns: 1fr; } .rv-yt td.lab { width: auto; min-width: 180px; } }
/* the main column beside the page list may shrink - wide report widgets (rating grids) then scroll inside their card */
#pageMainCol { min-width: 0; }
.rv .rt-wrap, .rv .rt-groups { min-width: 0; }
.rv .rt-groups { flex: 1 1 auto; }
.rv-tile-yrs .n b { white-space: nowrap; }
.rv-tile-yrs .n b.rv-g, .rv-tile-yrs .n b.rv-a, .rv-tile-yrs .n b.rv-r { font-size: 28px; }

/* ---- AI token limits (ai-token-limits.js): the editor and each limit's state ---- */
.ai-limits-editor { display: grid; gap: .5rem; }
.ai-limit-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 13rem); gap: .5rem 1rem; align-items: center; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--bs-border-radius-sm); background: var(--surface); }
.ai-limit-label { font-weight: 600; font-size: .9rem; margin-bottom: 0; }
.ai-limit-hours { width: 4.5rem; padding-top: .1rem; padding-bottom: .1rem; }
.ai-windows { display: grid; gap: .45rem; }
.ai-windows.is-compact { gap: .3rem; min-width: 12rem; }
.ai-window > .d-flex > span { white-space: nowrap; }
.ai-window .progress { background: color-mix(in srgb, var(--muted, #888) 18%, transparent); }
.ai-window.is-reached .fw-semibold { color: var(--bs-danger); }
@media (max-width: 575.98px) {
    .ai-limit-row { grid-template-columns: 1fr; }
}

/* busy-buttons.js: a button whose request is still running - can't be clicked, with a spinner in place of its icon */
.is-busy { pointer-events: none; opacity: .8; }
.busy-spinner { --bs-spinner-width: 1em; --bs-spinner-height: 1em; --bs-spinner-border-width: .15em; flex: 0 0 auto; }
.is-busy .busy-hidden { display: none !important; }

/* ── Dark mode: Bootstrap's light-only utilities ──
   The dark theme turns --bs-light (so .bg-light) dark, but .text-dark, .text-bg-light, .bg-white and
   .table-light keep their light-theme colours - dark text on a dark badge (the Audit Log's "Viewed"),
   a white table heading. Here they follow the theme; backgrounds that stay bright (warning, info)
   keep dark text. Both the OS preference and the explicit toggle, like the tokens at the top. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .text-dark { color: var(--bs-body-color) !important; }
    :root:not([data-theme="light"]) .text-bg-light { color: var(--bs-body-color) !important; background-color: var(--bs-tertiary-bg) !important; }
    :root:not([data-theme="light"]) .kpi-page-foot .rv-note { color: #9cc0ff; }
    :root:not([data-theme="light"]) .bg-white { background-color: var(--surface-menu) !important; }
    :root:not([data-theme="light"]) .table-light { --bs-table-bg: var(--bs-tertiary-bg); --bs-table-color: var(--bs-body-color); --bs-table-border-color: var(--bs-border-color); --bs-table-striped-bg: var(--bs-tertiary-bg); --bs-table-hover-bg: var(--bs-tertiary-bg); color: var(--bs-body-color); }
    :root:not([data-theme="light"]) .bg-warning.text-dark, :root:not([data-theme="light"]) .bg-warning .text-dark, :root:not([data-theme="light"]) .bg-info.text-dark, :root:not([data-theme="light"]) .bg-info .text-dark, :root:not([data-theme="light"]) .text-bg-warning, :root:not([data-theme="light"]) .text-bg-info, :root:not([data-theme="light"]) [class*="-subtle"].text-dark { color: #1B1F23 !important; }
}
:root[data-theme="dark"] .text-dark { color: var(--bs-body-color) !important; }
:root[data-theme="dark"] .text-bg-light { color: var(--bs-body-color) !important; background-color: var(--bs-tertiary-bg) !important; }
:root[data-theme="dark"] .kpi-page-foot .rv-note { color: #9cc0ff; }
:root[data-theme="dark"] .bg-white { background-color: var(--surface-menu) !important; }
:root[data-theme="dark"] .table-light { --bs-table-bg: var(--bs-tertiary-bg); --bs-table-color: var(--bs-body-color); --bs-table-border-color: var(--bs-border-color); --bs-table-striped-bg: var(--bs-tertiary-bg); --bs-table-hover-bg: var(--bs-tertiary-bg); color: var(--bs-body-color); }
:root[data-theme="dark"] .bg-warning.text-dark, :root[data-theme="dark"] .bg-warning .text-dark, :root[data-theme="dark"] .bg-info.text-dark, :root[data-theme="dark"] .bg-info .text-dark, :root[data-theme="dark"] .text-bg-warning, :root[data-theme="dark"] .text-bg-info, :root[data-theme="dark"] [class*="-subtle"].text-dark { color: #1B1F23 !important; }
