/* ==========================================================================
   ERP & WMS Comprehensive Dark Theme System (dark-theme.css)
   Provides complete dark-mode coverage across all ERP pages, tables, modals,
   KPI cards, forms, sticky columns, scrollbars, and React/Vite apps.
   ========================================================================== */

html.dark, body.dark, html.dark body, html.dark body.full-width-body {
    color-scheme: dark;
    background-color: #0b1120 !important;
    color: #e2e8f0 !important;
}

:where(.dark, .dark *) #preloader {
    background-color: #0b1120 !important;
}

/* ==========================================================================
   0. Global Header, Logo, Navigation Menu & Theme Toggle
   ========================================================================== */
:where(.dark, .dark *) .full-width-nav-wrapper,
:where(.dark, .dark *) .full-width-nav-wrapper > div {
    background-color: #0f172a !important;
    border-color: #1e293b !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35) !important;
}

:where(.dark, .dark *) header img[alt="Site Logo"] {
    filter: invert(1) hue-rotate(180deg) brightness(1.45) contrast(1.05);
}

:where(.dark, .dark *) #theme-toggle,
:where(.dark, .dark *) .theme-toggle {
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #fbbf24 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

:where(.dark, .dark *) #theme-toggle:hover,
:where(.dark, .dark *) .theme-toggle:hover {
    background-color: #334155 !important;
    border-color: #475569 !important;
}

:where(.dark, .dark *) #menu-toggler {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45) !important;
}

:where(.dark, .dark *) #menu-toggler:hover {
    color: #60a5fa !important;
    background: #1e293b !important;
}

