/* Telecom Voucher ? UI/UX Masterpiece + unified design tokens (formerly tokens.css, v2026.3)
 * Theme authority: html[data-theme="light"|"dark"] overrides :root for the same variable.
 * Tajawal is loaded from _Layout.cshtml (<link>) so @import does not block this file.
 * Arabic (html[lang="ar"]): Noto Sans Arabic is loaded from _Layout when UI culture is ar.
 */

/* ??? :root ? structural defaults, slate ramp, z-index, motion, legacy maps ??? */
:root {
    --tv-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --tv-transition-duration: 200ms;

    --tv-transition-fast: 150ms;
    --tv-transition-base: 250ms;
    --tv-transition-slow: 400ms;
    --tv-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --tv-ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --tv-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

    --duration-150: 150ms;
    --duration-200: 200ms;
    --duration-250: 250ms;
    --duration-300: 300ms;

    --tv-space-1: 0.25rem;
    --tv-space-2: 0.5rem;
    --tv-space-3: 0.75rem;
    --tv-space-4: 1rem;
    --tv-space-6: 1.5rem;
    --tv-space-8: 2rem;

    --sp-1: var(--tv-space-1);
    --sp-2: var(--tv-space-2);
    --sp-3: var(--tv-space-3);
    --sp-4: var(--tv-space-4);
    --sp-5: 1.25rem;
    --sp-6: var(--tv-space-6);
    --sp-8: var(--tv-space-8);

    --tv-fs-xs: 0.6875rem;
    --tv-fs-sm: 0.8125rem;
    --tv-fs-base: 0.9375rem;
    --tv-fs-lg: 1.0625rem;
    --tv-fs-xl: 1.25rem;
    --tv-fs-2xl: 1.5rem;

    --tv-font-sans: "Tajawal", system-ui, sans-serif;
    --tv-font-display: "Tajawal", system-ui, sans-serif;
    --tv-font-mono:
        "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New",
        monospace;

    --tv-slate-50: #f8fafc;
    /* Zebra / even table rows (slate-50, explicit RGB for parity with spec) */
    --tv-table-stripe-even: rgb(248, 250, 252);
    --tv-slate-100: #f1f5f9;
    --tv-slate-200: #e2e8f0;
    --tv-slate-300: #cbd5e1;
    --tv-slate-400: #94a3b8;
    --tv-slate-500: #64748b;
    --tv-slate-600: #475569;
    --tv-slate-700: #334155;
    --tv-slate-800: #1e293b;
    --tv-slate-900: #0f172a;
    --tv-slate-950: #020617;

    --tv-sidebar-width: 250px;
    --tv-sidebar-collapsed-width: 80px;
    --tv-topbar-height: 64px;

    --tv-radius: 8px;
    --tv-radius-sm: 4px;
    --tv-radius-md: 8px;
    --tv-radius-lg: 8px;
    --tv-radius-xl: 12px;
    --tv-radius-full: 9999px;
    --tv-radius-2xl: 20px;
    --tv-radius-3xl: 24px;
    --tv-radius-pill: 9999px;

    --tv-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --tv-shadow-sm:
        0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
    --tv-shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    --tv-shadow-lg:
        0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --tv-shadow-xl:
        0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --tv-shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

    /* RGB fallbacks aligned to light theme semantic hexes (themes override) */
    --tv-primary-rgb: 58, 90, 156;
    --tv-success-rgb: 21, 128, 61;
    --tv-danger-rgb: 192, 57, 43;
    --tv-warning-rgb: 180, 83, 9;
    --tv-info-rgb: 3, 105, 161;

    --color-primary: var(--tv-primary);
    --color-bg-app: var(--tv-bg-app);
    --color-gray-100: var(--tv-slate-100);
    --color-gray-200: var(--tv-slate-200);
    --color-gray-300: var(--tv-slate-300);
    --color-gray-400: var(--tv-slate-400);
    --color-gray-500: var(--tv-slate-500);
    --color-gray-600: var(--tv-slate-600);
    --color-gray-700: var(--tv-slate-700);
    --color-gray-800: var(--tv-slate-800);
    --color-gray-900: var(--tv-slate-900);
    --font-sans: var(--tv-font-sans);
    --radius-md: var(--tv-radius-md);
    --radius-lg: var(--tv-radius-lg);
    --radius-full: var(--tv-radius-full);

    --tv-z-base: 1;
    --tv-z-dropdown: 1000;
    --tv-z-sticky: 1010;
    --tv-z-sidebar-backdrop: 1025;
    --tv-z-topbar: 1030;
    --tv-z-sidebar: 1040;
    --tv-z-flyout: 1060;
    --tv-z-modal-backdrop: 1040;
    --tv-z-modal: 1050;
    --tv-z-popover: 1070;
    --tv-z-toast: 1080;
    --tv-z-skip-link: 9999;

    /* Minimal app fallbacks (match light shell; html[data-theme="light"] overwrites) */
    --tv-primary: #3a5a9c;
    --tv-primary-hover: #4e72b0;
    --tv-primary-deep: #2c4575;
    --tv-primary-soft: rgba(58, 90, 156, 0.1);
    --tv-primary-glow: rgba(58, 90, 156, 0.2);
    --tv-on-primary: #ffffff;
    --tv-bg-app: #f1f3f6;
    --tv-surface: #ffffff;
    --tv-surface-elevated: #ffffff;
    --tv-bg-muted: #e8eaef;
    --tv-text: #1a1e2a;
    --tv-text-secondary: #5a6274;
    --tv-text-muted: #5a6274;
    --tv-text-hint: #8b95a8;
    --tv-border: #c8cdd6;
    --tv-border-subtle: #d0d4dc;
    --tv-border-strong: #a4aab6;
    --tv-divider: rgba(0, 0, 0, 0.08);
    --tv-backdrop: rgba(26, 30, 42, 0.5);
    --tv-glass-bg: rgba(255, 255, 255, 0.7);
    --tv-shadow-glow: 0 0 0 3px rgba(58, 90, 156, 0.25);
    --tv-danger-hover: #dc2626;
    --tv-warning-text: #92400e;
    --tv-success-dark: #059669;
}

/* ----- Light theme (canonical UI ? wins over :root) ----- */
html[data-theme="light"] {
    color-scheme: light;

    --tv-primary-rgb: 58, 90, 156; /* #3a5a9c enterprise blue */

    --tv-font-sans: "Tajawal", system-ui, sans-serif;
    --tv-font-display: "Tajawal", system-ui, sans-serif;

    /* App Shell */
    --tv-bg-app: #f8fafc;
    --tv-bg-app-mid: #f1f5f9;
    --tv-bg-muted: #f1f5f9;
    --tv-surface: #ffffff;
    --tv-surface-elevated: #ffffff;
    --tv-sidebar-bg: #ffffff;
    --tv-sidebar-inner: #ffffff;
    --tv-topbar-bg: rgba(255, 255, 255, 0.85);

    /* Typography */
    --tv-text: #1a1e2a;
    --tv-text-secondary: #5a6274;
    --tv-text-muted: #5a6274;
    --tv-text-hint: #8b95a8;
    --tv-link: #3a5a9c;
    --tv-on-primary: #ffffff;

    /* Borders & Shadows */
    --tv-border: #e2e8f0;
    --tv-border-subtle: #f8fafc;
    --tv-border-strong: #cbd5e1;
    --tv-divider: #e2e8f0;

    --tv-shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.03);
    --tv-shadow-sm:
        0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.03);
    --tv-shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --tv-shadow-md:
        0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
    --tv-card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);

    --tv-shadow-inset-soft: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --tv-shadow-inset-input: inset 0 1px 2px rgba(0, 0, 0, 0.02);

    /* Semantic Colors */
    --tv-primary: #3a5a9c;
    --tv-primary-deep: #2c4575;
    --tv-primary-hover: #4e72b0;
    --tv-primary-soft: rgba(58, 90, 156, 0.1);
    --tv-primary-glow: rgba(58, 90, 156, 0.2);
    --tv-primary-on-soft: #2c4575;

    --tv-accent-orange: #f97316;
    --tv-accent-orange-hover: #ea580c;
    --tv-accent-orange-soft: #fff7ed;

    --tv-success: #15803d;
    --tv-success-soft: #dcfce7;
    --tv-success-text: #166534;
    --tv-warning: #b45309;
    --tv-warning-soft: #fef3c7;
    --tv-danger: #c0392b;
    --tv-danger-soft: #fee2e2;
    --tv-danger-text: #991b1b;
    --tv-info: #0369a1;
    --tv-info-soft: #e0f2fe;
    --tv-neutral-soft: #e4e7ed;

    /* Logistics Modes */
    --tv-mode-land: #0d9488;
    --tv-mode-land-bg: #ccfbf1;
    --tv-mode-sea: #3a5a9c;
    --tv-mode-sea-bg: #dbeafe;
    --tv-mode-air: #f97316;
    --tv-mode-air-bg: #fff7ed;

    --tv-price: #3a5a9c;
    --tv-date-ochre: #b45309;

    /* Geometry & Layout */
    --tv-radius: 0.75rem; /* 12px base */
    --tv-radius-lg: 1rem; /* 16px */
    --tv-radius-md: 0.5rem; /* 8px */
    --tv-radius-sm: 0.375rem; /* 6px */
    --tv-radius-xl: 1.25rem; /* 20px */
    --tv-radius-pill: 9999px;

    --tv-sidebar-width: 250px;
    --tv-sidebar-collapsed-width: 80px;
    --tv-topbar-height: 64px;

    --tv-backdrop: rgba(26, 30, 42, 0.5); /* using foreground color */

    --tv-nav-active-grad: #e8eaef; /* reference sidebar-accent */
    --tv-nav-active-border: rgba(58, 90, 156, 0.22);

    /* Merged from legacy tokens.css ? rgba() channels match semantic hex above + depth shadows */
    --tv-success-rgb: 21, 128, 61;
    --tv-danger-rgb: 192, 57, 43;
    --tv-warning-rgb: 180, 83, 9;
    --tv-info-rgb: 3, 105, 161;
    --tv-danger-hover: #dc2626;
    --tv-warning-text: #92400e;
    --tv-success-dark: #059669;
    --tv-shadow-glow: 0 0 0 3px rgba(var(--tv-primary-rgb), 0.22);
    --tv-shadow-lg:
        0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --tv-shadow-xl:
        0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
    --tv-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.15);
}

/* ----- Dark theme (canonical shell ? not legacy tokens slate-900 defaults) ----- */
html[data-theme="dark"] {
    color-scheme: dark;

    --tv-primary-rgb: 99, 102, 241; /* #6366f1 Indigo */
    --tv-table-stripe-even: rgba(255, 255, 255, 0.03);

    --tv-font-sans: "Tajawal", system-ui, sans-serif;
    --tv-font-display: "Tajawal", system-ui, sans-serif;

    --tv-bg-app: #0d1117;
    --tv-bg-app-mid: #161b22;
    --tv-bg-muted: #161d2a;
    --tv-surface: #161b22;
    --tv-surface-elevated: #1c2333;
    --tv-sidebar-bg: #0f1419;
    --tv-sidebar-inner: #0f1419;
    --tv-topbar-bg: rgba(13, 17, 23, 0.85);

    --tv-text: #e6eaf0;
    --tv-text-secondary: #8b95a8;
    --tv-text-muted: #8b95a8;
    --tv-text-hint: #5a6274;
    --tv-link: #5b8cd9;
    --tv-on-primary: #0d1117;

    --tv-border: #262f3d;
    --tv-border-subtle: #1c2333;
    --tv-border-strong: #5a6274;
    --tv-divider: #262f3d;

    --tv-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --tv-shadow-sm:
        0 1px 3px 0 rgb(0 0 0 / 0.6), 0 1px 2px -1px rgb(0 0 0 / 0.5);
    --tv-shadow:
        0 4px 6px -1px rgb(0 0 0 / 0.6), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --tv-shadow-md:
        0 10px 15px -3px rgb(0 0 0 / 0.7), 0 4px 6px -4px rgb(0 0 0 / 0.6);
    --tv-card-shadow: var(--tv-shadow-sm);

    --tv-shadow-inset-soft: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --tv-shadow-inset-input: inset 0 2px 6px rgba(0, 0, 0, 0.25);

    --tv-primary: #6366f1;
    --tv-primary-deep: #4f46e5;
    --tv-primary-hover: #818cf8;
    --tv-primary-soft: rgba(99, 102, 241, 0.15);
    --tv-primary-glow: rgba(99, 102, 241, 0.3);
    --tv-primary-on-soft: #c7d2fe;

    --tv-accent-orange: #fb923c;
    --tv-accent-orange-hover: #fdba74;
    --tv-accent-orange-soft: rgba(251, 146, 60, 0.14);

    --tv-success: #4ade80;
    --tv-success-soft: rgba(74, 222, 128, 0.14);
    --tv-success-text: #bbf7d0;
    --tv-warning: #fbbf24;
    --tv-warning-soft: rgba(251, 191, 36, 0.12);
    --tv-danger: #e74c3c;
    --tv-danger-soft: rgba(231, 76, 60, 0.14);
    --tv-danger-text: #fecaca;

    --tv-mode-land: #2dd4bf;
    --tv-mode-land-bg: rgba(45, 212, 191, 0.12);
    --tv-mode-sea: #818cf8;
    --tv-mode-sea-bg: rgba(129, 140, 248, 0.14);
    --tv-mode-air: #fb923c;
    --tv-mode-air-bg: rgba(251, 146, 60, 0.12);

    --tv-price: #5b8cd9;
    --tv-date-ochre: #fcd34d;

    --tv-info: #60a5fa;
    --tv-info-soft: rgba(96, 165, 250, 0.14);
    --tv-neutral-soft: #1c2333;

    --tv-radius: 0.75rem;
    --tv-radius-lg: 1rem;
    --tv-radius-md: 0.5rem;
    --tv-radius-sm: 0.375rem;
    --tv-radius-xl: 1.25rem;
    --tv-radius-pill: 9999px;

    --tv-sidebar-width: 250px;
    --tv-sidebar-collapsed-width: 80px;
    --tv-topbar-height: 64px;

    --tv-backdrop: rgba(13, 17, 23, 0.7);

    --tv-nav-active-grad: #1c2333;
    --tv-nav-active-border: rgba(91, 140, 217, 0.35);

    --tv-glass-bg: rgba(13, 17, 23, 0.7);

    --app-header-excel: #1c2333;

    /* Merged from legacy tokens.css ? semantic rgb + focus ring + deep shadows (shell unchanged) */
    --tv-success-rgb: 74, 222, 128;
    --tv-danger-rgb: 231, 76, 60;
    --tv-warning-rgb: 251, 191, 36;
    --tv-info-rgb: 96, 165, 250;
    --tv-warning-text: #fcd34d;
    --tv-danger-hover: #f87171;
    --tv-success-dark: #34d399;
    --tv-shadow-glow: 0 0 0 3px rgba(var(--tv-primary-rgb), 0.25);
    --tv-shadow-lg:
        0 10px 15px -3px rgb(0 0 0 / 0.65), 0 4px 6px -4px rgb(0 0 0 / 0.55);
    --tv-shadow-xl:
        0 20px 25px -5px rgb(0 0 0 / 0.72), 0 8px 10px -6px rgb(0 0 0 / 0.62);
    --tv-shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.55);
}

