/* ==========================================================================
   QBM SHARED DESIGN SYSTEM  (qbm-theme.css)
   --------------------------------------------------------------------------
   ONE stylesheet, shared by every QBM app (QSales, QSalesView, QClock, QDine…)
   because it ships from the BAComponents Razor Class Library and is served at
   _content/BAComponents/css/qbm-theme.css.

   It mirrors QCRM's design language token-for-token so the whole product line
   reads as one system:
     • the SAME color tokens, type scale, spacing scale, radii, shadows and
       focus ring as QCRM (src/Web/wwwroot/css/site.css),
     • a dark-first palette (:root) with a light override ([data-theme="light"]),
     • the SAME button/action/alert/form/badge classes so a "Save" or "Delete"
       button looks identical in every app.

   Theme selection is driven by <html data-theme="dark|light">, applied before
   paint by qbm-theme.js. Load this file BEFORE each app's own app.css so the
   app can reference the canonical tokens (and map its legacy --qs-* names to
   them). Authored phone-first.
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Mobile-first foundations: neutralize the two most common causes of phone
   horizontal scroll — media that won't shrink and long unbroken strings. */
img,
video,
canvas {
    max-width: 100%;
    height: auto;
}

:where(p, h1, h2, h3, h4, dd, dt, td, th, .detail-value, .card-surface) {
    overflow-wrap: break-word;
}

/* Screen-reader-only utility (kept global so shared labels never render huge). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Keyboard users can bypass repeated shell navigation and move directly to page content. */
.qbm-skip-link {
    position: fixed;
    inset-block-start: var(--space-2, 0.5rem);
    inset-inline-start: var(--space-2, 0.5rem);
    z-index: 10000;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    color: var(--accent-contrast, #fff);
    background: var(--accent, #4f46e5);
    border-radius: var(--radius-md, 0.5rem);
    transform: translateY(-180%);
    transition: transform 0.15s ease;
}

.qbm-skip-link:focus {
    transform: translateY(0);
}

/* ==========================================================================
   1. TOKENS — DARK (default)
   Values are copied from QCRM so both products share one palette.
   ========================================================================== */
:root {
    /* Surfaces */
    --surface: #0f172a;                     /* page background */
    --surface-alt: #111c2f;                 /* card / panel background */
    --surface-card: rgba(15, 23, 42, 0.7);
    --surface-panel: rgba(17, 28, 47, 0.85);
    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5f5;
    --text-heading: #ffffff;
    /* Accents & status colors */
    --accent: #60a5fa;
    --accent-strong: #3b82f6;
    --accent-contrast: #ffffff;
    --warning: #f97316;
    --success: #34d399;
    --info: #38bdf8;
    --danger: #ef4444;
    --danger-strong: #dc2626;

    /* Layout & styling */
    --border: rgba(255, 255, 255, 0.08);
    --btn-radius: 12px;
    --font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

    /* Spacing scale — one compact, mobile-first rhythm. */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    /* Type scale — restrained for professional, information-dense screens.
       Pick a step; never invent a literal size. */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 0.95rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;

    /* Line-height steps. */
    --leading-tight: 1.2;
    --leading-snug: 1.35;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;

    /* Radius scale: sm = chips/inputs-in-rows, md = buttons/fields, lg = cards. */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Elevation. */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.18);
    --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.22);
    --shadow-base: 0 10px 30px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.35);

    /* Universal focus ring — one visible keyboard-focus treatment everywhere. */
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
    --field-focus-ring: color-mix(in srgb, var(--accent) 28%, transparent);

    /* Semantic aliases keep component CSS independent of theme implementation. */
    --text: var(--text-primary);
    --text-muted: var(--text-secondary);
    --surface-2: var(--surface-alt);
    --surface-subtle: color-mix(in srgb, var(--surface-alt) 86%, var(--surface));
    --border-strong: color-mix(in srgb, var(--text-secondary) 34%, var(--border));

    /* Badges. */
    --badge-active-bg: rgba(52, 211, 153, 0.15);
    --badge-active-text: #34d399;
    --badge-inactive-bg: rgba(148, 163, 184, 0.15);
    --badge-inactive-text: #cbd5e1;

    /* Alerts — dark defaults. */
    --alert-error-bg: linear-gradient(180deg, rgba(239, 68, 68, .12), rgba(239, 68, 68, .06));
    --alert-error-border: rgba(239, 68, 68, .45);
    --alert-error-text: #ffe5e6;
    --alert-success-bg: linear-gradient(180deg, rgba(52, 211, 153, .12), rgba(52, 211, 153, .06));
    --alert-success-border: rgba(52, 211, 153, .45);
    --alert-success-text: #d1fae5;
    --alert-warning-bg: linear-gradient(180deg, rgba(251, 146, 60, .12), rgba(251, 146, 60, .06));
    --alert-warning-border: rgba(251, 146, 60, .45);
    --alert-warning-text: #fed7aa;
    --alert-info-bg: linear-gradient(180deg, rgba(56, 189, 248, .12), rgba(56, 189, 248, .06));
    --alert-info-border: rgba(56, 189, 248, .45);
    --alert-info-text: #e0f2fe;

    /* Form tokens. */
    --field-radius: 12px;
    --field-pad: 10px 12px;
    --field-height: 42px;
    --ring-size: 4px;

    /* Theme-aware helper tokens for tables/panels. */
    --muted-bg: color-mix(in srgb, var(--surface-alt) 82%, var(--surface));
    --muted-bg-2: color-mix(in srgb, var(--surface-alt) 92%, var(--surface));
    --table-header-bg: color-mix(in srgb, var(--surface-alt) 72%, var(--surface));
    --table-row-hover: color-mix(in srgb, var(--accent) 6%, var(--surface-alt));
    --table-border: color-mix(in srgb, var(--border) 88%, transparent);

    /* Action-button tokens (unified per-action colors, theme-aware). */
    --action-edit-color: var(--accent);
    --action-edit-strong: var(--accent-strong);
    --action-delete-color: #f87171;
    --action-delete-strong: var(--danger-strong);
    --action-view-color: var(--text-secondary);
    --action-view-strong: var(--text-primary);
    --action-view-bg-hover: color-mix(in srgb, var(--text-primary) 10%, transparent);
    --action-cancel-color: var(--text-secondary);
    --action-cancel-border: var(--border);
    --action-cancel-bg-hover: rgba(255, 255, 255, 0.06);
}