:where(.dark, .dark *) .main-menu { background-color: #1e293b !important; }
:where(.dark, .dark *) .header-inline-menu .main-menu { background-color: transparent !important; }
:where(.dark, .dark *) .paper { background-color: #cbd5e1 !important; }

:where(.dark, .dark *) .submenu {
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55) !important;
}

/* ==========================================================================
   0.1 Explicit dark:* Utility Fallbacks (Guaranteed Class-Mode Support)
   ========================================================================== */
:where(.dark, .dark *) :is(.dark\:bg-gray-900, .dark\:bg-slate-900) { background-color: #0f172a !important; }
:where(.dark, .dark *) :is(.dark\:bg-gray-800, .dark\:bg-slate-800) { background-color: #1e293b !important; }
:where(.dark, .dark *) :is(.dark\:bg-gray-700, .dark\:bg-slate-700) { background-color: #334155 !important; }
:where(.dark, .dark *) :is(.dark\:hover\:bg-gray-800:hover, .dark\:hover\:bg-slate-800:hover) { background-color: #1e293b !important; }
:where(.dark, .dark *) :is(.dark\:hover\:bg-gray-700:hover, .dark\:hover\:bg-slate-700:hover, .dark\:hover\:bg-gray-700\/60:hover) { background-color: #334155 !important; }
:where(.dark, .dark *) :is(.dark\:hover\:bg-gray-600:hover, .dark\:hover\:bg-slate-600:hover) { background-color: #475569 !important; }
:where(.dark, .dark *) :is(.dark\:text-white, .dark\:text-gray-100, .dark\:text-slate-100) { color: #f8fafc !important; }
:where(.dark, .dark *) :is(.dark\:text-gray-200, .dark\:text-slate-200) { color: #e2e8f0 !important; }
:where(.dark, .dark *) :is(.dark\:text-gray-300, .dark\:text-slate-300) { color: #cbd5e1 !important; }
:where(.dark, .dark *) :is(.dark\:text-gray-400, .dark\:text-slate-400) { color: #94a3b8 !important; }
:where(.dark, .dark *) :is(.dark\:border-gray-700, .dark\:border-slate-700, .dark\:border-gray-600, .dark\:border-slate-600) { border-color: #334155 !important; }

/* ==========================================================================
   1. Core Surface Hierarchy (Cards, Wells, Tracks, Pills)
   ========================================================================== */
/* Level 1: Primary Cards / Panels / Modals (.bg-white) */
:where(.dark, .dark *) :is(.bg-white, .bg-white\/95, .bg-white\/90, .bg-white\/85, .bg-white\/80, .bg-white\/75, .bg-white\/70):not([class*="dark:bg-"]):not(.peer ~ div):not(.rounded-full.w-4.h-4):not(.rounded-full.w-5.h-5):not(.custom-switch-thumb) {
    background-color: #1e293b !important;
}

:where(.dark, .dark *) :is(.bg-white\/60, .bg-white\/50, .bg-white\/40):not([class*="dark:bg-"]) {
    background-color: rgba(30, 41, 59, 0.82) !important;
}

/* Level 2: Recessed Surfaces (.bg-slate-50, .bg-gray-50, .bg-zinc-50) */
:where(.dark, .dark *) :is(
    .bg-slate-50, [class^="bg-slate-50/"], [class*=" bg-slate-50/"],
    .bg-gray-50, [class^="bg-gray-50/"], [class*=" bg-gray-50/"],
    .bg-zinc-50, [class^="bg-zinc-50/"], [class*=" bg-zinc-50/"], .bg-neutral-50
):not(body):not([class*="dark:bg-"]) {
    background-color: #0f172a !important;
}

/* Level 3A: Recessed Containers, Progress Tracks & Segmented Control Tracks (div.bg-slate-100) */
:where(.dark, .dark *) :is(div, section, header, footer, aside, nav, ul):is(
    .bg-slate-100, [class^="bg-slate-100/"], [class*=" bg-slate-100/"],
    .bg-gray-100, [class^="bg-gray-100/"], [class*=" bg-gray-100/"], .bg-zinc-100
):not([class*="dark:bg-"]) {
    background-color: #0f172a !important;
}

/* Level 3B: Elevated Neutral Badges, Chips, Icon Boxes & Buttons (span/button/a.bg-slate-100) */
:where(.dark, .dark *) :is(span, button, a, label, code, kbd, td, th, li):is(
    .bg-slate-100, [class^="bg-slate-100/"], [class*=" bg-slate-100/"],
    .bg-gray-100, [class^="bg-gray-100/"], [class*=" bg-gray-100/"], .bg-zinc-100
):not([class*="dark:bg-"]) {
    background-color: #283548 !important;
}

/* Active Button / Tab inside a Segmented Control Track (.bg-slate-100 > button.bg-white) */
:where(.dark, .dark *) :is(
    .bg-slate-100, [class^="bg-slate-100/"], [class*=" bg-slate-100/"],
    .bg-gray-100, [class^="bg-gray-100/"], [class*=" bg-gray-100/"],
    .bg-slate-50, [class^="bg-slate-50/"], [class*=" bg-slate-50/"]
) :is(button, a):is(.bg-white, .bg-white\/90, .bg-white\/80) {
    background-color: #334155 !important;
    color: #f8fafc !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

/* Level 4: Prominent Neutral Surfaces (.bg-slate-200, .bg-slate-300, .bg-gray-200, .bg-gray-300) */
:where(.dark, .dark *) :is(
    .bg-slate-200, [class^="bg-slate-200/"], [class*=" bg-slate-200/"],
    .bg-gray-200, [class^="bg-gray-200/"], [class*=" bg-gray-200/"],
    .bg-zinc-200, [class^="bg-zinc-200/"], [class*=" bg-zinc-200/"],
    .bg-slate-300, [class^="bg-slate-300/"], [class*=" bg-slate-300/"], .bg-gray-300
):not([class*="dark:bg-"]) {
    background-color: #334155 !important;
}

/* ==========================================================================
   2. Gradient Surface Overrides
   ========================================================================== */
:where(.dark, .dark *) :is(
    .from-white, .from-slate-50, [class^="from-slate-50/"], [class*=" from-slate-50/"],
    .from-slate-100, [class^="from-slate-100/"], [class*=" from-slate-100/"], .from-gray-50, .from-gray-100,
    .from-indigo-50, [class^="from-indigo-50/"], [class*=" from-indigo-50/"],
    .from-blue-50, [class^="from-blue-50/"], [class*=" from-blue-50/"],
    .from-sky-50, [class^="from-sky-50/"], [class*=" from-sky-50/"],
    .from-emerald-50, [class^="from-emerald-50/"], [class*=" from-emerald-50/"], .from-green-50, .from-teal-50,
    .from-amber-50, [class^="from-amber-50/"], [class*=" from-amber-50/"], .from-orange-50, .from-yellow-50,
    .from-rose-50, [class^="from-rose-50/"], [class*=" from-rose-50/"], .from-red-50, .from-purple-50, .from-violet-50
):not([class*="dark:from-"]) {
    --tw-gradient-from: #1e293b !important;
}

:where(.dark, .dark *) :is(.via-white, .via-slate-50, .via-slate-100, .via-gray-50):not([class*="dark:via-"]) {
    --tw-gradient-via: #1e293b !important;
}

:where(.dark, .dark *) :is(
    .to-white, .to-slate-50, [class^="to-slate-50/"], [class*=" to-slate-50/"],
    .to-slate-100, [class^="to-slate-100/"], [class*=" to-slate-100/"], .to-gray-50, .to-gray-100,
    .to-indigo-50, [class^="to-indigo-50/"], [class*=" to-indigo-50/"], .to-indigo-100,
    .to-blue-50, [class^="to-blue-50/"], [class*=" to-blue-50/"], .to-blue-100,
    .to-sky-50, [class^="to-sky-50/"], [class*=" to-sky-50/"],
    .to-emerald-50, [class^="to-emerald-50/"], [class*=" to-emerald-50/"], .to-emerald-100,
    .to-amber-50, [class^="to-amber-50/"], [class*=" to-amber-50/"],
    .to-rose-50, [class^="to-rose-50/"], [class*=" to-rose-50/"],
    .to-purple-50, .to-purple-100, .to-violet-50, [class^="to-violet-50/"], [class*=" to-violet-50/"]
):not([class*="dark:to-"]) {
    --tw-gradient-to: #0f172a !important;
}

/* ==========================================================================
   3. Typography & High-Contrast Text Overrides
   ========================================================================== */
:where(.dark, .dark *) :is(.text-slate-950, .text-slate-900, .text-gray-950, .text-gray-900, .text-zinc-950, .text-zinc-900, .text-neutral-900):not([class*="dark:text-"]):not([class*="bg-amber-4"]):not([class*="bg-amber-5"]):not([class*="from-amber-4"]):not([class*="bg-yellow-4"]):not([class*="bg-yellow-5"]) {
    color: #f8fafc !important;
}

:where(.dark, .dark *) :is(.text-slate-800, .text-gray-800, .text-zinc-800, .text-neutral-800):not([class*="dark:text-"]):not([class*="bg-amber-4"]):not([class*="bg-amber-5"]):not([class*="from-amber-4"]) {
    color: #f1f5f9 !important;
}

:where(.dark, .dark *) :is(.text-slate-700, .text-gray-700, .text-zinc-700, .text-neutral-700):not([class*="dark:text-"]) { color: #e2e8f0 !important; }
:where(.dark, .dark *) :is(.text-slate-600, .text-gray-600, .text-zinc-600, .text-neutral-600):not([class*="dark:text-"]) { color: #cbd5e1 !important; }
:where(.dark, .dark *) :is(.text-slate-500, .text-gray-500, .text-zinc-500, .text-neutral-500):not([class*="dark:text-"]) { color: #94a3b8 !important; }

/* Neutral Hover Text Overrides */
:where(.dark, .dark *) :is(
    .hover\:text-slate-950:hover, .hover\:text-slate-900:hover, .hover\:text-slate-800:hover, .hover\:text-slate-700:hover,
    .hover\:text-gray-950:hover, .hover\:text-gray-900:hover, .hover\:text-gray-800:hover, .hover\:text-gray-700:hover,
    .hover\:text-zinc-950:hover, .hover\:text-zinc-900:hover
):not([class*="dark:hover:text-"]) {
    color: #f8fafc !important;
}

:where(.dark, .dark *) :is(.hover\:text-slate-600:hover, .hover\:text-gray-600:hover, .group:hover .group-hover\:text-slate-600, .group:hover .group-hover\:text-gray-600):not([class*="dark:hover:text-"]) {
    color: #e2e8f0 !important;
}

/* ==========================================================================
   4. Borders, Dividers, Rings & Focus Halos
   ========================================================================== */
:where(.dark, .dark *) :is(
    .border-white, [class^="border-white/"], [class*=" border-white/"],
    .border-slate-50, .border-slate-100, [class^="border-slate-100/"], [class*=" border-slate-100/"],
    .border-slate-200, [class^="border-slate-200/"], [class*=" border-slate-200/"],
    .border-slate-300, [class^="border-slate-300/"], [class*=" border-slate-300/"],
    .border-gray-50, .border-gray-100, .border-gray-200, [class^="border-gray-200/"], [class*=" border-gray-200/"], .border-gray-300,
    .border-zinc-50, .border-zinc-100, .border-zinc-200, .border-zinc-300
):not([class*="dark:border-"]) {
    border-color: #334155 !important;
}

:where(.dark, .dark *) :is(.hover\:border-slate-100:hover, .hover\:border-slate-200:hover, .hover\:border-slate-300:hover, .hover\:border-gray-200:hover, .hover\:border-gray-300:hover, .hover\:border-zinc-300:hover):not([class*="dark:hover:border-"]) {
    border-color: #475569 !important;
}

:where(.dark, .dark *) :is(.divide-slate-50 > :not(:last-child), .divide-slate-100 > :not(:last-child), .divide-slate-200 > :not(:last-child), .divide-slate-200\/60 > :not(:last-child), .divide-gray-100 > :not(:last-child), .divide-gray-200 > :not(:last-child), .divide-gray-300 > :not(:last-child)) {
    border-color: #334155 !important;
}

:where(.dark, .dark *) :is(.ring-white, [class^="ring-white/"], [class*=" ring-white/"], .ring-slate-100, .ring-slate-200, .ring-gray-100, .ring-gray-200, .ring-gray-300, .ring-indigo-50, .ring-indigo-100, .ring-indigo-200, .ring-blue-100, .ring-blue-200, .ring-emerald-100, .ring-emerald-200, .ring-purple-100, .ring-black\/5):not([class*="dark:ring-"]) {
    --tw-ring-color: rgba(148, 163, 184, 0.25) !important;
}

:where(.dark, .dark *) :is(
    .focus\:ring-indigo-100:focus, .focus\:ring-indigo-200:focus, .focus\:ring-indigo-300:focus,
    .focus\:ring-blue-100:focus, .focus\:ring-blue-200:focus, .focus\:ring-blue-300:focus,
    .focus\:ring-emerald-100:focus, .focus\:ring-emerald-200:focus, .focus\:ring-emerald-300:focus,
    .focus\:ring-amber-100:focus, .focus\:ring-rose-100:focus, .focus\:ring-gray-200:focus, .focus\:ring-gray-300:focus,
    .focus-within\:ring-indigo-100:focus-within, .focus-within\:ring-blue-100:focus-within, .focus-within\:ring-emerald-100:focus-within, .focus-within\:ring-rose-100:focus-within
) {
    --tw-ring-color: rgba(99, 102, 241, 0.35) !important;
}

:where(.dark, .dark *) :is(.focus\:bg-white:focus, .focus-within\:bg-white:focus-within):not([class*="dark:focus:bg-"]) {
    background-color: #0f172a !important;
}

/* ==========================================================================
   5. Semantic Pastel Badges, Pills, Callouts & Hover States
   ========================================================================== */
/* --- 5.1 Emerald / Green / Teal / Lime --- */
:where(.dark, .dark *) :is(.bg-emerald-50, [class^="bg-emerald-50/"], [class*=" bg-emerald-50/"], .bg-emerald-100, [class^="bg-emerald-100/"], [class*=" bg-emerald-100/"], .bg-green-50, [class^="bg-green-50/"], [class*=" bg-green-50/"], .bg-green-100, [class^="bg-green-100/"], [class*=" bg-green-100/"], .bg-lime-50, .bg-lime-100):not([class*="dark:bg-"]) {
    background-color: rgba(16, 185, 129, 0.16) !important;
}

:where(.dark, .dark *) :is(.bg-emerald-200, [class^="bg-emerald-200/"], [class*=" bg-emerald-200/"], .bg-green-200, [class^="bg-green-200/"], [class*=" bg-green-200/"]):not([class*="dark:bg-"]) {
    background-color: rgba(16, 185, 129, 0.25) !important;
}

:where(.dark, .dark *) :is(.bg-teal-50, [class^="bg-teal-50/"], [class*=" bg-teal-50/"], .bg-teal-100, [class^="bg-teal-100/"], [class*=" bg-teal-100/"], .bg-teal-200, [class^="bg-teal-200/"], [class*=" bg-teal-200/"]):not([class*="dark:bg-"]) {
    background-color: rgba(20, 184, 166, 0.18) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-emerald-50:hover, [class^="hover:bg-emerald-50/"]:hover, [class*=" hover:bg-emerald-50/"]:hover, .hover\:bg-emerald-100:hover, [class^="hover:bg-emerald-100/"]:hover, [class*=" hover:bg-emerald-100/"]:hover, .hover\:bg-emerald-200:hover, .hover\:bg-green-50:hover, .hover\:bg-green-100:hover, .hover\:bg-green-200:hover, .hover\:bg-teal-50:hover, .hover\:bg-teal-100:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(16, 185, 129, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-emerald-100, [class^="border-emerald-100/"], [class*=" border-emerald-100/"], .border-emerald-200, [class^="border-emerald-200/"], [class*=" border-emerald-200/"], .border-emerald-300, [class^="border-emerald-300/"], [class*=" border-emerald-300/"], .border-green-100, .border-green-200, .border-green-300, .border-teal-100, .border-teal-200, .border-teal-300, .hover\:border-emerald-200:hover, .hover\:border-emerald-300:hover):not([class*="dark:border-"]) {
    border-color: rgba(16, 185, 129, 0.38) !important;
}

:where(.dark, .dark *) :is(.text-emerald-600, [class^="text-emerald-600/"], [class*=" text-emerald-600/"], .text-green-600, [class^="text-green-600/"], [class*=" text-green-600/"], .text-teal-600, [class^="text-teal-600/"], [class*=" text-teal-600/"], .hover\:text-emerald-600:hover, .hover\:text-green-600:hover, .group:hover .group-hover\:text-emerald-600):not([class*="dark:text-"]) {
    color: #34d399 !important;
}

:where(.dark, .dark *) :is(.text-emerald-700, [class^="text-emerald-700/"], [class*=" text-emerald-700/"], .text-emerald-800, [class^="text-emerald-800/"], [class*=" text-emerald-800/"], .text-emerald-900, .text-emerald-950, .text-green-700, .text-green-800, .text-green-900, .text-green-950, .text-teal-700, .text-teal-800, .text-teal-900, .text-teal-950, .hover\:text-emerald-700:hover, .hover\:text-emerald-800:hover, .hover\:text-emerald-900:hover, .hover\:text-green-700:hover, .hover\:text-green-800:hover, .group:hover .group-hover\:text-emerald-700):not([class*="dark:text-"]) {
    color: #6ee7b7 !important;
}

/* --- 5.2 Amber / Yellow / Orange --- */
:where(.dark, .dark *) :is(.bg-amber-50, [class^="bg-amber-50/"], [class*=" bg-amber-50/"], .bg-amber-100, [class^="bg-amber-100/"], [class*=" bg-amber-100/"], .bg-amber-500\/10, .bg-yellow-50, [class^="bg-yellow-50/"], [class*=" bg-yellow-50/"], .bg-yellow-100, [class^="bg-yellow-100/"], [class*=" bg-yellow-100/"], .bg-orange-50, [class^="bg-orange-50/"], [class*=" bg-orange-50/"], .bg-orange-100, [class^="bg-orange-100/"], [class*=" bg-orange-100/"]):not([class*="dark:bg-"]) {
    background-color: rgba(245, 158, 11, 0.16) !important;
}

:where(.dark, .dark *) :is(.bg-amber-200, [class^="bg-amber-200/"], [class*=" bg-amber-200/"], .bg-yellow-200, [class^="bg-yellow-200/"], [class*=" bg-yellow-200/"], .bg-orange-200, [class^="bg-orange-200/"], [class*=" bg-orange-200/"]):not([class*="dark:bg-"]) {
    background-color: rgba(245, 158, 11, 0.25) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-amber-50:hover, [class^="hover:bg-amber-50/"]:hover, [class*=" hover:bg-amber-50/"]:hover, .hover\:bg-amber-100:hover, [class^="hover:bg-amber-100/"]:hover, [class*=" hover:bg-amber-100/"]:hover, .hover\:bg-amber-200:hover, .hover\:bg-amber-300:hover, .hover\:bg-yellow-50:hover, .hover\:bg-yellow-100:hover, .hover\:bg-yellow-200:hover, .hover\:bg-orange-50:hover, .hover\:bg-orange-100:hover, .hover\:bg-orange-200:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(245, 158, 11, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-amber-100, [class^="border-amber-100/"], [class*=" border-amber-100/"], .border-amber-200, [class^="border-amber-200/"], [class*=" border-amber-200/"], .border-amber-300, [class^="border-amber-300/"], [class*=" border-amber-300/"], .border-amber-400, .border-yellow-100, .border-yellow-200, .border-yellow-300, .border-orange-100, .border-orange-200, .border-orange-300, .hover\:border-amber-200:hover, .hover\:border-amber-300:hover):not([class*="dark:border-"]) {
    border-color: rgba(245, 158, 11, 0.4) !important;
}

:where(.dark, .dark *) :is(.text-amber-600, [class^="text-amber-600/"], [class*=" text-amber-600/"], .text-yellow-600, [class^="text-yellow-600/"], [class*=" text-yellow-600/"], .text-orange-600, [class^="text-orange-600/"], [class*=" text-orange-600/"], .hover\:text-amber-600:hover, .group:hover .group-hover\:text-amber-600):not([class*="dark:text-"]) {
    color: #fbbf24 !important;
}

:where(.dark, .dark *) :is(.text-amber-700, [class^="text-amber-700/"], [class*=" text-amber-700/"], .text-amber-800, [class^="text-amber-800/"], [class*=" text-amber-800/"], .text-amber-900, .text-amber-950, .text-yellow-700, .text-yellow-800, .text-yellow-900, .text-yellow-950, .text-orange-700, .text-orange-800, .text-orange-900, .text-orange-950, .hover\:text-amber-700:hover, .hover\:text-amber-800:hover, .hover\:text-amber-900:hover, .group:hover .group-hover\:text-orange-700):not([class*="dark:text-"]):not([class*="bg-amber-4"]):not([class*="bg-amber-5"]):not([class*="from-amber-4"]) {
    color: #fcd34d !important;
}

/* --- 5.3 Rose / Red / Pink --- */
:where(.dark, .dark *) :is(.bg-rose-50, [class^="bg-rose-50/"], [class*=" bg-rose-50/"], .bg-rose-100, [class^="bg-rose-100/"], [class*=" bg-rose-100/"], .bg-red-50, [class^="bg-red-50/"], [class*=" bg-red-50/"], .bg-red-100, [class^="bg-red-100/"], [class*=" bg-red-100/"], .bg-pink-50, [class^="bg-pink-50/"], [class*=" bg-pink-50/"], .bg-pink-100):not([class*="dark:bg-"]) {
    background-color: rgba(244, 63, 94, 0.16) !important;
}

:where(.dark, .dark *) :is(.bg-rose-200, [class^="bg-rose-200/"], [class*=" bg-rose-200/"], .bg-red-200, [class^="bg-red-200/"], [class*=" bg-red-200/"], .bg-pink-200):not([class*="dark:bg-"]) {
    background-color: rgba(244, 63, 94, 0.25) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-rose-50:hover, [class^="hover:bg-rose-50/"]:hover, [class*=" hover:bg-rose-50/"]:hover, .hover\:bg-rose-100:hover, [class^="hover:bg-rose-100/"]:hover, [class*=" hover:bg-rose-100/"]:hover, .hover\:bg-rose-200:hover, .hover\:bg-red-50:hover, [class^="hover:bg-red-50/"]:hover, [class*=" hover:bg-red-50/"]:hover, .hover\:bg-red-100:hover, .hover\:bg-red-200:hover, .hover\:bg-pink-50:hover, .hover\:bg-pink-100:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(244, 63, 94, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-rose-100, [class^="border-rose-100/"], [class*=" border-rose-100/"], .border-rose-200, [class^="border-rose-200/"], [class*=" border-rose-200/"], .border-rose-300, [class^="border-rose-300/"], [class*=" border-rose-300/"], .border-red-100, .border-red-200, .border-red-300, .border-pink-100, .border-pink-200, .border-pink-300, .hover\:border-rose-200:hover, .hover\:border-rose-300:hover, .hover\:border-red-200:hover):not([class*="dark:border-"]) {
    border-color: rgba(244, 63, 94, 0.4) !important;
}

:where(.dark, .dark *) :is(.text-rose-600, [class^="text-rose-600/"], [class*=" text-rose-600/"], .text-red-600, [class^="text-red-600/"], [class*=" text-red-600/"], .text-pink-600, .hover\:text-rose-600:hover, .hover\:text-red-600:hover):not([class*="dark:text-"]) {
    color: #fb7185 !important;
}

:where(.dark, .dark *) :is(.text-rose-700, [class^="text-rose-700/"], [class*=" text-rose-700/"], .text-rose-800, [class^="text-rose-800/"], [class*=" text-rose-800/"], .text-rose-900, .text-rose-950, .text-red-700, .text-red-800, .text-red-900, .text-red-950, .text-pink-700, .text-pink-800, .text-pink-900, .hover\:text-rose-700:hover, .hover\:text-rose-800:hover, .hover\:text-red-700:hover, .hover\:text-red-800:hover, .hover\:text-red-900:hover):not([class*="dark:text-"]) {
    color: #fda4af !important;
}

/* --- 5.4 Indigo / Blue --- */
:where(.dark, .dark *) :is(.bg-indigo-50, [class^="bg-indigo-50/"], [class*=" bg-indigo-50/"], .bg-indigo-100, [class^="bg-indigo-100/"], [class*=" bg-indigo-100/"], .bg-blue-50, [class^="bg-blue-50/"], [class*=" bg-blue-50/"], .bg-blue-100, [class^="bg-blue-100/"], [class*=" bg-blue-100/"]):not([class*="dark:bg-"]) {
    background-color: rgba(99, 102, 241, 0.16) !important;
}

:where(.dark, .dark *) :is(.bg-indigo-200, [class^="bg-indigo-200/"], [class*=" bg-indigo-200/"], .bg-blue-200, [class^="bg-blue-200/"], [class*=" bg-blue-200/"]):not([class*="dark:bg-"]) {
    background-color: rgba(99, 102, 241, 0.25) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-indigo-50:hover, [class^="hover:bg-indigo-50/"]:hover, [class*=" hover:bg-indigo-50/"]:hover, .hover\:bg-indigo-100:hover, [class^="hover:bg-indigo-100/"]:hover, [class*=" hover:bg-indigo-100/"]:hover, .hover\:bg-indigo-200:hover, .hover\:bg-blue-50:hover, [class^="hover:bg-blue-50/"]:hover, [class*=" hover:bg-blue-50/"]:hover, .hover\:bg-blue-100:hover, [class^="hover:bg-blue-100/"]:hover, [class*=" hover:bg-blue-100/"]:hover, .hover\:bg-blue-200:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(99, 102, 241, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-indigo-100, [class^="border-indigo-100/"], [class*=" border-indigo-100/"], .border-indigo-200, [class^="border-indigo-200/"], [class*=" border-indigo-200/"], .border-indigo-300, [class^="border-indigo-300/"], [class*=" border-indigo-300/"], .border-blue-100, [class^="border-blue-100/"], [class*=" border-blue-100/"], .border-blue-200, [class^="border-blue-200/"], [class*=" border-blue-200/"], .border-blue-300, .hover\:border-indigo-200:hover, .hover\:border-indigo-300:hover, .hover\:border-blue-200:hover, .hover\:border-blue-300:hover, .focus\:border-indigo-300:focus, .focus\:border-blue-300:focus):not([class*="dark:border-"]) {
    border-color: rgba(99, 102, 241, 0.4) !important;
}

:where(.dark, .dark *) :is(.text-indigo-600, [class^="text-indigo-600/"], [class*=" text-indigo-600/"], .hover\:text-indigo-600:hover, .group:hover .group-hover\:text-indigo-600):not([class*="dark:text-"]) {
    color: #818cf8 !important;
}

:where(.dark, .dark *) :is(.text-blue-600, [class^="text-blue-600/"], [class*=" text-blue-600/"], .hover\:text-blue-600:hover, .group:hover .group-hover\:text-blue-600):not([class*="dark:text-"]) {
    color: #60a5fa !important;
}

:where(.dark, .dark *) :is(.text-indigo-700, [class^="text-indigo-700/"], [class*=" text-indigo-700/"], .text-indigo-800, [class^="text-indigo-800/"], [class*=" text-indigo-800/"], .text-indigo-900, [class^="text-indigo-900/"], [class*=" text-indigo-900/"], .text-indigo-950, .hover\:text-indigo-700:hover, .hover\:text-indigo-800:hover, .hover\:text-indigo-900:hover, .group:hover .group-hover\:text-indigo-700):not([class*="dark:text-"]) {
    color: #a5b4fc !important;
}

:where(.dark, .dark *) :is(.text-blue-700, [class^="text-blue-700/"], [class*=" text-blue-700/"], .text-blue-800, [class^="text-blue-800/"], [class*=" text-blue-800/"], .text-blue-900, .text-blue-950, .hover\:text-blue-700:hover, .hover\:text-blue-800:hover, .group:hover .group-hover\:text-blue-700):not([class*="dark:text-"]) {
    color: #93c5fd !important;
}

/* --- 5.5 Sky / Cyan --- */
:where(.dark, .dark *) :is(.bg-sky-50, [class^="bg-sky-50/"], [class*=" bg-sky-50/"], .bg-sky-100, [class^="bg-sky-100/"], [class*=" bg-sky-100/"], .bg-sky-200, .bg-cyan-50, [class^="bg-cyan-50/"], [class*=" bg-cyan-50/"], .bg-cyan-100):not([class*="dark:bg-"]) {
    background-color: rgba(14, 165, 233, 0.16) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-sky-50:hover, [class^="hover:bg-sky-50/"]:hover, [class*=" hover:bg-sky-50/"]:hover, .hover\:bg-sky-100:hover, [class^="hover:bg-sky-100/"]:hover, [class*=" hover:bg-sky-100/"]:hover, .hover\:bg-cyan-50:hover, .hover\:bg-cyan-100:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(14, 165, 233, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-sky-100, .border-sky-200, [class^="border-sky-200/"], [class*=" border-sky-200/"], .border-sky-300, .border-cyan-100, .border-cyan-200, .border-cyan-300):not([class*="dark:border-"]) {
    border-color: rgba(56, 189, 248, 0.38) !important;
}

:where(.dark, .dark *) :is(.text-sky-600, .text-cyan-600):not([class*="dark:text-"]) { color: #38bdf8 !important; }
:where(.dark, .dark *) :is(.text-sky-700, [class^="text-sky-700/"], [class*=" text-sky-700/"], .text-sky-800, .text-sky-900, .text-sky-950, .text-cyan-700, .text-cyan-800, .text-cyan-900):not([class*="dark:text-"]) { color: #7dd3fc !important; }

/* --- 5.6 Purple / Violet / Fuchsia --- */
:where(.dark, .dark *) :is(.bg-purple-50, [class^="bg-purple-50/"], [class*=" bg-purple-50/"], .bg-purple-100, [class^="bg-purple-100/"], [class*=" bg-purple-100/"], .bg-purple-200, [class^="bg-purple-200/"], [class*=" bg-purple-200/"], .bg-violet-50, [class^="bg-violet-50/"], [class*=" bg-violet-50/"], .bg-violet-100, [class^="bg-violet-100/"], [class*=" bg-violet-100/"], .bg-violet-200, .bg-fuchsia-50, .bg-fuchsia-100):not([class*="dark:bg-"]) {
    background-color: rgba(139, 92, 246, 0.16) !important;
}

:where(.dark, .dark *) :is(.hover\:bg-purple-50:hover, .hover\:bg-purple-100:hover, .hover\:bg-violet-50:hover, .hover\:bg-violet-100:hover, [class^="hover:bg-violet-100/"]:hover, [class*=" hover:bg-violet-100/"]:hover, .hover\:bg-fuchsia-50:hover, .hover\:bg-fuchsia-100:hover):not([class*="dark:hover:bg-"]) {
    background-color: rgba(139, 92, 246, 0.28) !important;
}

:where(.dark, .dark *) :is(.border-purple-100, .border-purple-200, [class^="border-purple-200/"], [class*=" border-purple-200/"], .border-purple-300, .border-violet-100, .border-violet-200, [class^="border-violet-200/"], [class*=" border-violet-200/"], .border-violet-300, .hover\:border-purple-200:hover, .hover\:border-violet-200:hover):not([class*="dark:border-"]) {
    border-color: rgba(167, 139, 250, 0.38) !important;
}

:where(.dark, .dark *) :is(.text-purple-600, .text-violet-600, .text-fuchsia-600, .hover\:text-purple-600:hover, .hover\:text-violet-600:hover):not([class*="dark:text-"]) { color: #a78bfa !important; }
:where(.dark, .dark *) :is(.text-purple-700, .text-purple-800, .text-purple-900, .text-purple-950, .text-violet-700, .text-violet-800, .text-violet-900, .text-violet-950, .text-fuchsia-700, .text-fuchsia-800, .text-fuchsia-900, .hover\:text-purple-700:hover, .hover\:text-violet-700:hover, .group:hover .group-hover\:text-purple-700):not([class*="dark:text-"]) { color: #c4b5fd !important; }

/* ==========================================================================
   6. Tables, Sticky Headers, Sticky Columns & Neutral Hover States
   ========================================================================== */
:where(.dark, .dark *) :is(table thead, table thead tr, table thead th) {
    background-color: #0f172a !important;
    color: #94a3b8 !important;
    border-color: #334155 !important;
}

:where(.dark, .dark *) table tbody tr { border-color: #1e293b !important; }
:where(.dark, .dark *) table tbody tr:hover { background-color: rgba(51, 65, 85, 0.45) !important; }

:where(.dark, .dark *) :is(
    .hover\:bg-white:hover, [class^="hover:bg-white/"]:hover, [class*=" hover:bg-white/"]:hover,
    .hover\:bg-slate-50:hover, [class^="hover:bg-slate-50/"]:hover, [class*=" hover:bg-slate-50/"]:hover,
    .hover\:bg-slate-100:hover, [class^="hover:bg-slate-100/"]:hover, [class*=" hover:bg-slate-100/"]:hover,
    .hover\:bg-gray-50:hover, [class^="hover:bg-gray-50/"]:hover, [class*=" hover:bg-gray-50/"]:hover,
    .hover\:bg-gray-100:hover, [class^="hover:bg-gray-100/"]:hover, [class*=" hover:bg-gray-100/"]:hover
):not(tr):not([class*="dark:hover:bg-"]) {
    background-color: #334155 !important;
}

:where(.dark, .dark *) :is(.hover\:bg-slate-200:hover, [class^="hover:bg-slate-200/"]:hover, [class*=" hover:bg-slate-200/"]:hover, .hover\:bg-slate-300:hover, .hover\:bg-gray-200:hover, .hover\:bg-gray-300:hover):not([class*="dark:hover:bg-"]) {
    background-color: #475569 !important;
}

:where(.dark, .dark *) :is(table th.sticky, table thead .sticky) { background-color: #0f172a !important; }
:where(.dark, .dark *) :is(table td.sticky, table tbody .sticky) { background-color: #1e293b !important; }
:where(.dark, .dark *) table tbody tr:hover td.sticky { background-color: #26354d !important; }

/* ==========================================================================
   7. Forms, Inputs, Selects, Date Pickers & Textareas
   ========================================================================== */
:where(.dark, .dark *) :is(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="color"]):not([type="file"]):not(.bg-transparent),
    select:not(.bg-transparent),
    textarea:not(.bg-transparent)
):not([class*="dark:bg-"]) {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
    color-scheme: dark;
}

:where(.dark, .dark *) :is(input.bg-transparent, select.bg-transparent, textarea.bg-transparent) {
    background-color: transparent !important;
    border-color: transparent !important;
    color: #f8fafc !important;
    color-scheme: dark;
}

:where(.dark, .dark *) select:not([multiple]):not([size]):not(.appearance-none):not(.select-input):not(.bg-transparent) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M6 8l4 4 4-4'/%3E%3C/svg%3E") !important;
    background-position: right 0.65rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.15em 1.15em !important;
    padding-right: 2.1rem !important;
}

:where(.dark, .dark *) :is(input:not([type="checkbox"]):not([type="radio"]), textarea)::placeholder { color: #64748b !important; }
:where(.dark, .dark *) :is(input:not([type="checkbox"]):not([type="radio"]):not(.bg-transparent):focus, select:not(.bg-transparent):focus, textarea:not(.bg-transparent):focus) { border-color: #6366f1 !important; }
:where(.dark, .dark *) :is(input[type="checkbox"], input[type="radio"]) { color-scheme: dark; accent-color: #6366f1; }
:where(.dark, .dark *) :is(select option, select optgroup) { background-color: #0f172a; color: #f8fafc; }

/* ==========================================================================
   8. Scrollbars in Dark Mode (Root Viewport + All Inner Containers)
   ========================================================================== */
html.dark, body.dark { scrollbar-color: #334155 #0b1120; }
:where(.dark, .dark *) :is(.custom-scrollbar, .table-responsive-wrapper, .table-container, .checkbox-container, .custom-scroll) { scrollbar-color: #475569 rgba(15, 23, 42, 0.4) !important; }

html.dark::-webkit-scrollbar, body.dark::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark::-webkit-scrollbar-track, body.dark::-webkit-scrollbar-track { background: #0b1120 !important; }
html.dark::-webkit-scrollbar-thumb, body.dark::-webkit-scrollbar-thumb { background-color: #334155 !important; border-radius: 9999px !important; border: 2px solid #0b1120 !important; }
html.dark::-webkit-scrollbar-thumb:hover, body.dark::-webkit-scrollbar-thumb:hover { background-color: #475569 !important; }

html.dark *::-webkit-scrollbar, body.dark *::-webkit-scrollbar, :where(.dark, .dark *) :is(.custom-scrollbar, .table-responsive-wrapper, .table-container, .checkbox-container, .custom-scroll)::-webkit-scrollbar { width: 6px !important; height: 6px !important; }
html.dark *::-webkit-scrollbar-track, body.dark *::-webkit-scrollbar-track, :where(.dark, .dark *) :is(.custom-scrollbar, .table-responsive-wrapper, .table-container, .checkbox-container, .custom-scroll)::-webkit-scrollbar-track { background: rgba(15, 23, 42, 0.35) !important; border-radius: 9999px !important; }
html.dark *::-webkit-scrollbar-thumb, body.dark *::-webkit-scrollbar-thumb, :where(.dark, .dark *) :is(.custom-scrollbar, .table-responsive-wrapper, .table-container, .checkbox-container, .custom-scroll)::-webkit-scrollbar-thumb { background-color: #334155 !important; border-radius: 9999px !important; }
html.dark *::-webkit-scrollbar-thumb:hover, body.dark *::-webkit-scrollbar-thumb:hover, :where(.dark, .dark *) :is(.custom-scrollbar, .table-responsive-wrapper, .table-container, .checkbox-container, .custom-scroll)::-webkit-scrollbar-thumb:hover { background-color: #475569 !important; }
html.dark::-webkit-scrollbar-corner, body.dark::-webkit-scrollbar-corner, html.dark *::-webkit-scrollbar-corner, body.dark *::-webkit-scrollbar-corner { background: transparent !important; }

/* ==========================================================================
   9. Module-Specific Custom Classes (Modals, Skeletons, Kanban, Inventory, Maps)
   ========================================================================== */
:where(.dark, .dark *) .skeleton {
    background: #1e293b !important;
    background-image: linear-gradient(to right, #1e293b 0%, #334155 20%, #1e293b 40%, #1e293b 100%) !important;
    background-size: 200% 100% !important;
}

:where(.dark, .dark *) :is(.modal-content, .planner-modal-content, .calc-box, .popover) {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

:where(.dark, .dark *) :is(.popover h3, .calc-header h3, .calc-history-section h4) { color: #f8fafc !important; }
:where(.dark, .dark *) :is(.founders-list-item, .client-list-item) { border-color: #334155 !important; }
:where(.dark, .dark *) :is(.founders-list-item:hover, .client-list-item:hover, .day-with-events:hover) { background-color: rgba(51, 65, 85, 0.5) !important; }
:where(.dark, .dark *) .chat-table-highlight { background-color: rgba(255, 255, 255, 0.08) !important; }

:where(.dark, .dark *) :is(.calc-result, .history-list) {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

:where(.dark, .dark *) :is(.calc-result p, .history-text, .calc-form-group label, .history-user) { color: #cbd5e1 !important; }
:where(.dark, .dark *) .calc-total { color: #818cf8 !important; border-color: #334155 !important; }
:where(.dark, .dark *) .timeline-item::before { background-color: #334155 !important; }
:where(.dark, .dark *) .timeline-dot { border-color: #1e293b !important; }
:where(.dark, .dark *) :is(.kanban-column.drag-over, .dashboard-item.active) { background-color: rgba(99, 102, 241, 0.18) !important; outline: 2px solid #6366f1 !important; }

/* Warehouse Inventory Modals (.inv-*) */
:where(.dark, .dark *) :is(.inv-modal-dialog, .inv-panel, .inv-cells-pane, .inv-ptype-group, .inv-stock-toggle, .inv-mode-tab, .inv-chips-bar, .inv-panel-search) {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

:where(.dark, .dark *) :is(.inv-modal-footer, .inv-filter-box, .inv-panel-header, .inv-tab-pill, .inv-action-pill-slate) {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

:where(.dark, .dark *) .inv-ptype-btn { color: #cbd5e1 !important; }
:where(.dark, .dark *) :is(.inv-ptype-btn:hover, .inv-mode-tab:hover) { background-color: #334155 !important; }
:where(.dark, .dark *) .inv-ptype-btn.active { background-color: #4f46e5 !important; color: #ffffff !important; }
:where(.dark, .dark *) :is(.inv-mode-tab.active, .inv-summary-badge) { background-color: rgba(99, 102, 241, 0.18) !important; border-color: #6366f1 !important; color: #a5b4fc !important; }
:where(.dark, .dark *) .inv-action-pill-emerald { background-color: rgba(16, 185, 129, 0.16) !important; border-color: rgba(16, 185, 129, 0.38) !important; color: #6ee7b7 !important; }
:where(.dark, .dark *) .inv-reset-btn { background-color: rgba(244, 63, 94, 0.16) !important; color: #fda4af !important; }

/* Leaflet Popups & 3D Map Panels */
:where(.dark, .dark *) :is(.leaflet-popup-content-wrapper, .leaflet-popup-tip, .glass-panel, .rack-badge-compact, .rack-badge-expanded) {
    background: rgba(30, 41, 59, 0.92) !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

:where(.dark, .dark *) .row-label {
    background: rgba(15, 23, 42, 0.92) !important;
    border-color: rgba(59, 130, 246, 0.45) !important;
    color: #60a5fa !important;
}

:where(.dark, .dark *) input[type="range"]::-webkit-slider-runnable-track { background: #334155 !important; }
:where(.dark, .dark *) .btn-apple:not(.btn-primary):not(.btn-orange) { background-color: rgba(30, 41, 59, 0.9) !important; border-color: #334155 !important; color: #e2e8f0 !important; }
:where(.dark, .dark *) .btn-apple:not(.btn-primary):not(.btn-orange):hover { background-color: #334155 !important; color: #ffffff !important; }