/* Arabic: compound selectors beat html[data-theme] font tokens alone */
html[lang="ar"][data-theme="light"],
html[lang="ar"][data-theme="dark"] {
    --tv-font-sans: "Noto Sans Arabic", "Tajawal", system-ui, sans-serif;
    --tv-font-display: "Noto Sans Arabic", "Tajawal", system-ui, sans-serif;
}

/* ?? Token Aliases: map purchasing/subscription tokens ? canonical design-system tokens ?? */
:root,
html[data-theme="light"],
html[data-theme="dark"] {
    /* purchasing-workflow.css and others use these non-canonical names */
    --tv-color-brand:       var(--tv-primary);
    --tv-color-success:     var(--tv-success);
    --tv-color-danger:      var(--tv-danger);
    --tv-surface-base:      var(--tv-surface);
    --tv-surface-raised:    var(--tv-surface-elevated);
    --tv-surface-overlay:   var(--tv-bg-muted);
    --tv-border-default:    var(--tv-border);
    --tv-text-tertiary:     var(--tv-text-muted);
    --tv-radius-shellmd:    var(--tv-radius);
    --tv-space-5:           1.25rem;    /* 20px ? missing from spacing scale */
}

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

/* ----- Global Scrollbar Modernization ----- */
.tv-theme ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.tv-theme ::-webkit-scrollbar-track {
    background: var(--tv-bg-app);
}
.tv-theme ::-webkit-scrollbar-thumb {
    background: var(--tv-border-strong);
    border-radius: 10px;
    border: 2px solid var(--tv-bg-app);
}
.tv-theme ::-webkit-scrollbar-thumb:hover {
    background: var(--tv-text-muted);
}

/* ----- Atmospheric page background ----- */
body.tv-theme {
    font-family: var(--tv-font-sans) !important;
    color: var(--tv-text);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background-color: var(--tv-bg-app-mid);
    background-image: none !important; /* Flatten background further */
    background-attachment: fixed;
}

.tv-theme h1,
.tv-theme h2,
.tv-theme h3,
.tv-theme h4,
.tv-theme h5,
.tv-theme h6,
.tv-theme p,
.tv-theme span,
.tv-theme a,
.tv-theme button,
.tv-theme input,
.tv-theme select,
.tv-theme textarea,
.tv-theme label {
    font-family: var(--tv-font-sans) !important;
}

html[data-theme="dark"] body.tv-theme {
    background-image:
        radial-gradient(
            ellipse 90% 55% at 50% 0%,
            rgba(var(--tv-primary-rgb), 0.08),
            transparent 50%
        ),
        linear-gradient(180deg, var(--tv-bg-app) 0%, var(--tv-bg-app-mid) 100%);
}

body.tv-theme::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.14;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 220px 220px;
    mix-blend-mode: multiply;
}

html[data-theme="dark"] body.tv-theme::before {
    opacity: 0.22;
    mix-blend-mode: overlay;
}

.tv-app {
    position: relative;
    /* Do not set z-index here: it creates a stacking context so Bootstrap modals
     nested inside .tv-app render *below* body-level .modal-backdrop (1050). */
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ----- Sidebar ----- */
/* Fixed sidebar/backdrop must not reserve flex row width: .tv-shell-main uses margin-inline-start only.
   A min-width on the sidebar flex item doubled the inset (flex track + margin + calc) and caused huge side gutters.
   !important beats enterprise-enhancements mobile .tv-sidebar--collapsed { min-width: ... !important }. */
.tv-app > .tv-sidebar-backdrop,
.tv-app > .tv-sidebar {
    flex: 0 0 0 !important;
    min-width: 0 !important;
}

.tv-sidebar {
    width: var(--tv-sidebar-width);
    min-width: 0;
    background: var(--tv-sidebar-inner);
    border-inline-end: 1px solid var(--tv-border);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    /* ALWAYS fixed ? never scrolls with body content */
    position: fixed !important;
    top: 0;
    inset-inline-start: 0;
    bottom: 0;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    z-index: var(--tv-z-sidebar, 1040);
    transition: width var(--tv-transition-duration) var(--tv-transition-timing);
}

/* Sidebar: GPU hint for width transitions. Do NOT set will-change on .tv-shell-main ? it creates a fixed-position
   containing block so Bootstrap modals left under main stack below the body .modal-backdrop until reparent runs. */
.tv-sidebar {
    backface-visibility: hidden;
    will-change: width, transform;
}

.tv-shell-main {
    backface-visibility: hidden;
}

.tv-sidebar--collapsed {
    width: var(--tv-sidebar-collapsed-width);
    min-width: 0;
}

.tv-sidebar--collapsed .tv-sidebar__logo-name,
.tv-sidebar--collapsed .tv-sidebar__section-label,
.tv-sidebar--collapsed .tv-sidebar-link span:not(.tv-sidebar-icon),
.tv-sidebar--collapsed .tv-sidebar-user__meta,
.tv-sidebar--collapsed .tv-btn-sidebar-logout span,
.tv-sidebar--collapsed .tv-sidebar__divider {
    display: none;
}

.tv-sidebar--collapsed .tv-sidebar-link,
.tv-sidebar--collapsed .tv-btn-sidebar-logout {
    justify-content: center;
    padding: 0.625rem;
    position: relative;
}

/* ?? Collapsed icon-rail tooltips ??
   Removed CSS-only tooltips in favor of unified JS tooltips in site.js
*/

/* Collapsed rail: hide expandable sections (icons-only mode) */
.tv-sidebar--collapsed .collapse {
    display: none !important;
}

/*
  Bootstrap's collapse show() removes .collapse and adds .collapsing during the
  transition; our .collapse rule then no longer matches and the panel briefly
  takes height (gap under the icon). Keep icon-rail layout flat while .collapsing.
*/
.tv-sidebar--collapsed .collapsing {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    border-width: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.tv-sidebar--collapsed [data-bs-toggle="collapse"] .ms-auto {
    display: none;
}

/* ?????????????????????????????????????????????????????????????
   Collapsed-rail flyout ? shows submenu items beside the trigger
   when the sidebar is in icon-only mode. Lives on document.body
   to escape sidebar clipping & containing-block traps caused by
   ancestor will-change/transform.
   ????????????????????????????????????????????????????????????? */
.tv-sidebar-flyout {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1080;
    min-width: 220px;
    max-width: 280px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 6px;
    background: var(--tv-surface-elevated, var(--tv-surface));
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    box-shadow:
        0 22px 48px rgba(15, 23, 42, 0.18),
        0 8px 16px rgba(15, 23, 42, 0.12),
        var(--tv-shadow-inset-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-6px) scale(0.98);
    transform-origin: top left;
    transition:
        opacity 0.14s ease,
        transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--tv-border) transparent;
}

[dir="rtl"] .tv-sidebar-flyout {
    transform: translateX(6px) scale(0.98);
    transform-origin: top right;
}

.tv-sidebar-flyout.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

.tv-sidebar-flyout::-webkit-scrollbar {
    width: 6px;
}

.tv-sidebar-flyout::-webkit-scrollbar-thumb {
    background: var(--tv-border);
    border-radius: 99px;
}

html[data-theme="dark"] .tv-sidebar-flyout {
    box-shadow:
        0 22px 48px rgba(0, 0, 0, 0.55),
        0 8px 16px rgba(0, 0, 0, 0.4);
}

.tv-sidebar-flyout__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem 0.55rem;
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tv-text-muted);
    border-bottom: 1px solid var(--tv-border-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-sidebar-flyout__list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0 2px;
}

.tv-sidebar-flyout__link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.7rem;
    border-radius: var(--tv-radius-md);
    color: var(--tv-text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.01em;
    border: 1px solid transparent;
    transition:
        background 0.12s ease,
        color 0.12s ease,
        border-color 0.12s ease,
        box-shadow 0.12s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.tv-sidebar-flyout__link:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-text);
}

.tv-sidebar-flyout__link:focus-visible {
    outline: none;
    border-color: var(--tv-primary);
    box-shadow: 0 0 0 2px var(--tv-primary-soft);
}

.tv-sidebar-flyout__link.active {
    background: var(--tv-nav-active-grad, var(--tv-primary-soft));
    color: var(--tv-primary-deep);
    border-color: var(--tv-nav-active-border, transparent);
    font-weight: 600;
}

html[data-theme="dark"] .tv-sidebar-flyout__link.active {
    color: var(--tv-primary);
}

html[data-theme="dark"] .tv-sidebar {
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.35);
}

.tv-sidebar__brand {
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--tv-border-subtle);
    background: transparent;
}

html[data-theme="dark"] .tv-sidebar__brand {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.04) 0%,
        transparent 100%
    );
}

.tv-sidebar__logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--tv-text);
    font-weight: 700;
    font-size: 1.07rem;
    letter-spacing: -0.035em;
    padding: 0.35rem 0.25rem;
    border-radius: var(--tv-radius-sm);
    transition:
        background 0.18s ease,
        transform 0.18s ease,
        color 0.18s ease;
}

.tv-sidebar__logo-name {
    color: var(--tv-primary);
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-sidebar__logo:hover .tv-sidebar__logo-name {
    color: var(--tv-primary-deep);
}

.tv-sidebar__logo:hover {
    background: rgba(var(--tv-primary-rgb), 0.06);
}

.tv-sidebar__logo-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(
        145deg,
        #12b896 0%,
        var(--tv-primary) 45%,
        var(--tv-primary-deep) 100%
    );
    display: grid;
    place-items: center;
    color: var(--tv-on-primary);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    box-shadow:
        var(--tv-shadow-sm),
        0 0 0 1px rgba(255, 255, 255, 0.22) inset,
        0 8px 24px var(--tv-primary-glow);
}

/* Logo tile: light border + radius so white PNG art reads as a card */
.tv-sidebar__logo-frame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px 6px;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md);
    background: var(--tv-surface-elevated, var(--tv-surface));
    box-shadow: var(--tv-shadow-xs);
}

html[data-theme="dark"] .tv-sidebar__logo-frame {
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

/* Raster logos: medium when sidebar expanded, small in icon rail */
.tv-sidebar__logo-img {
    display: block;
    height: auto;
    object-fit: contain;
}

.tv-sidebar__logo-img--expanded {
    max-height: 40px;
    max-width: min(148px, 100%);
    width: auto;
}

.tv-sidebar__logo-img--collapsed {
    display: none;
    max-height: 30px;
    max-width: 34px;
    width: auto;
}

.tv-sidebar--collapsed .tv-sidebar__logo-img--expanded {
    display: none;
}

.tv-sidebar--collapsed .tv-sidebar__logo-img--collapsed {
    display: block;
}

.tv-sidebar--collapsed .tv-sidebar__logo {
    justify-content: center;
}

.tv-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.625rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--tv-border) transparent;
}