/* Dark theme mirrors the root set (exists so [data-theme="dark"] selectors work). */
[data-theme="dark"] {
    color-scheme: dark;
}

/* ==========================================================================
   2. TOKENS — LIGHT
   ========================================================================== */
[data-theme="light"] {
    color-scheme: light;
    /* Surfaces */
    --surface: #f1f5f9;
    --surface-alt: #ffffff;
    --surface-card: rgba(248, 250, 252, 0.9);
    --surface-panel: rgba(241, 245, 249, 0.95);
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-heading: #1e293b;
    /* Accents & status colors */
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --warning: #f97316;
    --success: #10b981;
    --info: #0ea5e9;
    --danger: #ef4444;
    --danger-strong: #dc2626;
    /* Layout & styling */
    --border: rgba(15, 23, 42, 0.12);
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-base: 0 5px 15px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 10px 25px rgba(15, 23, 42, 0.06);
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 12px 26px rgba(15, 23, 42, 0.12);
    /* Badges */
    --badge-active-bg: #dcfce7;
    --badge-active-text: #16a34a;
    --badge-inactive-bg: #e2e8f0;
    --badge-inactive-text: #475569;
    /* Alerts — light palette */
    --alert-error-bg: linear-gradient(180deg, #fff5f5, #fff8f8);
    --alert-error-border: var(--danger);
    --alert-error-text: #721c24;
    --alert-success-bg: linear-gradient(180deg, #f0fdf4, #dcfce7);
    --alert-success-border: var(--success);
    --alert-success-text: #14532d;
    --alert-warning-bg: linear-gradient(180deg, #fff7ed, #ffedd5);
    --alert-warning-border: var(--warning);
    --alert-warning-text: #7c2d12;
    --alert-info-bg: linear-gradient(180deg, #f0f9ff, #e0f2fe);
    --alert-info-border: var(--info);
    --alert-info-text: #0c4a6e;
    /* Action tokens — darker red so it is readable on white. */
    --action-delete-color: var(--danger-strong);
    --action-delete-strong: #b91c1c;
    --action-view-color: #475569;
    --action-view-strong: #0f172a;
    --action-view-bg-hover: rgba(15, 23, 42, 0.06);
    --action-cancel-color: #475569;
    --action-cancel-border: #cbd5e1;
    --action-cancel-bg-hover: rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   3. LEGACY --qs-* BRIDGE
   QSales' 3,800-line stylesheet is authored against --qs-* names. Aliasing
   them to the canonical tokens above makes every QSales screen theme-reactive
   with zero page rewrites. Harmless for apps that don't use --qs-* (unused
   custom properties cost nothing). Kept in the shared sheet so any QBM app
   authored against --qs-* upgrades automatically.
   ========================================================================== */
:root {
    --qs-bg: var(--surface);
    --qs-surface: var(--surface-alt);
    --qs-surface-soft: var(--surface-subtle);
    --qs-surface-muted: var(--muted-bg);
    --qs-border: var(--border);
    --qs-border-strong: var(--border-strong);
    --qs-text: var(--text-primary);
    --qs-heading: var(--text-heading);
    --qs-muted: var(--text-secondary);
    --qs-primary: var(--accent);
    --qs-primary-strong: var(--accent-strong);
    --qs-primary-soft: color-mix(in srgb, var(--accent) 14%, transparent);
    --qs-ring: var(--field-focus-ring);
    --qs-green: var(--success);
    --qs-green-soft: var(--badge-active-bg);
    --qs-green-text: var(--badge-active-text);
    --qs-amber: var(--warning);
    --qs-amber-soft: color-mix(in srgb, var(--warning) 16%, transparent);
    --qs-amber-text: var(--alert-warning-text);
    --qs-red: var(--danger);
    --qs-red-strong: var(--danger-strong);
    --qs-red-soft: color-mix(in srgb, var(--danger) 15%, transparent);
    --qs-red-text: var(--alert-error-text);
    --qs-info: var(--info);
    --qs-shadow-sm: var(--shadow-sm);
    --qs-shadow-card: var(--shadow-card);
    --qs-shadow-lg: var(--shadow-lg);
    --qs-radius: var(--radius-lg);
    --qs-radius-md: var(--radius-md);
    --qs-radius-sm: var(--radius-sm);
    --qs-field-radius: var(--field-radius);
    --qs-field-height: 44px;
    --qs-table-header-bg: var(--table-header-bg);
    --qs-table-row-hover: var(--table-row-hover);
    --qs-font: var(--font-family);
}

/* In light mode the amber/red "text" tokens read better as the solid hue than
   the softened alert text (which is tuned for filled alert panels). */
[data-theme="light"] {
    --qs-amber-text: #9a3412;
    --qs-red-text: #991b1b;
    --qs-green-text: #166534;
}

/* ==========================================================================
   4. BASE ELEMENTS
   ========================================================================== */
body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--surface);
    color: var(--text-primary);
    min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Universal keyboard-focus treatment. :where() keeps specificity at zero so a
   component that styles its own :focus-visible still wins — this is the floor. */
:where(a, button, [role="button"], [role="link"], input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Heading floor: unstyled headings inherit the shared scale, not browser defaults. */
:where(h1) { font-size: var(--font-size-3xl); line-height: var(--leading-tight); }
:where(h2) { font-size: var(--font-size-2xl); line-height: var(--leading-tight); }
:where(h3) { font-size: var(--font-size-xl); line-height: var(--leading-snug); }
:where(h4) { font-size: var(--font-size-lg); line-height: var(--leading-snug); }

/* ==========================================================================
   5. BUTTONS — the shared button language (same classes as QCRM)
   ========================================================================== */

/* Shared normalization: legacy, Telerik, and page-local buttons stay aligned. */
:where(.btn-primary, .btn-primary-modern, .qcrm-primary-button, .primary-action) {
    min-height: 44px;
    border-radius: var(--btn-radius);
    font-weight: 700;
}

:where(.btn-secondary, .btn-secondary-modern, .secondary-action, .qcrm-secondary-button, .secondary) {
    min-height: 44px;
    border-radius: var(--btn-radius);
    font-weight: 700;
}

:where(.danger-action, .btn-danger, .danger) {
    min-height: 44px;
    border-radius: var(--btn-radius);
    font-weight: 700;
}

.btn-primary-modern,
.btn-secondary-modern {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .06s ease, box-shadow .2s ease, background .15s ease, border-color .15s ease, opacity .2s ease;
    user-select: none;
}

.btn-primary-modern {
    color: #fff;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
}

.btn-primary-modern:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary-modern:active {
    transform: translateY(0);
}

.btn-primary-modern:disabled,
.btn-primary-modern[disabled],
.btn-secondary-modern:disabled,
.btn-secondary-modern[disabled] {
    opacity: .6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary-modern {
    color: var(--text-primary);
    background: transparent;
    border-color: var(--border);
}

.btn-secondary-modern:hover:not(:disabled) {
    background: color-mix(in srgb, var(--text-primary) 6%, transparent);
    border-color: var(--border-strong);
}

/* Danger / destructive filled button. */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    color: #fff;
    background: linear-gradient(180deg, var(--danger), var(--danger-strong));
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform .06s ease, box-shadow .2s ease, filter .15s ease;
}

.btn-danger:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }

/* ── UNIFIED ACTION MODIFIERS (add to any button: .action-edit/-delete/-view/-save/-cancel) ── */
.action-edit,
button.action-edit {
    color: var(--action-edit-color) !important;
    border-color: color-mix(in srgb, var(--action-edit-color) 60%, var(--border)) !important;
    background: transparent;
}
.action-edit:hover,
button.action-edit:hover {
    color: #fff !important;
    background: var(--action-edit-color) !important;
    border-color: var(--action-edit-color) !important;
}

.action-delete,
button.action-delete {
    color: var(--action-delete-color) !important;
    border-color: color-mix(in srgb, var(--action-delete-color) 60%, var(--border)) !important;
    background: transparent;
}
.action-delete:hover,
button.action-delete:hover {
    color: #fff !important;
    background: var(--action-delete-color) !important;
    border-color: var(--action-delete-color) !important;
}
.btn-danger.action-delete {
    color: #fff !important;
    background: linear-gradient(180deg, var(--danger), var(--danger-strong)) !important;
    border-color: transparent !important;
}

.action-view,
button.action-view {
    color: var(--action-view-color) !important;
    border-color: var(--border) !important;
    background: transparent;
}
.action-view:hover,
button.action-view:hover {
    color: var(--action-view-strong) !important;
    background: var(--action-view-bg-hover) !important;
    border-color: var(--action-view-strong) !important;
}

.action-cancel,
button.action-cancel {
    color: var(--action-cancel-color) !important;
    border: 1px solid var(--action-cancel-border) !important;
    background: transparent;
}
.action-cancel:hover,
button.action-cancel:hover {
    background: var(--action-cancel-bg-hover) !important;
    color: var(--text-primary) !important;
}

/* ==========================================================================
   6. FORM UTILITIES (shared with QCRM's forms.css)
   ========================================================================== */
.qcrm-form { display: grid; gap: 16px; margin: 0; padding: 0; border: 0; background: transparent; }
.qcrm-form-row { display: grid; gap: 6px; }
.qcrm-form-label { display: block; margin: 0; font-weight: 600; color: var(--text-heading); }

.qcrm-text-input,
.qcrm-full-width-input { width: 100%; }
.qcrm-full-width-input { width: 100% !important; }

.qcrm-text-input {
    min-height: var(--field-height);
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    color: var(--text-primary);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
[data-theme="light"] .qcrm-text-input { background: #ffffff; border-color: #cbd5e1; }

.qcrm-text-input::placeholder { color: var(--text-secondary); opacity: 1; }
.qcrm-text-input:hover:not(:disabled):not(:focus) { border-color: var(--border-strong); }
.qcrm-text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 var(--ring-size) var(--field-focus-ring);
}
.qcrm-text-input:disabled { opacity: .6; cursor: not-allowed; }
/* Invalid input (native + Blazor .invalid / .input-validation-error). */
.qcrm-text-input.invalid,
.qcrm-text-input.input-validation-error,
.qcrm-text-input[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 var(--ring-size) color-mix(in srgb, var(--danger) 22%, transparent);
}

.qcrm-primary-button {
    min-height: 44px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, transform .05s ease;
}
.qcrm-primary-button:hover { background: var(--accent-strong); }
.qcrm-primary-button:active { transform: translateY(1px); }

.qcrm-form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.qcrm-form-actions-end { justify-content: flex-end; }

/* ==========================================================================
   7. VALIDATION VISIBILITY (empty messages never take space)
   ========================================================================== */
.validation-message,
.field-validation-error,
.k-form-error,
.k-validation-message { display: none; }

.validation-message:not(:empty),
.field-validation-error:not(:empty),
.k-form-error:not(:empty),
.k-validation-message:not(:empty) {
    display: block;
    font-size: 0.9rem;
    line-height: 1.35;
    margin-top: 6px;
    color: var(--danger) !important;
}

[data-theme="dark"] .validation-message:not(:empty),
[data-theme="dark"] .field-validation-error:not(:empty),
[data-theme="dark"] .k-form-error:not(:empty),
[data-theme="dark"] .k-validation-message:not(:empty) { color: #ff7b7b !important; }

.validation-message:empty,
.field-validation-error:empty,
.k-form-error:empty,
.k-validation-message:empty { display: none !important; }

/* ==========================================================================
   8. ALERTS  (.alert-modern + .error/.success/.warning/.info-modern)
   ========================================================================== */
.alert-modern {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 18px 0;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--text-primary) 3%, transparent);
    color: var(--text-primary);
    font-size: .95rem;
    line-height: 1.5;
}
.alert-modern .alert-icon { flex-shrink: 0; margin-top: 2px; line-height: 0; color: currentColor; }
.alert-modern .alert-icon svg { color: currentColor; fill: currentColor; stroke: currentColor; }
.alert-modern .alert-body { flex: 1; min-width: 0; }
.alert-modern .alert-title { margin: 0 0 2px; font-weight: 700; color: inherit; }
.alert-modern .alert-text { margin: 0; color: inherit; }
.alert-modern .alert-close { border: none; background: transparent; color: inherit; cursor: pointer; line-height: 0; padding: 2px; }
.alert-modern a { color: currentColor; text-decoration: underline; text-underline-offset: 2px; }
.alert-modern.compact { padding: 10px 12px; border-radius: 8px; font-size: .9rem; }

.alert-modern.error-modern { border-color: var(--alert-error-border); background: var(--alert-error-bg); color: var(--alert-error-text); }
.alert-modern.success-modern { border-color: var(--alert-success-border); background: var(--alert-success-bg); color: var(--alert-success-text); }
.alert-modern.warning-modern { border-color: var(--alert-warning-border); background: var(--alert-warning-bg); color: var(--alert-warning-text); }
.alert-modern.info-modern { border-color: var(--alert-info-border); background: var(--alert-info-bg); color: var(--alert-info-text); }
.alert-modern:focus-within { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-secondary) 25%, transparent); }

/* ==========================================================================
   9. BADGES
   ========================================================================== */
.badge,
.qbm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.badge-active { background: var(--badge-active-bg); color: var(--badge-active-text); }
.badge-inactive { background: var(--badge-inactive-bg); color: var(--badge-inactive-text); }

/* ==========================================================================
   10. LOADING & EMPTY STATES
   ========================================================================== */
/* One full-viewport startup treatment remains visually stable while the app
   moves from static boot markup through authorization and into login. */
.qbm-app-loading {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: var(--space-6);
    color: var(--text-primary);
    background:
        radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 34rem),
        var(--surface);
}