.tv-sidebar__nav::-webkit-scrollbar {
    width: 6px;
}

.tv-sidebar__nav::-webkit-scrollbar-thumb {
    background: var(--tv-border);
    border-radius: 99px;
}

.tv-sidebar__section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--tv-sidebar-section-fg, var(--tv-text-muted));
    padding: 0.85rem 0.7rem 0.4rem;
}

.tv-sidebar__divider {
    height: 1px;
    margin: 0.65rem 0.55rem;
    background: linear-gradient(
        90deg,
        transparent,
        var(--tv-divider) 15%,
        var(--tv-divider) 85%,
        transparent
    );
}

.tv-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5625rem 0.875rem;
    border-radius: var(--tv-radius-md);
    color: var(--tv-sidebar-link-fg, var(--tv-text-secondary));
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    border: 1px solid transparent;
    transition:
        background 0.12s ease,
        color 0.12s ease,
        border-color 0.12s ease,
        box-shadow 0.12s ease;
    margin-bottom: 2px;
}

.tv-sidebar-link--toggle .ms-auto {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.75;
}

.tv-sidebar-link--toggle[aria-expanded="true"] .ms-auto {
    transform: rotate(180deg);
    opacity: 1;
}

.tv-sidebar-link--toggle {
    cursor: pointer;
}

.tv-sidebar-link:hover {
    background: var(--tv-sidebar-link-hover-bg, var(--tv-bg-muted));
    color: var(--tv-sidebar-link-hover-fg, var(--tv-text));
    border-color: transparent;
    box-shadow: none;
}

html[data-theme="dark"] .tv-sidebar-link:hover {
    background: var(--tv-sidebar-link-hover-bg, var(--tv-bg-muted));
    color: var(--tv-sidebar-link-hover-fg, var(--tv-text));
    border-color: transparent;
}

.tv-sidebar-link.active {
    background: var(--tv-sidebar-active-bg, var(--tv-nav-active-grad));
    color: var(--tv-sidebar-active-fg, var(--tv-primary-deep));
    border-color: var(--tv-sidebar-active-border, var(--tv-nav-active-border));
    font-weight: 600;
    box-shadow: none;
}

html[data-theme="dark"] .tv-sidebar-link.active {
    background: var(--tv-sidebar-active-bg, var(--tv-nav-active-grad));
    color: var(--tv-sidebar-active-fg, var(--tv-primary));
    border-color: var(--tv-sidebar-active-border, var(--tv-nav-active-border));
    box-shadow: none;
}

.tv-sidebar-link.active .tv-sidebar-icon {
    color: var(--tv-sidebar-active-icon, var(--tv-primary-deep));
    opacity: 1;
    filter: drop-shadow(0 1px 2px rgba(var(--tv-primary-rgb), 0.25));
}

html[data-theme="dark"] .tv-sidebar-link.active .tv-sidebar-icon {
    color: var(--tv-sidebar-active-icon, var(--tv-primary));
}

.tv-sidebar-link .tv-sidebar-icon {
    width: 1.18rem;
    height: 1.18rem;
    opacity: 0.78;
    flex-shrink: 0;
    transition:
        opacity 0.2s ease,
        color 0.2s ease;
}

.tv-sidebar-submenu {
    position: relative;
    padding: 0.25rem 0 0.35rem 0;
    margin: 0.15rem 0 0.45rem;
}

.tv-sidebar-submenu .tv-sidebar-link {
    position: relative;
    font-size: 13px;
    padding-block: 0.4375rem;
    padding-inline-end: 0.875rem;
    padding-inline-start: 2.125rem;
    border-radius: var(--tv-radius-md);
}

.tv-sidebar-submenu .tv-sidebar-link::before {
    content: "";
    position: absolute;
    inset-inline-start: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tv-sidebar-submenu-bullet, var(--tv-border-strong));
    flex-shrink: 0;
}

.tv-sidebar-submenu .tv-sidebar-link.active::before {
    background: var(--tv-sidebar-submenu-bullet-active, var(--tv-primary));
}

.tv-sidebar__footer {
    padding: 1rem 0.95rem 1.15rem;
    border-top: 1px solid var(--tv-border-subtle);
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.02) 0%, transparent 36%);
}

html[data-theme="dark"] .tv-sidebar__footer {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0%, transparent 40%);
}

.tv-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 0.72rem;
    border-radius: var(--tv-radius-md);
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    margin-bottom: 0.72rem;
    box-shadow: var(--tv-shadow-xs), var(--tv-shadow-inset-soft);
}

.tv-sidebar-user__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(
        145deg,
        var(--tv-primary-soft),
        rgba(99, 102, 241, 0.15)
    );
    color: var(--tv-primary);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.88rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.65) inset;
}

.tv-sidebar-user__meta {
    min-width: 0;
    flex: 1;
}

.tv-sidebar-user__name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tv-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tv-sidebar-user__hint {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--tv-text-muted);
    letter-spacing: 0.02em;
}

.tv-btn-sidebar-logout {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--tv-text-secondary);
    background: linear-gradient(180deg, #fafbfc 0%, var(--tv-bg-muted) 100%);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    transition:
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
    box-shadow: var(--tv-shadow-xs);
}

.tv-btn-sidebar-logout:hover {
    background: var(--tv-surface);
    color: var(--tv-text);
    box-shadow: var(--tv-shadow-sm);
}

html[data-theme="dark"] .tv-btn-sidebar-logout {
    background: linear-gradient(
        180deg,
        var(--tv-surface-elevated) 0%,
        var(--tv-bg-muted) 100%
    );
}

.tv-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--tv-backdrop);
    backdrop-filter: blur(3px);
    z-index: var(--tv-z-sidebar-backdrop, 1025);
}

.tv-sidebar-backdrop.show {
    display: block;
}

@media (max-width: 991.98px) {
    .tv-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--tv-shadow-md);
    }

    .tv-sidebar.tv-sidebar--open {
        transform: translateX(0);
    }

    .tv-shell-main {
        width: 100%;
        margin-inline-start: 0 !important;
        margin-inline-end: 0 !important;
    }
}

/* ----- Main column ? offset matches fixed sidebar width exactly ----- */
/* margin-inline-start: sidebar sits on inline-start (left in LTR, right in RTL).
   Width is flex-driven; avoid calc(100% - sidebar) when sidebar flex slot is zero ? that pattern duplicated the inset. */
.tv-shell-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-inline-start: var(--tv-sidebar-width);
    margin-inline-end: 0;
    width: auto;
    max-width: none;
    box-sizing: border-box;
    transition: margin-inline-start var(--tv-transition-duration)
        var(--tv-transition-timing);
}

/* Icon rail: shrink content inset. :has() avoids any fragile sibling adjacency; + keeps a fallback. */
.tv-app:has(> .tv-sidebar.tv-sidebar--collapsed) > .tv-shell-main,
.tv-sidebar--collapsed + .tv-shell-main {
    margin-inline-start: var(--tv-sidebar-collapsed-width);
}

/* Authenticated desktop: scroll inside main shell so the thumb stays on the content pane edge (LTR: right; RTL: left). */
@media (min-width: 992px) {
    html:has(.tv-app > .tv-sidebar) {
        height: 100%;
    }

    body.tv-theme:has(.tv-sidebar) {
        overflow: hidden;
        height: 100%;
    }

    .tv-app:has(> .tv-sidebar) {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }

    .tv-shell-main:not(.tv-main--guest) {
        min-height: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        scrollbar-gutter: stable;
    }
}

.tv-topbar {
    min-height: var(--tv-topbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--tv-topbar-bg);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--tv-border);
    position: sticky;
    top: 0;
    z-index: var(--tv-z-topbar, 1030);
}

html[data-theme="light"] .tv-topbar {
    background: rgba(255, 255, 255, 0.85);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.55) inset,
        0 4px 12px -2px rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] .tv-topbar {
    background: rgba(30, 41, 59, 0.8);
}

html[data-theme="dark"] .tv-topbar {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.tv-topbar__left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

/* Hamburger button permanently hidden ? sidebar is always fixed */
.tv-topbar__menu {
    display: none !important;
}

.tv-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 34px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--tv-radius-md);
    border: 1px solid var(--tv-border);
    background: var(--tv-bg-app);
    box-shadow: none;
    min-width: 0;
    flex: 1;
    max-width: 380px;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.tv-topbar {
    border-bottom: 1px solid var(--tv-border);
    background: var(--tv-topbar-bg);
    backdrop-filter: blur(12px) saturate(180%);
}

.tv-search:focus-within {
    border-color: var(--tv-primary);
    box-shadow: 0 0 0 3px rgba(var(--tv-primary-rgb), 0.12);
}

html[data-theme="dark"] .tv-search {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--tv-border);
}

.tv-search input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--tv-text-secondary);
}

.tv-search input::placeholder {
    color: var(--tv-text-hint);
}

.tv-search svg {
    flex-shrink: 0;
    opacity: 0.65;
}

.tv-topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Guest shell: logo tile + app name */
.tv-topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: min(100%, calc(100vw - 11rem));
    padding: 0.2rem 0.35rem;
    border-radius: var(--tv-radius-sm);
    transition:
        background 0.18s ease,
        opacity 0.18s ease;
}

.tv-topbar-brand:hover {
    background: rgba(var(--tv-primary-rgb), 0.08);
}

.tv-topbar-brand__frame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 3px 5px;
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md);
    background: var(--tv-surface-elevated, var(--tv-surface));
    box-shadow: var(--tv-shadow-xs);
}

html[data-theme="dark"] .tv-topbar-brand__frame {
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(255, 255, 255, 0.06);
}

.tv-topbar-brand__img {
    display: block;
    max-height: 32px;
    width: auto;
    max-width: min(120px, 36vw);
    object-fit: contain;
}

.tv-topbar-brand__name {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--tv-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-topbar-brand:hover .tv-topbar-brand__name {
    color: var(--tv-primary-deep);
}

.tv-btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--tv-border);
    background: linear-gradient(
        180deg,
        var(--tv-surface) 0%,
        var(--tv-bg-muted) 100%
    );
    color: var(--tv-text-secondary);
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.15s ease;
    box-shadow: var(--tv-shadow-xs);
}

.tv-btn-icon:hover {
    background: var(--tv-surface);
    color: var(--tv-primary);
    box-shadow: var(--tv-shadow-sm);
}

.tv-btn-icon:focus-visible {
    outline: 2px solid var(--tv-primary);
    outline-offset: 2px;
}

.tv-page-wrap {
    flex: 1;
    /* Tight top under sticky .tv-topbar; keep horizontal + bottom rhythm */
    padding: var(--tv-space-3, 0.75rem) 0.5rem 2.25rem;
    box-sizing: border-box;
}

@media (min-width: 992px) {
    .tv-page-wrap {
        padding: var(--tv-space-3, 0.75rem) 0.75rem 2.75rem;
    }
}

/* Authenticated main uses full width of .tv-shell-main (sidebar already defines left edge) */
.tv-shell-main:not(.tv-main--guest) > main.tv-page-wrap {
    width: 100%;
    max-width: none;
    margin-inline: 0;
}

.tv-shell-main footer.tv-footer .tv-footer__inner {
    max-width: none;
    margin-inline: 0;
}

/* ----- Skeleton Loading States ----- */
.tv-skeleton {
    background: linear-gradient(
        90deg,
        var(--tv-bg-muted) 25%,
        var(--tv-border-subtle) 37%,
        var(--tv-bg-muted) 63%
    );
    background-size: 400% 100%;
    animation: tv-skeleton-loading 1.4s ease infinite;
    border-radius: var(--tv-radius-sm);
    display: inline-block;
    min-height: 1em;
    width: 100%;
}

@keyframes tv-skeleton-loading {
    0% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}

/* Toolbar-style GET/POST filter rows (lists + reports) */
.tv-filter-bar.row {
    padding: 1rem 1.125rem;
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md);
    box-shadow: var(--tv-shadow-xs);
}

html[data-ui-brand="enterprise"] .tv-filter-bar.row {
    border-radius: 1rem;
    box-shadow: var(--app-shadow-xs);
}

@media (max-width: 575.98px) {
    .tv-filter-bar.row {
        padding: 0.875rem 1rem;
    }
}

/* Dashboard / misc Bootstrap cards ? match tv-card-surface treatment */
.tv-shell-main main.tv-page-wrap > .tv-page-content-shell > .row .card,
.tv-shell-main main.tv-page-wrap > .tv-page-content-shell > .card {
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--tv-card-shadow);
    overflow: hidden;
}

.tv-shell-main main.tv-page-wrap .card-header {
    padding: 0.75rem 1.125rem;
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: -0.015em;
    color: var(--tv-text);
    background: var(--tv-bg-muted);
    border-bottom: 1px solid var(--tv-border);
}

.tv-shell-main main.tv-page-wrap .card-body {
    padding: 1rem 1.125rem;
}

html[data-ui-brand="enterprise"] .tv-shell-main main.tv-page-wrap > .tv-page-content-shell > .row .card,
html[data-ui-brand="enterprise"] .tv-shell-main main.tv-page-wrap > .tv-page-content-shell > .card {
    border-radius: 1rem;
    box-shadow: var(--app-card-shadow);
}

html[data-ui-brand="enterprise"] .tv-shell-main main.tv-page-wrap .card-header {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.85) 0%,
        var(--tv-bg-muted) 100%
    );
}

html[data-theme="dark"][data-ui-brand="enterprise"]
    .tv-shell-main
    main.tv-page-wrap
    .card-header {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.04) 0%,
        var(--tv-bg-muted) 100%
    );
}

/* Shared panel title strip (matches dashboard ?Fast create?) */
.tv-panel-header {
    padding: 0.75rem 1.125rem;
    border-bottom: 1px solid var(--tv-border);
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: -0.015em;
    color: var(--tv-text);
    background: var(--tv-bg-muted);
}

html[data-ui-brand="enterprise"] .tv-panel-header {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.85) 0%,
        var(--tv-bg-muted) 100%
    );
}

html[data-theme="dark"][data-ui-brand="enterprise"] .tv-panel-header {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.04) 0%,
        var(--tv-bg-muted) 100%
    );
}

/* ----- Cards ----- */
.tv-card {
    position: relative;
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    box-shadow: var(--tv-card-shadow);
    overflow: visible;
    transition: all var(--tv-transition-duration) var(--tv-transition-timing);
}

.tv-card--w-xs { max-width: 26.25rem; }
.tv-card--w-sm { max-width: 30rem; }
.tv-card--w-md { max-width: 32.5rem; }
.tv-card--w-lg { max-width: 35rem; }
.tv-card--w-xl { max-width: 40rem; }
.tv-card--w-2xl { max-width: 42.5rem; }
.tv-card--w-3xl { max-width: 45rem; }
.tv-card--w-wide { max-width: 48rem; }
.tv-card--w-profile { max-width: 32rem; }

.tv-form-stack--narrow {
    max-width: 40rem;
}

.tv-modal-dialog--narrow {
    max-width: 24rem;
}

.tv-modal-dialog--compact {
    max-width: 26rem;
}

.tv-control--reason {
    max-width: 8.75rem;
}

.tv-col--attachment-file { width: 36%; }
.tv-col--attachment-size { width: 10%; }
.tv-col--attachment-uploaded { width: 14%; }
.tv-col--attachment-actions { width: 18%; }

.tv-activity-time {
    width: 7rem;
}

.tv-status-dot {
    width: 0.375rem;
    height: 0.375rem;
}

.tv-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.85),
        transparent
    );
    opacity: 0.9;
    pointer-events: none;
}

html[data-theme="dark"] .tv-card::before {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.12),
        transparent
    );
}

.tv-card:hover {
    box-shadow: var(--tv-shadow-sm);
    transform: translateY(-1px);
    border-color: rgba(var(--tv-primary-rgb), 0.2);
}

.tv-card-body {
    padding: 1.25rem 1.5rem;
}

.tv-page-title {
    font-family: var(--tv-font-display);
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
    line-height: 1.25;
    margin-bottom: 0.5rem;
    color: var(--tv-text);
}

html[data-theme="light"] .tv-page-title {
    text-shadow: none;
}

html[data-theme="dark"] .tv-page-title {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.tv-page-sub {
    color: var(--tv-text-secondary);
    font-size: 0.96rem;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* ----- Buttons ----- */
/* Ledger pill system: tv-buttons-ledger.css (.tv-theme .btn*, .tv-btn-* under .tv-theme). */

.tv-btn-accent {
    background: linear-gradient(
        165deg,
        #f59e0b 0%,
        var(--tv-accent-orange) 100%
    );
    color: #fff;
    box-shadow:
        var(--tv-shadow-xs),
        0 4px 14px rgba(217, 119, 6, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tv-btn-accent:hover {
    filter: brightness(1.05);
    color: #fff;
    transform: translateY(-1px);
}

.tv-btn-dark {
    background: linear-gradient(180deg, #1a1a1a 0%, #000000 100%);
    color: #ffffff;
    border: 1px solid #000000;
    box-shadow:
        var(--tv-shadow-xs),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tv-btn-dark:hover {
    filter: brightness(1.12);
    color: #ffffff;
    transform: translateY(-1px);
}

html[data-theme="dark"] .tv-btn-dark {
    background: linear-gradient(180deg, #ffffff 0%, #e5e7eb 100%);
    color: #111827;
    border-color: #e5e7eb;
}

/* ----- KPI / summary strips (invoice totals, etc.) ----- */
.tv-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.tv-kpi {
    border-radius: var(--tv-radius-md);
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--tv-border);
    box-shadow: var(--tv-shadow-xs);
    position: relative;
    overflow: hidden;
}

.tv-kpi--muted {
    background: var(--tv-bg-muted);
}

.tv-kpi--success {
    background: var(--tv-success-soft);
    border-color: var(--tv-success);
}

html[data-theme="dark"] .tv-kpi--success {
    background: var(--tv-success-soft);
}

.tv-kpi__label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tv-text-muted);
    margin-bottom: 0.35rem;
}

.tv-kpi__value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--tv-text);
    line-height: 1.15;
}

.tv-kpi--success .tv-kpi__value {
    color: var(--tv-success-text);
}

/* ----- Logistics / offer card (Retin-style) ----- */
.tv-offer-card {
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    padding: 1.35rem 1.4rem 1.45rem;
    box-shadow: var(--tv-shadow);
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.tv-offer-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--tv-shadow-md);
}

.tv-offer-card__top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: start;
    margin-bottom: 1rem;
}

.tv-mode-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.tv-mode-icon--land {
    background: var(--tv-mode-land);
}

.tv-mode-icon--sea {
    background: var(--tv-mode-sea);
}

.tv-mode-icon--air {
    background: var(--tv-mode-air);
}

.tv-offer-card__meta-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tv-text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tv-offer-card__meta-value {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.03em;
    color: var(--tv-text);
}

.tv-offer-card__price {
    text-align: end;
}

.tv-offer-card__price .tv-offer-card__meta-value {
    color: var(--tv-price);
    font-size: 1.12rem;
}

.tv-badge-dashed {
    display: inline-block;
    margin: 0.65rem auto 0.85rem;
    padding: 0.38rem 1rem;
    border-radius: var(--tv-radius-pill);
    border: 2px dashed currentColor;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    width: fit-content;
    max-width: 100%;
}

.tv-badge-dashed--land {
    color: var(--tv-mode-land);
    background: var(--tv-mode-land-bg);
}

.tv-badge-dashed--sea {
    color: var(--tv-mode-sea);
    background: var(--tv-mode-sea-bg);
}

.tv-badge-dashed--air {
    color: var(--tv-mode-air);
    background: var(--tv-mode-air-bg);
}

.tv-timeline-rail {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0.85rem 0 1rem;
    padding: 0 0.25rem;
}

.tv-timeline-rail::before {
    content: "";
    flex: 1;
    height: 0;
    border-top: 2px dashed var(--tv-text-muted);
    opacity: 0.35;
}

.tv-timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tv-text-muted);
    opacity: 0.55;
    flex-shrink: 0;
    margin: 0 0.55rem;
}

.tv-offer-card__locations {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.tv-offer-card__loc-side {
    max-width: 46%;
}

.tv-offer-card__loc-side--end {
    text-align: end;
}

.tv-offer-card__city {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--tv-text);
    letter-spacing: -0.02em;
}

.tv-offer-card__country {
    font-size: 0.8rem;
    color: var(--tv-text-muted);
    margin-top: 0.15rem;
}

.tv-offer-card__dates {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0.35rem;
    gap: 0.75rem;
}

.tv-offer-card__date {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tv-offer-card__date--land {
    color: var(--tv-mode-land);
}

.tv-offer-card__date--sea {
    color: var(--tv-mode-sea);
}

.tv-offer-card__date--air {
    color: var(--tv-mode-air);
}

.tv-offer-card__date-cap {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--tv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.15rem;
}

/* ----- Forms ----- */
.tv-form-control,
.tv-theme .form-control {
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    padding: 0.5rem 0.75rem;
    background: var(--tv-surface);
    color: var(--tv-text);
    box-shadow: var(--tv-shadow-inset-input);
    font-weight: 400;
    font-size: var(--tv-fs-sm);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    font-family: var(--tv-font-sans);
}

.tv-form-control:focus,
.tv-theme .form-control:focus {
    border-color: var(--tv-primary);
    outline: none;
    box-shadow:
        0 0 0 2px var(--tv-bg-app),
        0 0 0 4px var(--tv-primary-soft);
}

.tv-theme .form-select {
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    background-color: var(--tv-surface);
    color: var(--tv-text);
    padding: 0.5rem 0.75rem;
    font-size: var(--tv-fs-sm);
    box-shadow: var(--tv-shadow-inset-input);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    font-family: var(--tv-font-sans);
}

.tv-theme .form-select:focus {
    border-color: var(--tv-primary);
    outline: none;
    box-shadow:
        0 0 0 2px var(--tv-bg-app),
        0 0 0 4px var(--tv-primary-soft);
}

/* Unified native selects: single chevron, consistent padding (app-wide; excludes multi-select). */
.tv-theme select.form-select:not([multiple]),
.tv-theme select.tv-form-control.form-select:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-inline-end: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 1rem;
}

html[dir="rtl"] .tv-theme select.form-select:not([multiple]),
html[dir="rtl"] .tv-theme select.tv-form-control.form-select:not([multiple]) {
    background-position: left 0.65rem center;
}

html[data-theme="dark"] .tv-theme select.form-select:not([multiple]),
html[data-theme="dark"] .tv-theme select.tv-form-control.form-select:not([multiple]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 1rem;
    background-position: right 0.65rem center;
}

html[data-theme="dark"][dir="rtl"] .tv-theme select.form-select:not([multiple]),
html[data-theme="dark"][dir="rtl"] .tv-theme select.tv-form-control.form-select:not([multiple]) {
    background-position: left 0.65rem center;
}

.tv-theme select.form-select:not([multiple]):disabled,
.tv-theme select.tv-form-control.form-select:not([multiple]):disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.tv-theme .form-label {
    color: var(--tv-text);
    font-weight: 600;
    font-size: var(--tv-fs-sm);
    margin-bottom: 0.375rem;
}

/* Comfortable tap targets on primary forms (not table embeds) */
.tv-shell-main main.tv-page-wrap .tv-card-body .form-control:not(textarea),
.tv-shell-main main.tv-page-wrap .tv-card-body .form-select {
    min-height: 2.5rem;
}

/* ?? _FormField Dense / Inline / LeadingIcon support ????????????????????????
 * Matches the visual pattern of tv-pw-field-group--inline in purchasing-workflow.css
 * so that new forms can use _FormField with Dense=true / Inline=true / LeadingIconName
 * instead of the hand-coded tv-pw-field-group HTML.
 * ???????????????????????????????????????????????????????????????????????????? */

/* Inline layout ? label and slot side-by-side */
.tv-form-field--inline {
    display: grid;
    grid-template-columns: minmax(7rem, 10rem) 1fr;
    align-items: flex-start;
    gap: 0 var(--tv-space-3, 0.75rem);
}

.tv-form-field__label--inline {
    display: flex;
    align-items: center;
    gap: var(--tv-space-2, 0.5rem);
    padding-block-start: 0.375rem; /* align with input text */
}

/* Slot wrapper inside _FormField */
.tv-form-field__slot {
    display: flex;
    flex-direction: column;
}

/* Leading icon inside the label */
.tv-form-field__icon {
    width: 0.9375rem;
    height: 0.9375rem;
    flex-shrink: 0;
    color: var(--tv-text-muted, #94a3b8);
}

/* Modern Form Section Title */
.tv-form-section-title {
    font-size: 0.6875rem;
    color: var(--tv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    border-bottom: 1px solid var(--tv-border-subtle);
    padding-bottom: 0.375rem;
    font-weight: 600;
}

.tv-form-section-title:first-child {
    margin-top: 0;
}

/* Standard Form Action Row */
.tv-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
    padding-top: 1.25rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--tv-border-subtle);
}

/* ----- Badges (invoice status parity) ----- */
.tv-badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.28rem 0.62rem;
    border-radius: var(--tv-radius-pill);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--tv-primary-soft);
    color: var(--tv-primary-on-soft);
    border: 1px solid rgba(var(--tv-primary-rgb), 0.12);
}