.qbm-app-loading-card {
    width: min(22rem, 100%);
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: var(--space-8);
    text-align: center;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.qbm-app-loading-mark {
    width: 3.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    color: var(--accent-contrast);
    background: linear-gradient(145deg, var(--accent), var(--accent-strong));
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 28%, transparent);
    font-size: var(--font-size-2xl);
    font-weight: 800;
    line-height: 1;
}

.qbm-app-loading-title {
    color: var(--text-heading);
    font-size: var(--font-size-xl);
    line-height: var(--leading-tight);
}

.qbm-app-loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: qbm-spin .8s linear infinite;
}

.qbm-app-loading-message {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--leading-normal);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 18px 48px;
    color: var(--text-secondary);
}
.empty-state {
    padding: 40px 18px 48px;
    text-align: center;
    color: var(--text-secondary);
}
.empty-state h3 { margin-bottom: 6px; color: var(--text-primary); }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; color: var(--accent); }
.empty-icon .k-svg-icon, .empty-icon svg { width: 2rem; height: 2rem; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: qbm-spin .8s linear infinite;
}
.loading-state .spinner {
    width: 24px;
    height: 24px;
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
    border-top-color: var(--accent);
}
@keyframes qbm-spin { to { transform: rotate(360deg); } }

/* Skeleton shimmer for large-data / loading rows. */
.qbm-skeleton {
    position: relative;
    overflow: hidden;
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
    border-radius: var(--radius-sm);
}
.qbm-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text-primary) 10%, transparent), transparent);
    animation: qbm-shimmer 1.4s infinite;
}

/* Panel skeletons reserve real dashboard/list space so initial loads do not blank or shift the page. */
.qbm-panel-skeleton {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.qbm-panel-skeleton-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--space-3);
}

.qbm-panel-skeleton-card { min-height: 5.5rem; }
.qbm-panel-skeleton-heading { display: block; width: min(18rem, 55%); height: 1.35rem; }
.qbm-panel-skeleton-line { display: block; width: 100%; height: 0.9rem; }
.qbm-panel-skeleton-line:nth-of-type(even) { width: 82%; }

/* One KPI card surface is shared by simple Home cards and richer manager cards. */
.qbm-kpi-card {
    min-height: 7.25rem;
    color: var(--text-primary);
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.qbm-kpi-card .card-header {
    color: var(--text-secondary) !important;
    background: transparent !important;
    border: 0;
}

.qbm-kpi-card .card-body {
    color: var(--text-primary);
    background: transparent;
}

.qbm-kpi-card.tone-blue { border-inline-start: 4px solid var(--accent); }
.qbm-kpi-card.tone-green { border-inline-start: 4px solid var(--success); }
.qbm-kpi-card.tone-red { border-inline-start: 4px solid var(--danger); }
.qbm-kpi-card.tone-amber { border-inline-start: 4px solid var(--warning); }
.qbm-kpi-card.tone-teal { border-inline-start: 4px solid var(--info); }
.qbm-kpi-card.tone-slate { border-inline-start: 4px solid var(--text-secondary); }
@keyframes qbm-shimmer { 100% { transform: translateX(100%); } }

/* ==========================================================================
   11. TELERIK / KENDO ALIGNMENT — unify radius, height and focus glow so the
   shared control library matches the token system in both themes.
   ========================================================================== */
:where(.k-input, .k-textbox, .k-textarea, .k-picker, .k-dropdownlist, .k-combobox) {
    border-radius: var(--field-radius) !important;
    min-height: var(--field-height);
}
.k-input:focus-within,
.k-picker:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--field-focus-ring);
}