.tv-badge-success {
    background: var(--tv-success-soft);
    color: var(--tv-success-text);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.tv-badge-warning {
    background: var(--tv-warning-soft);
    color: var(--tv-accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.25);
}

.tv-badge-danger {
    background: var(--tv-danger-soft);
    color: var(--tv-danger-text);
    border: 1px solid rgba(220, 38, 38, 0.22);
}

.tv-badge-neutral {
    background: var(--tv-neutral-soft);
    color: var(--tv-text-secondary);
    border: 1px solid var(--tv-border);
}

.tv-table-wrap {
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md);
    box-shadow: var(--tv-shadow-sm);
    background: var(--tv-surface);
    overflow: hidden;
}

/* App shell ?canvas? tables: neutral chrome aligned with shell cards / .tw-shell-card-header.
   Excludes: DataTables (.dataTable), tv-datatables (.tv-dt), list enterprise grid (.tv-table-enterprise). */
.tv-theme .tv-shell-main main table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise) {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    font-size: 0.9375rem;
    color: var(--tv-text);
    vertical-align: middle;
}

.tv-theme .tv-shell-main main table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise) thead th {
    position: static;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, var(--tv-bg-muted) 100%);
    color: var(--tv-text-muted);
    font-weight: 600;
    font-size: 0.6875rem;
    line-height: 1.35;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0.55rem 0.65rem;
    border: none;
    border-bottom: 1px solid var(--tv-border);
    border-inline-end: 1px solid var(--tv-border-subtle, rgba(148, 163, 184, 0.28));
    white-space: nowrap;
    vertical-align: middle;
    box-shadow: none;
}

.tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    thead
    th:last-child {
    border-inline-end: none;
}

.tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    thead
    tr {
    border-bottom: 1px solid var(--tv-border);
}

.tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    tr:nth-child(even) {
    background: var(--tv-table-stripe-even);
}

html[data-theme="dark"]
    .tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    tr:nth-child(odd) {
    background: var(--tv-surface);
}

.tv-theme .tv-shell-main main table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise) tbody td {
    padding: 0.5rem 0.65rem;
    font-size: 0.875rem;
    color: var(--tv-text);
    border: 1px solid var(--tv-border-subtle, rgba(148, 163, 184, 0.25));
    vertical-align: middle;
}

.tv-theme .tv-shell-main main table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise) tbody tr {
    transition: background 0.15s ease;
}

.tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    tr:hover {
    background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"]
    .tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"]
    .tv-theme
    .tv-shell-main
    main
    table.table:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    thead
    th {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.04) 0%,
        color-mix(in srgb, var(--tv-surface-raised) 88%, var(--tv-primary) 8%) 100%
    );
    color: var(--tv-text-secondary);
    border-bottom-color: var(--tv-border);
    border-inline-end-color: var(--tv-border-subtle, rgba(255, 255, 255, 0.12));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tv-theme
    .tv-shell-main
    main
    table.table.table-sm:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    tbody
    td {
    padding: 0.38rem 0.55rem;
    font-size: 0.8125rem;
}

.tv-theme
    .tv-shell-main
    main
    table.table.table-sm:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    thead
    th {
    padding: 0.45rem 0.55rem;
    font-size: 0.6875rem;
}

.tv-theme
    .tv-shell-main
    main
    table.table.table-striped:not(.dataTable):not(.tv-dt):not(.tv-table-enterprise)
    > tbody
    > tr:nth-of-type(odd)
    > * {
    --bs-table-accent-bg: transparent;
    box-shadow: none;
}

/* ----- Footer ----- */
.tv-footer {
    border-top: 1px solid var(--tv-border);
    background: var(--tv-topbar-bg);
    backdrop-filter: blur(12px);
    color: var(--tv-text-muted);
    font-size: 0.84rem;
    font-weight: 400;
}

/* ----- Bootstrap alignment ----- */
.tv-theme .btn-primary {
    background: var(--tv-primary);
    border-color: var(--tv-primary);
    border-radius: var(--tv-radius-md);
    font-weight: 500;
    font-size: 13px;
    padding: 0.5625rem 1.125rem;
    box-shadow: var(--tv-shadow-xs);
}

.tv-theme .btn-primary:hover,
.tv-theme .btn-primary:focus {
    background: var(--tv-primary-deep);
    border-color: var(--tv-primary-deep);
    filter: none;
}

.tv-theme .btn-primary:active {
    transform: scale(0.98);
}

.tv-theme .btn-sm.btn-primary,
.tv-theme .btn-primary.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 12.5px;
    border-radius: var(--tv-radius-md);
}

/* Outline primary ? brand-forward (must not override BS --bs-btn-* with neutral borders) */
.tv-theme .btn-outline-primary {
    border-radius: var(--tv-radius-md);
    font-weight: 500;
    font-size: var(--tv-fs-sm);
    padding: 0.5rem 0.875rem;
    color: var(--tv-primary);
    border: 1px solid rgba(var(--tv-primary-rgb), 0.45);
    background: var(--tv-surface);
}

.tv-theme .btn-outline-primary:hover {
    background: var(--tv-primary-soft);
    color: var(--tv-primary-on-soft, var(--tv-primary-deep));
    border-color: var(--tv-primary);
}

.tv-theme .btn-outline-primary:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 2px var(--tv-bg-app),
        0 0 0 4px rgba(var(--tv-primary-rgb), 0.35);
}

html[data-theme="dark"] .tv-theme .btn-outline-primary:hover {
    color: var(--tv-text);
}

.tv-theme .btn-outline-secondary {
    border-radius: var(--tv-radius-md);
    border-color: var(--tv-border-strong);
    color: var(--tv-text-secondary);
    font-weight: 400;
    font-size: 13px;
    padding: 0.5rem 0.875rem;
    background: var(--tv-surface);
}

.tv-theme .btn-outline-secondary:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-text);
    border-color: var(--tv-border-strong);
}

.tv-theme .btn-secondary {
    background: var(--tv-bg-muted);
    border-color: var(--tv-border-strong);
    color: var(--tv-text-secondary);
    border-radius: var(--tv-radius-md);
    font-weight: 500;
    font-size: 13px;
}

.tv-theme .btn-secondary:hover {
    background: var(--tv-border-subtle);
    color: var(--tv-text);
    border-color: var(--tv-border-strong);
}

.tv-theme .dropdown-menu {
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-md);
    box-shadow: var(--tv-shadow-md);
    background: var(--tv-surface);
    padding: 0.4rem;
}

.tv-theme .dropdown-item {
    color: var(--tv-text);
    border-radius: var(--tv-radius-sm);
    padding: 0.45rem 0.75rem;
    font-weight: 500;
}

.tv-theme .dropdown-item:hover {
    background: var(--tv-primary-soft);
    color: var(--tv-primary-deep);
}

html[data-theme="dark"] .tv-theme .dropdown-item:hover {
    color: var(--tv-primary);
}

/* ----- Guest / login ----- */
.tv-main--guest .tv-page-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: calc(100vh - var(--tv-topbar-height));
}

/* Guest body was horizontal flex (default row): the nested Bootstrap .row collapsed to a narrow strip. */
.tv-main--guest .tv-page-wrap > .tv-page-content-shell > .row {
    width: 100%;
    max-width: min(96vw, 56rem);
    margin-inline: auto;
    justify-content: center;
}

.tv-login-card {
    width: 100%;
    max-width: min(calc(96vw * 0.7), calc(44rem * 0.7));
    margin-left: auto;
    margin-right: auto;
    padding: 2.75rem clamp(1.5rem, 4vw, 3rem);
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--tv-shadow-md);
}

.tv-login-card .tv-page-title {
    font-size: clamp(1.5rem, 2.5vw, 1.85rem);
}

.tv-login-card .form-label {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.tv-login-card .form-control {
    padding: 0.85rem 1.15rem;
    font-size: 1rem;
    min-height: 3rem;
}

.tv-login-card .btn-primary {
    min-height: 3rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ----- Utilities ----- */
.tv-link {
    color: var(--tv-link);
    text-decoration: none;
    font-weight: 600;
}

.tv-link:hover {
    text-decoration: underline;
}

.tv-muted {
    color: var(--tv-text-muted);
}

.tv-price-text {
    font-weight: 700;
    color: var(--tv-price);
    letter-spacing: -0.03em;
}

.tv-divider-fade {
    height: 1px;
    margin: 1rem 0;
    background: linear-gradient(
        90deg,
        transparent,
        var(--tv-divider),
        transparent
    );
}

/* ----- MetricFlow: Bootstrap surfaces ----- */
.tv-theme .card {
    background: var(--tv-surface);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    box-shadow: var(--tv-card-shadow);
}

.tv-theme .card.shadow-sm {
    box-shadow: var(--tv-card-shadow) !important;
}

.tv-theme .card-header {
    padding: 0.75rem 1.25rem;
    font-size: 13px;
    font-weight: 600;
    color: var(--tv-text-secondary);
    background: var(--tv-bg-muted);
    border-bottom: 1px solid var(--tv-border);
}

.tv-theme .card-body {
    padding: 1.25rem 1.5rem;
    font-size: 14px;
    color: var(--tv-text);
}

.tv-theme main > h1:first-child:not(.tv-page-title) {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--tv-text);
    margin-bottom: 1.25rem;
}

.tv-theme main > h2,
.tv-theme main h2.h3,
.tv-theme main h2.h4,
.tv-theme main h2.h5,
.tv-theme main h2.h6 {
    font-size: 16px;
    font-weight: 600;
    color: var(--tv-text);
    line-height: 1.4;
}

.tv-theme .alert {
    border-radius: var(--tv-radius-md);
    font-size: 13px;
    border-width: 1px;
}

.tv-theme .alert-success {
    background: var(--tv-success-soft);
    color: var(--tv-success-text);
    border-color: rgba(22, 101, 52, 0.2);
}

html[data-theme="dark"] .tv-theme .alert-success {
    color: var(--tv-success-text);
    border-color: rgba(74, 222, 128, 0.25);
}

.tv-theme .alert-info {
    background: rgba(var(--tv-primary-rgb), 0.08);
    color: var(--tv-primary-deep);
    border-color: rgba(var(--tv-primary-rgb), 0.22);
}

html[data-theme="dark"] .tv-theme .alert-info {
    background: rgba(var(--tv-primary-rgb), 0.12);
    color: var(--tv-primary-on-soft);
    border-color: rgba(var(--tv-primary-rgb), 0.28);
}

.tv-theme .alert-danger {
    background: var(--tv-danger-soft);
    color: var(--tv-danger-text);
    border-color: rgba(239, 68, 68, 0.25);
}

.tv-theme .alert-light.border {
    background: var(--tv-surface);
    border-color: var(--tv-border) !important;
    color: var(--tv-text-secondary);
}

.tv-theme .pagination .page-link {
    border-radius: var(--tv-radius-sm);
    border-color: var(--tv-border);
    color: var(--tv-text-secondary);
    font-size: 13px;
}

.tv-theme .pagination .page-item.active .page-link {
    background: var(--tv-primary);
    border-color: var(--tv-primary);
    color: #fff;
}

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

.tv-theme .form-check-input:focus {
    border-color: var(--tv-primary);
    box-shadow: 0 0 0 3px rgba(var(--tv-primary-rgb), 0.12);
}

.tv-action-group {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

/* Icon-only view (eye) ? pairs with row ? menu; label in .visually-hidden for a11y */
a.tv-row-view-btn.tv-row-view-btn--icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.35rem;
  border-radius: var(--tv-radius-md, 8px);
  border: 1px solid var(--tv-border, #e2e8f0);
  background: var(--tv-surface, #ffffff);
  color: var(--tv-text-secondary, #475569);
  font-size: 0;
  line-height: 0;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition:
    background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.15s ease,
    border-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.12s cubic-bezier(0.4, 0, 0.2, 1);
}

a.tv-row-view-btn.tv-row-view-btn--icon-only:hover {
  background: var(--tv-bg-muted, #f8fafc);
  color: var(--tv-text, #1e293b);
  border-color: color-mix(in srgb, var(--tv-primary, #2563eb) 28%, var(--tv-border, #e2e8f0) 72%);
}

a.tv-row-view-btn.tv-row-view-btn--icon-only:active {
  transform: translateY(1px);
}

a.tv-row-view-btn.tv-row-view-btn--icon-only:focus-visible {
  outline: none;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 0 0 3px rgba(var(--tv-primary-rgb, 37, 99, 235), 0.28);
}

.tv-row-view-btn--icon-only .tv-row-view-btn__icon {
  flex-shrink: 0;
  opacity: 0.92;
}

html[data-theme="dark"] a.tv-row-view-btn.tv-row-view-btn--icon-only {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--tv-surface, #1e293b);
  color: var(--tv-text-secondary, #cbd5e1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] a.tv-row-view-btn.tv-row-view-btn--icon-only:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--tv-text, #f1f5f9);
}

html[data-theme="dark"] a.tv-row-view-btn.tv-row-view-btn--icon-only:focus-visible {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 0 0 3px rgba(var(--tv-primary-rgb, 96, 165, 250), 0.32);
}

a.tv-action-icon,
button.tv-action-icon {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--tv-radius-md, 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    text-decoration: none;
    padding: 0;
    transition:
        background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.12s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.15s ease;
}

a.tv-action-icon:focus-visible,
button.tv-action-icon:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--tv-surface, #fff), 0 0 0 4px rgba(var(--tv-primary-rgb), 0.35);
}

a.tv-action-icon:hover,
button.tv-action-icon:hover {
    opacity: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

a.tv-action-icon:active,
button.tv-action-icon:active {
    transform: scale(0.94);
    box-shadow: none;
}

a.tv-action-icon svg,
button.tv-action-icon svg,
a.tv-action-icon i,
button.tv-action-icon i {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

a.tv-action-icon.tv-action-icon--view {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    border: 1px solid var(--tv-border, #e2e8f0);
    background: var(--tv-surface, #ffffff);
    color: var(--tv-text-secondary, #475569);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

a.tv-action-icon.tv-action-icon--view:hover {
    background: var(--tv-bg-muted, #f8fafc);
    color: var(--tv-text, #1e293b);
    border-color: color-mix(in srgb, var(--tv-primary, #2563eb) 28%, var(--tv-border, #e2e8f0) 72%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] a.tv-action-icon.tv-action-icon--view {
    border-color: rgba(255, 255, 255, 0.12);
    background: var(--tv-surface, #1e293b);
    color: var(--tv-text-secondary, #cbd5e1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] a.tv-action-icon.tv-action-icon--view:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.22);
    color: var(--tv-text, #f1f5f9);
}

a.tv-action-icon.tv-action-icon--view svg,
a.tv-action-icon.tv-action-icon--view i {
    width: 18px;
    height: 18px;
}

.tv-action-icon--edit {
    background: color-mix(in srgb, var(--tv-text-secondary) 9%, var(--tv-surface, #fff));
    color: var(--tv-text-secondary, #64748b);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

.tv-action-icon--delete {
    background: color-mix(in srgb, var(--tv-danger, #ef4444) 12%, var(--tv-surface, #fff));
    color: var(--tv-danger, #dc2626);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

.tv-action-icon--approve {
    background: color-mix(in srgb, var(--tv-success, #22c55e) 12%, var(--tv-surface, #fff));
    color: var(--tv-success-text, #15803d);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

html[data-theme="dark"] .tv-action-icon--approve {
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

html[data-theme="dark"] .tv-action-icon--edit {
    background: rgba(148, 163, 184, 0.14);
    color: #cbd5e1;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

html[data-theme="dark"] .tv-action-icon--delete {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

html[data-theme="dark"] a.tv-action-icon:focus-visible,
html[data-theme="dark"] button.tv-action-icon:focus-visible {
    box-shadow: 0 0 0 2px var(--tv-slate-900), 0 0 0 4px rgba(var(--tv-primary-rgb), 0.45);
}

.tv-badge-paid {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    background: #dcfce7;
    color: #166534;
}

.tv-badge-pending {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    background: #fff7ed;
    color: #f97316;
}

html[data-theme="dark"] .tv-badge-paid {
    background: rgba(74, 222, 128, 0.14);
    color: var(--tv-success-text);
}

html[data-theme="dark"] .tv-badge-pending {
    background: rgba(251, 146, 60, 0.14);
    color: var(--tv-accent-orange-hover);
}

.tv-theme .text-danger,
.tv-theme .field-validation-error,
.tv-theme .validation-summary-errors {
    color: var(--tv-danger) !important;
}

.tv-theme .form-control.input-validation-error,
.tv-theme .form-select.input-validation-error {
    border-color: var(--tv-danger);
}

.tv-theme .form-control.input-validation-error:focus {
    border-color: var(--tv-danger);
    box-shadow:
        var(--tv-shadow-inset-input),
        0 0 0 3px var(--tv-danger-soft);
}

.tv-theme .table a:not(.btn):not(.tv-action-icon):hover {
    text-decoration: underline;
}

.tv-theme .modal-content {
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    box-shadow: var(--tv-shadow-md);
    background: var(--tv-surface);
}

.tv-theme .modal-header,
.tv-theme .modal-footer {
    border-color: var(--tv-border);
}

.tv-theme .modal-header {
    background: var(--tv-bg-muted);
}

.tv-theme .modal-title {
    color: var(--tv-text);
}

.tv-theme .modal-body {
    color: var(--tv-text);
}

.tv-theme .text-muted {
    color: var(--tv-text-muted) !important;
}

.tv-theme .list-group {
    border-radius: var(--tv-radius-md);
    overflow: hidden;
    border: 1px solid var(--tv-border);
    box-shadow: var(--tv-card-shadow);
}

.tv-theme .list-group-item {
    background: var(--tv-surface);
    color: var(--tv-text);
    border-color: var(--tv-border);
    padding: 0.75rem 1.25rem;
    font-size: 14px;
}

.tv-theme .list-group-item-action {
    color: var(--tv-link);
    font-weight: 500;
}

.tv-theme .list-group-item-action:hover {
    background: var(--tv-bg-muted);
    color: var(--tv-primary-deep);
}

html[data-theme="dark"] .tv-theme .list-group-item-action:hover {
    color: var(--tv-primary);
}

.tv-card.p-0 > .list-group.list-group-flush .list-group-item {
    border-inline: none;
}

.tv-card.p-0 > .list-group.list-group-flush .list-group-item:first-child {
    border-top: none;
}

.tv-card.p-0 > .list-group.list-group-flush .list-group-item:last-child {
    border-bottom: none;
}

/* ???????????????????????????????????????????????????????????????????????????
   Enterprise app tokens (--app-*): tables, KPI cards, toolbars, shadows.
   Aligned with MetricFlow --tv-* teal brand (single visual system).
   Activated when <html data-ui-brand="enterprise"> (see _Layout.cshtml).
   ??????????????????????????????????????????????????????????????????????????? */

:root {
    --app-surface: #f2f8f5;
    --app-surface-deep: #e8f2ed;
    --app-toolbar-border: #cfe6dc;
    --app-card-shadow: 0 10px 40px -14px rgba(10, 90, 70, 0.12);
    --app-loaded: #0d9488;
    --app-loaded-hover: #0f766e;
    /* Semantic aliases ? prefer --tv-primary* on themed pages; kept for legacy refs */
    --app-primary: #0a9c76;
    --app-primary-hover: #088f6c;
    --app-primary-muted: #ecfdf5;
    --app-primary-fg: #ffffff;
    --app-header-1: #0f172a;
    --app-header-2: #134e4a;
    --app-header-3: #0a9c76;
    --app-btn-csv: #0f766e;
    --app-btn-csv-hover: #0d9488;
    --app-accent: #0e7490;
    --app-accent-hover: #155e75;
    --app-border: #c5d9d0;
    --app-border-strong: #7fb3a2;
    --app-table-outline: #8eb3a8;
    --app-table-stripe: var(--tv-table-stripe-even);
    --app-header-excel: #0a5c48;
    --app-header-csv: #115e59;
    --app-stat-blue-from: #065f46;
    --app-stat-blue-to: #0a9c76;
    --app-stat-warn-from: #9a3412;
    --app-stat-warn-to: #ea580c;
    --app-stat-ok-from: #047857;
    --app-stat-ok-to: #10b981;
    --app-stat-money-from: #3730a3;
    --app-stat-money-to: #6366f1;
    --app-empty-from: #ccfbf1;
    --app-empty-to: #99f6e4;
    --app-print-banner-border: #0d9488;
    --app-shadow-xs: 0 1px 2px -0.5px rgba(15, 23, 42, 0.06);
    --app-shadow-sm: 0 2px 8px -2px rgba(10, 90, 70, 0.08);
    --app-shadow-md: 0 8px 28px -6px rgba(8, 80, 60, 0.12);
    --app-shadow-lg: 0 16px 48px -12px rgba(15, 23, 42, 0.16);
    --app-backdrop: rgba(15, 23, 42, 0.45);
    --app-toolbar-bg: rgba(255, 255, 255, 0.92);
    --app-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --chart-parity-1: rgba(10, 156, 118, 0.72);
    --chart-parity-2: rgba(14, 165, 233, 0.65);
    --chart-parity-3: rgba(245, 158, 11, 0.6);
    --chart-parity-4: rgba(99, 102, 241, 0.58);
    --chart-parity-5: rgba(236, 72, 153, 0.58);
    --chart-parity-6: rgba(100, 116, 139, 0.58);
}

html[data-theme="dark"][data-ui-brand="enterprise"] {
    --app-surface: #121a19;
    --app-surface-deep: #0c1211;
    --app-toolbar-bg: rgba(18, 27, 26, 0.94);
    --app-toolbar-border: #2d3f3c;
    --app-primary-muted: rgba(45, 212, 191, 0.16);
    --app-table-stripe: rgba(18, 30, 28, 0.88);
    --app-card-shadow: 0 12px 40px -14px rgba(0, 0, 0, 0.55);
    --app-border: #334f47;
    --app-border-strong: #4a6b60;
    --app-table-outline: #3d5c52;
    /* Slate header band ? matches shell --tv-surface-elevated (not green sheet export) */
    --app-header-excel: #1c2333;
    --app-stat-blue-from: #134e40;
    --app-stat-blue-to: #14b8a6;
    --app-empty-from: rgba(45, 212, 191, 0.12);
    --app-empty-to: rgba(20, 184, 166, 0.08);
}

html[data-ui-brand="enterprise"] body.tv-theme {
    background-color: var(--app-surface);
    background-image:
        radial-gradient(
            ellipse 110% 70% at 50% -25%,
            rgba(var(--tv-primary-rgb), 0.1),
            transparent 52%
        ),
        linear-gradient(
            180deg,
            var(--app-surface) 0%,
            var(--app-surface-deep) 100%
        );
}

html[data-ui-brand="enterprise"]
    body.tv-theme
    .tv-page-wrap
    > .tv-page-content-shell
    > h1.tv-page-title:first-child,
html[data-ui-brand="enterprise"] .tv-page-title {
    font-family: var(--tv-font-display);
    letter-spacing: -0.03em;
}

/* KPI gradient cards (React StatCard pattern) */
.tv-stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
    border-radius: 1rem;
    padding: 1rem 1.1rem;
    min-height: 100%;
    color: #fff;
    box-shadow: var(--app-shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition:
        box-shadow var(--app-transition-fast),
        transform var(--app-transition-fast);
}

@media (prefers-reduced-motion: reduce) {
    .tv-stat-card {
        transition: none;
    }
}

.tv-stat-card:hover {
    box-shadow: var(--app-shadow-lg);
    transform: translateY(-1px);
}

.tv-stat-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    position: relative;
    z-index: 2;
}

.tv-stat-card__icon-wrap {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tv-stat-card__icon-wrap svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor;
    fill: none;
}

.tv-stat-card__text {
    text-align: end;
    min-width: 0;
}

.tv-stat-card__value {
    font-size: clamp(1.35rem, 2.8vw, 2rem);
    font-weight: 300;
    line-height: 1.1;
    margin-bottom: 0.25rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.tv-stat-card__value--emphasis {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tv-stat-card__label {
    font-size: 0.875rem;
    opacity: 0.88;
}

.tv-stat-card__sub {
    font-size: 0.75rem;
    opacity: 0.62;
    margin-top: 0.125rem;
}

.tv-stat-card__deco {
    position: absolute;
    left: -0.75rem;
    bottom: -0.75rem;
    opacity: 0.1;
    transform: scale(2.5);
    pointer-events: none;
    z-index: 1;
}

.tv-stat-card--blue {
    background: linear-gradient(
        135deg,
        var(--app-stat-blue-from),
        var(--app-stat-blue-to)
    );
}

.tv-stat-card--warn {
    background: linear-gradient(
        135deg,
        var(--app-stat-warn-from),
        var(--app-stat-warn-to)
    );
}

.tv-stat-card--ok {
    background: linear-gradient(
        135deg,
        var(--app-stat-ok-from),
        var(--app-stat-ok-to)
    );
}

.tv-stat-card--money {
    background: linear-gradient(
        135deg,
        var(--app-stat-money-from),
        var(--app-stat-money-to)
    );
}

/* Elevated surface card (toolbar / filters) */
.tv-card-surface {
    border-radius: 1.35rem;
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--app-card-shadow);
    backdrop-filter: blur(2px);
}

html[data-theme="dark"] .tv-card-surface {
    background: var(--tv-surface-elevated);
}

/* Enterprise data table ? same visual language as React DataTable / export tables */
/* (--app-table-row-hover merged here from former stub above) */
.tv-table-enterprise {
    --app-table-row-hover: rgba(var(--tv-primary-rgb), 0.04);
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    border: 1px solid var(--app-table-outline);
}

.tv-table-enterprise thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--tv-surface) 45%, var(--tv-bg-muted) 55%) 0%,
        color-mix(in srgb, var(--tv-surface) 18%, var(--tv-bg-muted) 82%) 100%
    );
    color: var(--tv-text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: 0.04em;
    line-height: 1.35;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--tv-border);
    border-bottom: 1px solid var(--tv-border);
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.tv-table-enterprise tbody tr:nth-child(even) {
    background: var(--app-table-stripe);
}

.tv-table-enterprise tbody tr:hover {
    background: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .tv-table-enterprise tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .tv-table-enterprise thead th {
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--tv-surface-elevated) 94%, var(--tv-primary) 6%) 0%,
        color-mix(in srgb, var(--tv-surface-elevated) 82%, var(--tv-primary) 12%) 100%
    );
    color: color-mix(in srgb, var(--tv-text-secondary) 78%, var(--tv-text) 22%);
    border-color: var(--tv-border-strong);
    border-bottom-color: var(--tv-border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"][data-ui-brand="enterprise"] .tv-table-enterprise thead th {
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--tv-surface-elevated) 92%, var(--tv-primary) 8%) 0%,
        color-mix(in srgb, var(--tv-surface-elevated) 78%, var(--tv-primary) 14%) 100%
    );
    color: color-mix(in srgb, var(--tv-text-secondary) 72%, var(--tv-text) 28%);
}

.tv-table-enterprise tbody td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--app-border);
    vertical-align: middle;
}

.tv-table-enterprise-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: min(72vh, calc(100vh - 13rem));
    border-radius: var(--tv-radius-md);
    border: 1px solid var(--app-table-outline);
    background: var(--tv-surface);
    box-shadow: var(--tv-card-shadow);
}

/* Enterprise table ? light shell (neutral header; workspace / forms / attachments). */
.tv-table-enterprise.tv-table-enterprise--light {
    border-color: var(--tv-border);
}

.tv-table-enterprise.tv-table-enterprise--light thead th {
    background: color-mix(in srgb, var(--tv-bg-muted) 88%, var(--tv-surface) 12%);
    color: var(--tv-text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    padding: 0.55rem 0.65rem;
    border: none;
    border-inline-end: 1px solid var(--tv-border);
    border-bottom: 2px solid var(--tv-border);
    box-shadow: none;
    white-space: nowrap;
}

.tv-table-enterprise.tv-table-enterprise--light thead th:last-child {
    border-inline-end: none;
}

html[data-theme="dark"] .tv-table-enterprise.tv-table-enterprise--light thead th {
    background: color-mix(in srgb, var(--tv-bg-muted) 72%, var(--tv-surface-raised) 28%);
    color: var(--tv-text-secondary);
    border-inline-end-color: var(--tv-border);
    border-bottom-color: var(--tv-border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"][data-ui-brand="enterprise"]
    .tv-table-enterprise.tv-table-enterprise--light
    thead
    th {
    background: color-mix(in srgb, var(--tv-bg-muted) 60%, var(--tv-surface-elevated) 40%);
    color: var(--tv-text-secondary);
    border-inline-end-color: var(--tv-border);
    border-bottom-color: var(--tv-border-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tv-table-enterprise.tv-table-enterprise--light tbody tr:nth-child(even) {
    background: var(--tv-table-stripe-even);
}

html[data-theme="dark"] .tv-table-enterprise.tv-table-enterprise--light tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.tv-table-enterprise.tv-table-enterprise--light tbody tr:hover {
    background: rgba(148, 163, 184, 0.1);
}

html[data-theme="dark"] .tv-table-enterprise.tv-table-enterprise--light tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.tv-table-enterprise.tv-table-enterprise--light tbody td {
    border-color: var(--tv-border);
}

.tv-table-enterprise-wrap.tv-table-enterprise-wrap--light {
    border-color: var(--tv-border);
    box-shadow: var(--tv-card-shadow);
}

/* Bootstrap primary ? same as shell brand tokens */
html[data-ui-brand="enterprise"] .tv-theme .btn-primary {
    --bs-btn-bg: var(--tv-primary);
    --bs-btn-border-color: var(--tv-primary);
    --bs-btn-hover-bg: var(--tv-primary-hover);
    --bs-btn-hover-border-color: var(--tv-primary-hover);
    --bs-btn-active-bg: var(--tv-primary-deep);
    --bs-btn-active-border-color: var(--tv-primary-deep);
}

html[data-ui-brand="enterprise"] .tv-theme .btn-outline-primary {
    --bs-btn-color: var(--tv-primary);
    --bs-btn-border-color: rgba(var(--tv-primary-rgb), 0.45);
    --bs-btn-hover-bg: var(--tv-primary-soft);
    --bs-btn-hover-border-color: var(--tv-primary);
}

/* ----- Empty State Component ----- */
.tv-empty-state {
    padding: 4rem 2rem;
    text-align: center;
    background: var(--tv-surface);
    border: 2px dashed var(--tv-border);
    border-radius: var(--tv-radius);
}
.tv-empty-state__icon {
    font-size: 3rem;
    color: var(--tv-text-hint);
    margin-bottom: 1.5rem;
    opacity: 0.5;
}
.tv-empty-state__title {
    font-weight: 600;
    color: var(--tv-text-secondary);
    margin-bottom: 0.5rem;
}

/* ?? Shared section / card title rhythm (use on Razor sections for consistency) ?? */
.tv-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--tv-space-4, 1rem);
    margin-bottom: var(--tv-space-4, 1rem);
    padding-bottom: var(--tv-space-3, 0.75rem);
    border-bottom: 1px solid var(--tv-border);
}

.tv-section-header__title {
    font-family: var(--tv-font-display);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--tv-text);
    margin: 0;
}

.tv-section-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* ?? Compact page header ? workspace / toolbar mode ?????????????????????????
 * Applied via PageHeaderViewModel.Compact = true ? tv-page-header-shell--compact.
 * Reduces title size and gaps so it sits comfortably inside form-heavy workflow
 * pages (e.g. Purchasing Lines / Serials / Devices).
 * ???????????????????????????????????????????????????????????????????????????? */
.tv-page-header-shell--compact {
    gap: var(--tv-space-3, 0.75rem);
    margin-bottom: var(--tv-space-4, 1rem);
    padding-bottom: var(--tv-space-3, 0.75rem);
}

.tv-page-header-shell--compact .tv-page-title {
    font-size: var(--tv-pw-lines-doc-title-size, 1rem);
    font-weight: var(--tv-pw-lines-doc-title-weight, 600);
    letter-spacing: var(--tv-pw-lines-doc-title-tracking, -0.01em);
    line-height: var(--tv-pw-lines-doc-title-leading, 1.4);
}

.tv-page-header-shell--compact .tv-page-sub {
    font-size: 0.8125rem;
}

/* ?? Report Card Grid ?? */
.tv-report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.tv-report-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--tv-radius);
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--tv-card-shadow);
    text-decoration: none;
    color: var(--tv-text);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.tv-report-card:hover {
    border-color: rgba(var(--tv-primary-rgb), 0.35);
    box-shadow: var(--tv-shadow-md);
    transform: translateY(-2px);
    color: var(--tv-text);
    text-decoration: none;
}

.tv-report-card__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--tv-radius-md);
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.tv-report-card--danger .tv-report-card__icon {
    background: var(--tv-danger-soft);
    color: var(--tv-danger);
}

.tv-report-card--warning .tv-report-card__icon {
    background: var(--tv-warning-soft);
    color: var(--tv-warning);
}

.tv-report-card--accent .tv-report-card__icon {
    background: var(--tv-accent-orange-soft);
    color: var(--tv-accent-orange);
}

.tv-report-card--success .tv-report-card__icon {
    background: var(--tv-success-soft);
    color: var(--tv-success);
}

.tv-report-card--info .tv-report-card__icon {
    background: var(--tv-info-soft);
    color: var(--tv-info);
}

.tv-report-card--money .tv-report-card__icon {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    color: #92400e;
}

html[data-theme="dark"] .tv-report-card--money .tv-report-card__icon {
    background: rgba(251, 191, 36, 0.15);
    color: var(--tv-warning);
}

.tv-report-card:hover .tv-report-card__icon {
    background: var(--tv-primary);
    color: var(--tv-on-primary);
}

.tv-report-card__content {
    flex: 1;
    min-width: 0;
}

.tv-report-card__title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--tv-text);
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.tv-report-card__desc {
    font-size: 0.8125rem;
    color: var(--tv-text-muted);
    margin: 0;
    line-height: 1.5;
}

.tv-report-card__arrow {
    color: var(--tv-text-hint);
    flex-shrink: 0;
    margin-top: 0.15rem;
    transition:
        transform 0.2s ease,
        color 0.2s ease;
}

.tv-report-card:hover .tv-report-card__arrow {
    transform: translateX(3px);
    color: var(--tv-primary);
}

[dir="rtl"] .tv-report-card:hover .tv-report-card__arrow {
    transform: translateX(-3px);
}

/* ?? StatCard Premium ? extracted from inline style block ?? */
.tv-stat-card-premium {
    position: relative;
    border-radius: var(--tv-radius-xl, 16px);
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--tv-card-shadow);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tv-stat-card-premium:hover {
    box-shadow: var(--tv-shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.08));
    transform: translateY(-4px);
    border-color: rgba(var(--tv-primary-rgb), 0.3);
}

.tv-stat-card-premium__body {
    padding: 1.25rem 1.5rem;
}

.tv-stat-card-premium__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.tv-stat-card-premium__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--tv-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
}

.tv-stat-card-premium__badge {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: var(--tv-radius-pill);
    background: var(--tv-bg-muted);
    color: var(--tv-text-muted);
}

.tv-stat-card-premium__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tv-text-muted);
    margin: 0 0 0.25rem 0;
}

.tv-stat-card-premium__value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--tv-text);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.04em;
}

.tv-stat-card-premium__value--lg {
    font-size: 2.25rem;
}

.tv-stat-card-premium__prefix,
.tv-stat-card-premium__suffix {
    font-size: 1rem;
    font-weight: 600;
    color: var(--tv-text-muted);
}

.tv-stat-card-premium__subtext {
    font-size: 0.75rem;
    color: var(--tv-text-muted);
    margin: 0.5rem 0 0 0;
}

.tv-stat-card-premium__trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--tv-radius-sm);
}

.tv-trend--up {
    color: var(--tv-success);
    background: var(--tv-success-soft);
}

.tv-trend--down {
    color: var(--tv-danger);
    background: var(--tv-danger-soft);
}

.tv-trend--neutral {
    color: var(--tv-text-muted);
    background: var(--tv-bg-muted);
}

.tv-stat-card-premium__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0;
    background: var(--tv-bg-muted);
    color: var(--tv-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.tv-stat-card-premium__link:hover {
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
    text-decoration: none;
}

.tv-stat-card-premium--blue .tv-stat-card-premium__icon {
    background: var(--tv-info-soft);
    color: var(--tv-info);
}

.tv-stat-card-premium--ok .tv-stat-card-premium__icon {
    background: var(--tv-success-soft);
    color: var(--tv-success);
}

.tv-stat-card-premium--money .tv-stat-card-premium__icon {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    color: #92400e;
}

html[data-theme="dark"]
    .tv-stat-card-premium--money
    .tv-stat-card-premium__icon {
    background: rgba(251, 191, 36, 0.15);
    color: var(--tv-warning);
}

.tv-stat-card-premium--warn .tv-stat-card-premium__icon {
    background: var(--tv-warning-soft);
    color: var(--tv-warning);
}

.tv-stat-card-premium--danger .tv-stat-card-premium__icon {
    background: var(--tv-danger-soft);
    color: var(--tv-danger);
}

/* ?? Key-Value Display (readonly data presentation) ?? */
.tv-kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem 1.5rem;
}

.tv-kv-item {
}

.tv-kv-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tv-text-muted);
    margin-bottom: 0.25rem;
}

.tv-kv-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--tv-text);
    word-break: break-word;
}

.tv-kv-value--mono {
    font-family: var(--tv-font-mono, ui-monospace, monospace);
    font-size: 0.875rem;
    letter-spacing: 0.02em;
}

.tv-kv-value--empty {
    color: var(--tv-text-hint);
    font-style: italic;
}

/* ?? Quick Actions Grid ?? */
.tv-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tv-quick-actions--group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tv-quick-actions__group-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--tv-text-muted);
    margin-bottom: 0.375rem;
}

/* ?? Stat Card (card-surface variant, used by _StatCard.cshtml) ??
   These rules intentionally override the gradient-based .tv-stat-card
   defined earlier in this file for the new card-surface design. */
.tv-stat-card {
    position: relative;
    border-radius: var(--tv-radius-lg);
    border: 1px solid var(--tv-border);
    background: var(--tv-surface);
    box-shadow: var(--tv-shadow-sm);
    overflow: hidden;
    transition: all var(--tv-transition-duration) var(--tv-transition-timing);
}

.tv-card-elevated:hover {
    box-shadow: var(--tv-shadow-md);
    transform: translateY(-2px);
    border-color: rgba(var(--tv-primary-rgb), 0.2);
}

.tv-stat-card__body {
    padding: 1.25rem 1.5rem;
}

.tv-stat-card__top {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.tv-stat-card__icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: var(--tv-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--tv-primary-soft);
}

.tv-stat-card--blue .tv-stat-card__icon-wrap {
    background: rgba(var(--tv-primary-rgb), 0.1);
}

.tv-stat-card--ok .tv-stat-card__icon-wrap {
    background: var(--tv-success-soft);
}

.tv-stat-card--money .tv-stat-card__icon-wrap {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
}

.tv-stat-card--warn .tv-stat-card__icon-wrap {
    background: var(--tv-warning-soft);
}

.tv-stat-card--danger .tv-stat-card__icon-wrap {
    background: var(--tv-danger-soft);
}

.tv-stat-card__text {
    flex: 1;
    min-width: 0;
}

.tv-stat-card__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--tv-text-muted);
    margin-top: 0.25rem;
}

.tv-stat-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tv-text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.tv-stat-card__value--emphasis {
    font-size: 2rem;
}

.tv-stat-card__prefix,
.tv-stat-card__suffix {
    font-size: 1rem;
    font-weight: 600;
    color: var(--tv-text-muted);
}

.tv-stat-card__sub {
    font-size: 0.75rem;
    color: var(--tv-text-muted);
    margin-top: 0.375rem;
}

.tv-stat-card__trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.625rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--tv-radius-sm);
}

.tv-stat-card__trend--up {
    color: var(--tv-success);
    background: var(--tv-success-soft);
}

.tv-stat-card__trend--down {
    color: var(--tv-danger);
    background: var(--tv-danger-soft);
}

.tv-stat-card__trend--neutral {
    color: var(--tv-text-muted);
    background: var(--tv-bg-muted);
}

.tv-stat-card__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 1rem -1.5rem -1.25rem;
    background: var(--tv-bg-muted);
    color: var(--tv-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.tv-stat-card__link:hover {
    background: var(--tv-primary-soft);
    color: var(--tv-primary);
}

/* Accounting operations ? subtle card accent by kind (expense vs income) */
.tv-card.tv-card--accounting-expense[data-accounting-kind="expense"] {
    border-inline-start: 3px solid var(--tv-warning, #ca8a04);
}

.tv-card.tv-card--accounting-income[data-accounting-kind="income"] {
    border-inline-start: 3px solid var(--tv-success, #16a34a);
}

[data-accounting-kind="income"].tv-card:not(.tv-card--accounting-income) {
    border-top: 2px solid color-mix(in srgb, var(--tv-success, #16a34a) 35%, transparent);
}

/* ??? --db-* token aliases (dashboard.css consumes these) ????????????????
 * Both light and dark themes are covered by the html[data-theme] blocks
 * above; these aliases bridge the dashboard prefix to the global tv-* set.
 * ???????????????????????????????????????????????????????????????????????? */
html[data-theme="dark"] {
    --db-bg:            #0f1117;
    --db-surface:       #171923;
    --db-surface-2:     #1e2230;
    --db-surface-hover: #252a3d;
    --db-border:        rgba(255,255,255,0.08);
    --db-border-strong: rgba(255,255,255,0.12);
    --db-border-accent: rgba(99,179,237,0.35);
    --db-text-primary:  #f0f4ff;
    --db-text-muted:    #94a3b8;
    --db-text-hint:     #64748b;
    --db-cyan:          #63b3ed;
    --db-cyan-glow:     rgba(99,179,237,0.18);
    --db-gold:          #f6c90e;
    --db-gold-glow:     rgba(246,201,14,0.16);
    --db-green:         #48bb78;
    --db-green-glow:    rgba(72,187,120,0.16);
    --db-red:           #fc8181;
    --db-red-glow:      rgba(252,129,129,0.16);
    --db-amber:         #f6ad55;
    --db-amber-glow:    rgba(246,173,85,0.16);
    --db-purple:        #b794f4;
    --db-purple-glow:   rgba(183,148,244,0.16);
    --db-radius-card:   16px;
    --db-radius-inner:  10px;
    --db-shadow-card:   0 4px 24px rgba(0,0,0,0.42);
    --db-shadow-lift:   0 12px 40px rgba(0,0,0,0.5);
    --db-transition:    200ms cubic-bezier(0.4,0,0.2,1);
    --db-focus-ring:    0 0 0 3px rgba(99,179,237,0.45);
    --db-space-1: 4px;   --db-space-2: 8px;   --db-space-3: 12px;
    --db-space-4: 16px;  --db-space-5: 20px;  --db-space-6: 24px;
    --db-space-8: 32px;
    --db-content-max:  1440px;
    --db-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="light"] {
    --db-bg:            #f1f5f9;
    --db-surface:       #ffffff;
    --db-surface-2:     #f8fafc;
    --db-surface-hover: #f1f5f9;
    --db-border:        rgba(15,23,42,0.08);
    --db-border-strong: rgba(15,23,42,0.12);
    --db-border-accent: rgba(58,90,156,0.22);
    --db-text-primary:  #0f172a;
    --db-text-muted:    #475569;
    --db-text-hint:     #94a3b8;
    --db-cyan:          #3a5a9c;
    --db-cyan-glow:     rgba(58,90,156,0.12);
    --db-gold:          #b45309;
    --db-gold-glow:     rgba(180,83,9,0.12);
    --db-green:         #15803d;
    --db-green-glow:    rgba(21,128,61,0.12);
    --db-red:           #dc2626;
    --db-red-glow:      rgba(220,38,38,0.12);
    --db-amber:         #d97706;
    --db-amber-glow:    rgba(217,119,6,0.12);
    --db-purple:        #6d28d9;
    --db-purple-glow:   rgba(109,40,217,0.12);
    --db-radius-card:   16px;
    --db-radius-inner:  10px;
    --db-shadow-card:   0 1px 3px rgba(15,23,42,0.06), 0 4px 20px rgba(15,23,42,0.06);
    --db-shadow-lift:   0 12px 32px rgba(15,23,42,0.1);
    --db-transition:    200ms cubic-bezier(0.4,0,0.2,1);
    --db-focus-ring:    0 0 0 3px rgba(58,90,156,0.35);
    --db-space-1: 4px;   --db-space-2: 8px;   --db-space-3: 12px;
    --db-space-4: 16px;  --db-space-5: 20px;  --db-space-6: 24px;
    --db-space-8: 32px;
    --db-content-max:  1440px;
    --db-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ??? Animate.css integration ? speed overrides + reduced-motion guard ??????
 * animate.css is loaded in _Layout.cshtml from CDN (~2.5 kB gzip).
 * We speed up the page-level fadeIn so it feels snappy, not slow.
 * Uses CSS custom property that animate.css v4 reads.
 * ???????????????????????????????????????????????????????????????????????????*/
:root {
    /* Page-level swap fade: quick (280ms feels instant, not jarring) */
    --animate-duration: 280ms;
}

/* Honour prefers-reduced-motion ? disable all animate.css animations */
@media (prefers-reduced-motion: reduce) {
    .animate__animated {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

/* Pulse on confirm dialog icon ? opt-in class usable in _ConfirmDialog */
.tv-confirm-icon--pulse {
    animation: pulse 0.6s ease-in-out;
}

/* ??? Table skeleton shimmer loader ???????????????????????????????????????
 * _TableSkeleton.cshtml renders this structure.
 * Visibility is controlled by toggling 'tv-tbl-skeleton--visible' on the
 * nearest .tv-card ancestor (done by tv-datatable.js on htmx:beforeRequest /
 * htmx:afterSettle and on DataTables draw.dt).
 * ??????????????????????????????????????????????????????????????????????????*/

/* Keyframe for the shimmer sweep */
@keyframes tv-shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* Shimmer gradient shared across all skeleton bars */
.tv-skeleton-bar {
    border-radius: var(--tv-radius-sm, 4px);
    background: linear-gradient(
        90deg,
        var(--tv-surface-overlay, #f1f5f9) 25%,
        var(--tv-surface-raised,  #e9eef4) 50%,
        var(--tv-surface-overlay, #f1f5f9) 75%
    );
    background-size: 200% 100%;
    animation: tv-shimmer 1.5s linear infinite;
    height: 14px;
    width: 70%;
}

[data-theme="dark"] .tv-skeleton-bar {
    background: linear-gradient(
        90deg,
        var(--tv-surface-overlay, #1e293b) 25%,
        var(--tv-surface-raised,  #273044) 50%,
        var(--tv-surface-overlay, #1e293b) 75%
    );
    background-size: 200% 100%;
}

@media (prefers-reduced-motion: reduce) {
    .tv-skeleton-bar { animation: none; }
}

/* Bar size variants */
.tv-skeleton-bar--avatar { height: 32px; width: 32px; border-radius: 50%; }
.tv-skeleton-bar--sub    { height: 10px; width: 55%; margin-top: 4px; }
.tv-skeleton-bar--pill   { height: 22px; width: 60%; border-radius: 999px; }
.tv-skeleton-bar--num    { height: 14px; width: 50%; }
.tv-skeleton-bar--icon   { height: 24px; width: 24px; border-radius: 4px; }
.tv-skeleton-bar--check  { height: 16px; width: 16px; border-radius: 3px; }

/* Skeleton table layout */
.tv-table-skeleton {
    display: none; /* hidden by default; shown via .tv-tbl-skeleton--visible */
    padding: 0 16px;
}

.tv-table-skeleton__header,
.tv-table-skeleton__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--tv-border-subtle, #f1f5f9);
}

.tv-table-skeleton__header {
    padding: 12px 0;
}

.tv-table-skeleton__header .tv-table-skeleton__cell {
    background: var(--tv-surface-overlay, #f1f5f9);
    border-radius: 4px;
    height: 10px;
}

/* Staggered fade-in per row */
.tv-table-skeleton__row {
    opacity: 0;
    animation: tv-skeleton-row-in 200ms ease both;
    animation-delay: calc(var(--tv-skeleton-row, 0) * 40ms);
}

@keyframes tv-skeleton-row-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .tv-table-skeleton__row { animation: none; opacity: 1; }
}

/* Column widths mirror common table proportions */
.tv-table-skeleton__cell--check   { width: 36px;  flex-shrink: 0; }
.tv-table-skeleton__cell--sm      { width: 80px;  flex-shrink: 0; }
.tv-table-skeleton__cell--md      { flex: 1; min-width: 100px; }
.tv-table-skeleton__cell--lg      { flex: 2; min-width: 140px; }
.tv-table-skeleton__cell--actions { width: 60px;  flex-shrink: 0; display: flex; justify-content: flex-end; }

/* Visibility toggle ? only when a real shimmer block exists (:has guards pages without _TableSkeleton). */
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .tv-table-skeleton {
    display: block;
}

.tv-tbl-skeleton--visible:has(.tv-table-skeleton) table.tv-dt {
    visibility: hidden;
    pointer-events: none;
    height: 0;
    overflow: hidden;
}

/* DataTables toolbar hidden only while shimmer is present */
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .dataTables_wrapper .dataTables_filter,
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .dataTables_wrapper .dataTables_length,
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .dataTables_wrapper .dt-buttons,
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .dataTables_wrapper .dataTables_info,
.tv-tbl-skeleton--visible:has(.tv-table-skeleton) .dataTables_wrapper .dataTables_paginate {
    visibility: hidden;
    pointer-events: none;
}

/* ----- UI utilities (enterprise design system) ----- */
.tv-icon-sm {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tv-icon-md {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.tv-ltr-isolate {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline-block;
}

.tv-card-body {
    padding: var(--tv-space-4);
}

[dir="rtl"] .btn.tv-btn-primary,
[dir="rtl"] .btn.tv-btn-secondary,
[dir="rtl"] .btn.tv-btn-ghost,
[dir="rtl"] .btn.tv-btn-danger {
    flex-direction: row-reverse;
}

/* Canonical buttons: btn + tv-btn-primary|secondary|ghost|danger|success */
/* Deprecated: db-pill-btn, ledger pill buttons on primary actions */

.tv-sticky-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-top: var(--tv-space-4);
    padding: var(--tv-space-3) var(--tv-space-4);
    background: var(--tv-surface, #fff);
    border: 1px solid var(--tv-border, #e2e8f0);
    border-radius: var(--tv-radius-lg, 8px);
    box-shadow: var(--app-shadow-sm);
}

.tv-detail-overview-grid {
    display: grid;
    gap: var(--tv-space-3);
}

@media (min-width: 768px) {
    .tv-detail-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