/* ==========================================================================
   12. CONTENT TOP BAR  (mirrors QCRM's .top-row / .top-right)
   A sticky utility bar at the top of the main content area — to the RIGHT of
   the sidebar — where app-shell controls (theme toggle, language, account)
   live, right-aligned. Never place these in the left navigation.
   ========================================================================== */
.qbm-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    min-height: 52px;
    padding: 8px 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--surface-alt) 85%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.qbm-topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-inline-start: auto;
}
/* On phones the app already shows a nav top bar; keep this row in flow so the
   two never overlap at the viewport top. */
@media (max-width: 640px) {
    .qbm-topbar { position: static; backdrop-filter: none; }
}

/* ==========================================================================
   13. THEME TOGGLE  (styles for BAComponents/ThemeToggle.razor — global so it
   works regardless of scoped-CSS bundling order)
   ========================================================================== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface-alt) 70%, transparent);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease, transform .06s ease;
}
.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* Show the icon for the theme you'd switch TO: moon in light, sun in dark. */
.theme-toggle .theme-toggle-sun { display: none; }
.theme-toggle .theme-toggle-moon { display: block; }
[data-theme="dark"] .theme-toggle .theme-toggle-sun { display: block; }
[data-theme="dark"] .theme-toggle .theme-toggle-moon { display: none; }
