/* Main CSS for Demo Plant LLC Inventory Management */

* {
    font-family: 'Inter', sans-serif;
}

/* Demo-mode redaction: hide cost columns/cells and recipe-quantity columns
   site-wide. Module templates tag elements with these classes; the rules
   only fire when body.demo-mode is set (see auth.js#updateUserDisplay). */
body.demo-mode .demo-hide-cost,
body.demo-mode .demo-hide-recipe-qty {
    display: none !important;
}

/* Hide number input spinner arrows (increment/decrement buttons) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}
html, body {
    height: 100%;
    overflow: hidden;
}

/* JITTER FIX: Prevent scrollbar-induced horizontal shifts */
#main-content {
    scrollbar-gutter: stable;
}
.loader {
    border: 4px solid #f3f3f3;
    border-radius: 50%;
    border-top: 4px solid #3498db;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: none;
}
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Thin scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
/* Toast container - fixed position in top-right corner */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

/* Toast notification */
.toast {
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@keyframes slideIn {
    from {
        transform: translate3d(400px, 0, 0);
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}
/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}
@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Sidebar - NO transitions for instant, jitter-free collapse/expand */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow: hidden !important;
    z-index: 40;
}

/* JITTER FIX: All nav-items must have same border width to prevent layout shift */
#sidebar .nav-item,
#sidebar a.nav-item {
    border: 2px solid transparent !important;
    outline: none !important; /* JITTER FIX: Prevent focus outline from affecting layout */
    box-sizing: border-box !important; /* JITTER FIX: Ensure border is included in dimensions */
}

/* CRITICAL: Override Tailwind bg-slate-800 for active navigation items */
#sidebar a.nav-item.bg-slate-800,
#sidebar .nav-item.bg-slate-800,
a.bg-slate-800.nav-item,
.bg-slate-800.nav-item {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border: 2px solid #dc2626 !important;
    color: #000000 !important;
}

#sidebar.collapsed {
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    background: #0f0f0f !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
}

#sidebar:not(.collapsed) {
    width: 256px !important;
    min-width: 256px !important;
    max-width: 256px !important;
}

#sidebar.collapsed #sidebar-nav,
#sidebar:not(.collapsed) #sidebar-nav {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Hide scrollbar but keep scroll functional via mouse wheel */
#sidebar #sidebar-nav::-webkit-scrollbar {
    display: none;
}

/* Full sidebar - Black theme */
#sidebar {
    background: #0f0f0f !important;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff !important;
}

/* Ensure all sidebar elements default to white text */
#sidebar *, #sidebar a, #sidebar span, #sidebar div {
    color: #ffffff !important;
}

/* Override for selected items - force black */
#sidebar .nav-item.bg-slate-800 *,
#sidebar a.bg-slate-800 *,
#sidebar .bg-slate-800 * {
    color: #000000 !important;
}

/* Override for icons - they should also be white by default */
#sidebar svg {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* But black when active/selected - highest priority */
#sidebar .nav-item.bg-slate-800 svg,
#sidebar a.bg-slate-800 svg,
#sidebar .bg-slate-800 svg {
    color: #000000 !important;
    stroke: #000000 !important;
    fill: none !important;
}

/* Ensure text is also black when selected */
#sidebar .nav-item.bg-slate-800,
#sidebar a.bg-slate-800,
#sidebar .bg-slate-800 {
    color: #000000 !important;
}

#sidebar .nav-item.bg-slate-800 span,
#sidebar a.bg-slate-800 span,
#sidebar .bg-slate-800 span {
    color: #000000 !important;
}

/* Clean white header with subtle border */
#top-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#page-title {
    color: #0f172a !important;
}

#top-header .text-slate-500 {
    color: #64748b !important;
}

/* Main content - Clean white theme */
body {
    background-color: #f8fafc !important;
}

#main-content {
    background-color: #f8fafc !important;
}

/* Adjust main content area for fixed sidebar */
body > div.flex.h-screen {
    padding-left: 256px;
}

/* When sidebar is collapsed, adjust padding */
body.sidebar-collapsed > div.flex.h-screen {
    padding-left: 72px;
}

/* Cards - White with subtle shadows */
.bg-white.rounded-xl {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
}

/* Text colors restored for white background */
.text-slate-900 {
    color: #0f172a !important;
}

.text-slate-500 {
    color: #64748b !important;
}

.text-slate-600 {
    color: #475569 !important;
}

.text-slate-700 {
    color: #334155 !important;
}

#sidebar.collapsed .nav-text {
    display: none;
}

#sidebar.collapsed .logo-full {
    display: none;
}

#sidebar.collapsed .logo-mini {
    display: none;
}

.logo-mini {
    display: none;
}

#sidebar.collapsed .p-6.border-b {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 1.5rem 0 !important;
    min-height: 72px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: transparent !important;
}

#sidebar.collapsed .p-6.border-b button {
    padding: 0 !important;
    margin: 0.375rem auto !important;
    width: 48px !important;
    height: 48px !important;
    background: transparent !important;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#sidebar.collapsed .p-6.border-b button::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    opacity: 0;
}

#sidebar.collapsed .p-6.border-b button:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: #dc2626;
    transform: translateX(-2px);
}

#sidebar.collapsed .p-6.border-b button:hover::after {
    opacity: 1;
}

#sidebar.collapsed .p-6.border-b button svg {
    width: 1.125rem !important;
    height: 1.125rem !important;
    color: rgba(255, 255, 255, 0.6) !important;
    position: relative;
    z-index: 1;
}

#sidebar.collapsed .p-6.border-b button:hover svg {
    color: rgba(255, 255, 255, 0.95) !important;
    transform: scale(1.05);
}

#sidebar.collapsed .nav-item {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0.375rem auto !important;
    padding: 0 !important;
    width: 48px !important;
    height: 48px !important;
    border-radius: 0.5rem !important; /* Rounded corners */
    text-align: center;
    border: 2px solid transparent;
    position: relative;
    background: transparent !important;
    border: 1px solid transparent;
}

/* Permission-restricted items - must beat `display: flex !important`
   on #sidebar.collapsed .nav-item and any tablet/mobile overrides. */
#sidebar .nav-item.nav-hidden,
#sidebar .sb-section.nav-hidden,
.kbe-mod.nav-hidden {
    display: none !important;
}

#sidebar.collapsed .nav-item svg {
    width: 1.125rem !important;
    height: 1.125rem !important;
    display: block !important;
    margin: 0 auto !important;
    position: relative;
    z-index: 1;
}

#sidebar.collapsed .nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0.5rem; /* Rounded corners */
    background: rgba(255, 255, 255, 0.03);
    opacity: 0;
}

#sidebar:not(.collapsed) .logo-mini {
    display: none !important;
}

/* Hide tooltips in expanded sidebar - they cause horizontal overflow */
#sidebar:not(.collapsed) .nav-tooltip {
    display: none !important;
}

/* Tooltip for collapsed sidebar */
.nav-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(-8px);
    margin-left: 16px;
    padding: 8px 14px;
    background: rgba(30, 30, 30, 0.98);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.08);
}

.nav-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(30, 30, 30, 0.98);
}

#sidebar.collapsed .nav-item:hover .nav-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.nav-item {
    position: relative;
}

/* Sidebar toggle button - match nav item styling */
#sidebar-toggle-btn {
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
}

/* Hover state - red border like nav items */
#sidebar-toggle-btn:hover {
    border: 2px solid #dc2626 !important;
    background: rgba(255, 255, 255, 0.06) !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2) !important;
}

/* Collapsed sidebar - center the button */
#sidebar.collapsed #sidebar-toggle-btn {
    margin: 0 auto;
}

/* Toggle icon styling */
#sidebar-toggle-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

#sidebar.collapsed #sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* Black sidebar with white/red accents */
#sidebar.collapsed .nav-item,
#sidebar.collapsed .nav-item:hover,
#sidebar.collapsed a.nav-item,
#sidebar.collapsed a.nav-item:hover {
    background-color: transparent !important;
    background: none !important;
    border-radius: 0 !important;
    border: none !important;
}

/* Remove the above transparent rule for active items */
#sidebar.collapsed .nav-item.bg-slate-800,
#sidebar.collapsed a.nav-item.bg-slate-800 {
    background: #ffffff !important;
    background-color: #ffffff !important;
}

/* White icons for black background */
#sidebar.collapsed .nav-item svg,
#sidebar.collapsed a.nav-item svg {
    color: rgba(255, 255, 255, 0.6) !important;
    flex-shrink: 0 !important; /* JITTER FIX: Prevent SVG from shrinking/growing */
}

/* Hover - red border accent - NOT for active items */
/* JITTER FIX: Removed translateX(-2px) - causes horizontal layout shift */
#sidebar.collapsed .nav-item:hover:not(.bg-slate-800) {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 2px solid #dc2626 !important; /* Red border on hover */
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2) !important; /* Subtle red glow */
}

#sidebar.collapsed .nav-item:hover:not(.bg-slate-800)::after {
    opacity: 1;
}

#sidebar.collapsed .nav-item:hover:not(.bg-slate-800) svg,
#sidebar.collapsed a.nav-item:hover:not(.bg-slate-800) svg {
    color: rgba(255, 255, 255, 0.95) !important;
}

/* Active items should not change on hover */
#sidebar.collapsed .nav-item.bg-slate-800:hover,
#sidebar.collapsed a.nav-item.bg-slate-800:hover {
    background: #ffffff !important;
    background-color: #ffffff !important;
}

/* Active state - white background with red border - HIGHEST PRIORITY */
#sidebar.collapsed .nav-item.bg-slate-800,
#sidebar.collapsed a.bg-slate-800,
#sidebar.collapsed a.nav-item.bg-slate-800 {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 2px solid #dc2626 !important;
    border-radius: 0.5rem !important; /* Rounded corners */
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3) !important;
}

#sidebar.collapsed .nav-item.bg-slate-800::after {
    opacity: 0 !important;
}

#sidebar.collapsed .nav-item.bg-slate-800 svg,
#sidebar.collapsed a.bg-slate-800 svg,
#sidebar.collapsed a.nav-item.bg-slate-800 svg {
    color: #000000 !important;
    stroke: #000000 !important;
    fill: none !important;
}

/* Better tooltip positioning */
#sidebar.collapsed .nav-tooltip {
    left: calc(100% + 5px);
}
/* Expanded sidebar - Black theme with red accents */
/* JITTER FIX: Removed border-left to prevent width changes - using 2px all-around instead */
#sidebar:not(.collapsed) .nav-item {
    color: #ffffff !important;
}

#sidebar:not(.collapsed) .nav-item svg {
    color: rgba(255, 255, 255, 0.6) !important;
    flex-shrink: 0 !important; /* JITTER FIX: Prevent SVG from shrinking/growing */
}

#sidebar:not(.collapsed) .nav-item span.nav-text {
    color: #ffffff !important;
    font-weight: 500; /* JITTER FIX: Keep consistent weight */
    white-space: nowrap; /* JITTER FIX: Prevent text wrapping that could cause layout shifts */
}

/* Force all text and icons in nav items to be white */
#sidebar:not(.collapsed) .nav-item * {
    color: inherit !important;
}

/* Override any conflicting Tailwind classes */
#sidebar:not(.collapsed) a.nav-item,
#sidebar:not(.collapsed) a.nav-item * {
    color: #ffffff !important;
}

#sidebar:not(.collapsed) a.nav-item svg {
    color: rgba(255, 255, 255, 0.8) !important;
}

#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) {
    background-color: rgba(255, 255, 255, 0.06) !important;
    border: 2px solid #dc2626 !important; /* Red border on hover */
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2) !important; /* Subtle red glow */
}

#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) svg,
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) span.nav-text,
#sidebar:not(.collapsed) a.nav-item:hover:not(.bg-slate-800) *{
    color: rgba(255, 255, 255, 0.95) !important;
}

/* Active items should maintain white background on hover */
#sidebar:not(.collapsed) .nav-item.bg-slate-800:hover,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800:hover {
    background: #ffffff !important;
    background-color: #ffffff !important;
}

#sidebar:not(.collapsed) .nav-item.bg-slate-800,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800,
#sidebar:not(.collapsed) a.bg-slate-800 {
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 2px solid #dc2626 !important;
    border-left-width: 3px !important;
    border-radius: 0.75rem !important;
}

#sidebar:not(.collapsed) .nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.bg-slate-800 span.nav-text {
    color: #000000 !important;
    font-weight: 500; /* JITTER FIX: Keep same weight as inactive (was 600, caused text width change) */
}

#sidebar:not(.collapsed) .nav-item.bg-slate-800 svg,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800 svg,
#sidebar:not(.collapsed) a.bg-slate-800 svg {
    color: #000000 !important;
    stroke: #000000 !important;
    fill: none !important;
}

/* Logo text styling */
.logo-full div,
.logo-full img {
    filter: brightness(1);
}

/* Sidebar header styling */
#sidebar .p-6.border-b {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* Navigation text readability */
#sidebar:not(.collapsed) .nav-item span {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Expanded sidebar padding and spacing */
/* JITTER FIX: Removed margin/padding overrides - using Tailwind classes from HTML instead */
#sidebar:not(.collapsed) .nav-item {
    /* margin and padding now controlled by Tailwind classes in HTML: mx-3 px-4 py-3 mb-2 */
}

/* Company name fallback styling */
.logo-full div {
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.logo-full .text-white {
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Better hover transitions */
/* JITTER FIX: Removed translateX(1px) - causes horizontal layout shift */
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) {
    /* No transform - prevents jitter */
}

/* Toggle button styling - no transitions for instant response */
#sidebar button {
    border-radius: 0.5rem;
}

#sidebar button svg {
    color: rgba(255, 255, 255, 0.7);
}

#sidebar button:hover {
    background: rgba(255, 255, 255, 0.06);
}

#sidebar button:hover svg {
    color: rgba(255, 255, 255, 0.95);
}

/* Navigation container styling */
#sidebar nav {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    overflow-x: hidden !important;
}

/* Active menu item indicator - removed for minimal design */

/* Ensure all nav items are relative for positioning */
#sidebar .nav-item {
    position: relative;
}

/* Buttons - Black with white text */
.bg-blue-600,
.bg-green-600,
.bg-indigo-600,
.bg-teal-600,
.bg-red-600 {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
    transition: border-color 0.15s ease;
}

.bg-blue-600:hover,
.bg-green-600:hover,
.bg-indigo-600:hover,
.bg-teal-600:hover,
.bg-red-600:hover,
.hover\:bg-blue-700:hover,
.hover\:bg-green-700:hover,
.hover\:bg-indigo-700:hover,
.hover\:bg-teal-700:hover,
.hover\:bg-red-700:hover {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}

/* Ensure button text is white */
.bg-blue-600 span,
.bg-green-600 span,
.bg-indigo-600 span,
.bg-teal-600 span,
.bg-red-600 span,
.bg-blue-600 svg,
.bg-green-600 svg,
.bg-indigo-600 svg,
.bg-teal-600 svg,
.bg-red-600 svg {
    color: #ffffff !important;
}

/* Change all blue accents to black */
.text-blue-600,
.text-blue-700,
.text-blue-800,
.text-blue-900 {
    color: #000000 !important;
}

.bg-blue-50,
.bg-blue-100 {
    background-color: #ffffff !important;
}

.border-blue-200,
.border-blue-300,
.border-blue-400,
.border-blue-500 {
    border-color: #d1d5db !important;
}

.ring-blue-500,
.focus\:ring-blue-500:focus {
    --tw-ring-color: #000000 !important;
}

.focus\:border-blue-500:focus {
    border-color: #000000 !important;
}

/* Tab/Filter buttons - Black when active */
.bg-blue-600.text-white,
button.bg-blue-600 {
    background-color: #000000 !important;
    color: #ffffff !important;
}

/* Hover states for tabs/filters */
.hover\:bg-slate-50:hover {
    background-color: #f9fafb !important;
}

.hover\:bg-blue-50:hover {
    background-color: #ffffff !important;
}

.hover\:text-blue-600:hover,
.hover\:text-blue-700:hover {
    color: #000000 !important;
}

.hover\:border-blue-500:hover {
    border-color: #000000 !important;
}

/* Badge and accent colors */
.bg-blue-100.text-blue-800 {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #e5e7eb !important;
}

/* Links and clickable text */
a.text-blue-600,
a.text-blue-700,
a.text-blue-800,
.text-blue-600,
.text-blue-700,
.text-blue-800 {
    color: #000000 !important;
}

a.text-blue-600:hover,
a.text-blue-700:hover,
a.text-blue-800:hover,
.text-blue-600:hover,
.text-blue-700:hover,
.text-blue-800:hover {
    color: #dc2626 !important;
}

/* Recipe list items and clickable elements */
.font-medium.text-gray-700,
.text-gray-700.group-hover\:text-blue-700,
.group-hover\:text-blue-700 {
    color: #1f2937 !important;
}

/* Hover state for recipe items */
.group:hover .group-hover\:text-blue-700,
.group:hover .group-hover\:text-black,
.group:hover .text-gray-700 {
    color: #000000 !important;
}

.group-hover\:text-black {
    transition: color 0.15s ease;
}

/* Status badges - make neutral */
.bg-green-100.text-green-700 {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
}

.bg-green-100.text-green-800 {
    background-color: #f3f4f6 !important;
    color: #1f2937 !important;
}

/* Remove all colored badges */
.bg-purple-100,
.bg-indigo-100,
.bg-teal-100 {
    background-color: #f3f4f6 !important;
}

.text-purple-600,
.text-purple-700,
.text-indigo-600,
.text-indigo-700,
.text-teal-600,
.text-teal-700 {
    color: #1f2937 !important;
}

/* Orange/warning colors to neutral */
.text-orange-600,
.text-orange-700,
.bg-orange-100 {
    background-color: #f3f4f6 !important;
    color: #1f2937 !important;
}

/* Ring colors for inputs */
.ring-2.ring-blue-500 {
    --tw-ring-color: #000000 !important;
}

/* Active states for filters/tabs */
.bg-blue-50.ring-1.ring-blue-300 {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Chart and icon colors */
.text-blue-600 svg,
.text-blue-700 svg,
.text-purple-600 svg,
.text-green-600 svg,
.text-orange-600 svg {
    color: #000000 !important;
}

/* Icon backgrounds in KPI cards */
.bg-blue-100,
.bg-purple-100,
.bg-orange-100,
.bg-green-100 {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
}

/* Icon colors in cards */
.text-blue-600,
.text-purple-600,
.text-orange-600,
.text-green-600 {
    color: #000000 !important;
}

/* Success/Info messages */
.bg-green-50 {
    background-color: #f9fafb !important;
}

.bg-blue-50:not(.recipe-item):not([onclick*="loadRecipeDetails"]) {
    background-color: #f9fafb !important;
}

.text-green-600,
.text-green-700,
.text-green-800 {
    color: #1f2937 !important;
}

/* Percentage badges and highlights */
.text-green-600.bg-green-50 {
    background-color: #f3f4f6 !important;
    color: #1f2937 !important;
}

/* Border colors */
.border-green-200,
.border-green-300,
.border-orange-200,
.border-orange-300,
.border-purple-200,
.border-purple-300 {
    border-color: #e5e7eb !important;
}

/* Remove all accent colors from hovers */
.hover\:bg-gray-50:hover {
    background-color: #f9fafb !important;
}

.hover\:bg-green-100:hover {
    background-color: #f3f4f6 !important;
}

.hover\:bg-blue-100:hover {
    background-color: #ffffff !important;
}

/* Table row highlights */
.hover\:bg-blue-50:hover {
    background-color: #ffffff !important;
}

/* Recipe list selected state */
div[onclick*="loadRecipeDetails"].bg-blue-50 {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

div[onclick*="loadRecipeDetails"].bg-blue-50 * {
    color: #000000 !important;
}

/* Group card hover effects */
.group:hover {
    border-color: #000000 !important;
}

/* Ensure all icons are black */
svg.text-blue-600,
svg.text-purple-600,
svg.text-green-600,
svg.text-orange-600 {
    color: #000000 !important;
}

/* Status badges - neutral gray theme */
.bg-green-100.text-green-800,
.bg-orange-100.text-orange-800,
.bg-red-100.text-red-800,
.bg-yellow-100.text-yellow-800 {
    background-color: #f3f4f6 !important;
    color: #1f2937 !important;
    border: 1px solid #d1d5db !important;
}

/* Critical status - keep red for urgency */
.bg-red-100.text-red-800 {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
}

/* Warning status */
.bg-orange-100.text-orange-800,
.bg-yellow-100.text-yellow-800 {
    background-color: #fef3c7 !important;
    color: #92400e !important;
}

/* "Tpl" and "User" badges in recipe list */
.bg-gray-200.text-gray-600,
.bg-green-100.text-green-700 {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
}

/* Focus and active input borders */
input:focus,
select:focus,
textarea:focus {
    border-color: #000000 !important;
    --tw-ring-color: #000000 !important;
}

/* Scrollbar styling */
::-webkit-scrollbar-thumb {
    background: #9ca3af !important;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280 !important;
}

/* Comprehensive catch-all for any remaining blue elements */
[class*="text-blue"]:not(.text-blue-600):not(.text-blue-700):not(.text-blue-800) {
    color: #000000 !important;
}

[class*="bg-blue"]:not(.bg-blue-600):not(button) {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
}

[class*="border-blue"] {
    border-color: #e5e7eb !important;
}

[class*="ring-blue"] {
    --tw-ring-color: #e5e7eb !important;
}

/* Modal and toast backgrounds */
.bg-white.rounded-lg.shadow-xl {
    border: 1px solid #e5e7eb !important;
}

/* Ensure dropdown and select elements are styled */
select option:checked {
    background-color: #000000 !important;
    color: #ffffff !important;
}

/* Links in content should be black */
a:not([class*="nav"]) {
    color: #000000 !important;
    text-decoration: none;
}

a:not([class*="nav"]):hover {
    color: #dc2626 !important;
}

/* Disable any blue animations or transitions */
*[class*="blue"] {
    transition-property: background-color, border-color, color !important;
}

/* Recipe item styles */
.recipe-item {
    position: relative;
    transition: all 0.2s ease;
}

.recipe-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-top: 0px solid #dc2626;
    border-right: 0px solid transparent;
    transition: all 0.2s ease;
    border-radius: 0.5rem 0 0 0;
}

.recipe-item:hover::before {
    border-top: 20px solid #dc2626;
    border-right: 20px solid transparent;
}

.recipe-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
}

.recipe-item.active {
    background: #ffffff !important;
    border-color: #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.recipe-item.active .recipe-item-text {
    color: #000000 !important;
    font-weight: 600;
}

.recipe-item.active:hover .recipe-item-text {
    color: #000000 !important;
}

.recipe-item:not(.active) .recipe-item-text {
    color: #1f2937 !important;
}

.recipe-item:not(.active):hover .recipe-item-text {
    color: #000000 !important;
    font-weight: 500;
}

/* FINAL OVERRIDE: Force white background with red border on active nav items */
a.nav-item.bg-slate-800,
.nav-item.bg-slate-800,
#sidebar a.nav-item.bg-slate-800,
#sidebar .nav-item.bg-slate-800,
#sidebar a.bg-slate-800,
#sidebar .bg-slate-800.nav-item {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border: 2px solid #dc2626 !important;
    border-radius: 0.75rem !important;
    color: #000000 !important;
}

/* Force black icons and text on active items */
a.nav-item.bg-slate-800 svg,
.nav-item.bg-slate-800 svg,
#sidebar a.nav-item.bg-slate-800 svg,
#sidebar .nav-item.bg-slate-800 svg,
a.nav-item.bg-slate-800 span,
.nav-item.bg-slate-800 span,
#sidebar a.nav-item.bg-slate-800 span,
#sidebar .nav-item.bg-slate-800 span {
    color: #000000 !important;
    stroke: #000000 !important;
}

/* Prevent blue hover states on active items */
a.nav-item.bg-slate-800:hover,
.nav-item.bg-slate-800:hover,
#sidebar a.nav-item.bg-slate-800:hover,
#sidebar .nav-item.bg-slate-800:hover,
#sidebar a.bg-slate-800:hover,
#sidebar .bg-slate-800.nav-item:hover {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border: 2px solid #dc2626 !important;
    border-radius: 0.75rem !important;
}

/* Keep icons and text black on hover for active items */
a.nav-item.bg-slate-800:hover svg,
.nav-item.bg-slate-800:hover svg,
#sidebar a.nav-item.bg-slate-800:hover svg,
#sidebar .nav-item.bg-slate-800:hover svg,
a.nav-item.bg-slate-800:hover span,
.nav-item.bg-slate-800:hover span,
#sidebar a.nav-item.bg-slate-800:hover span,
#sidebar .nav-item.bg-slate-800:hover span {
    color: #000000 !important;
    stroke: #000000 !important;
}


/* ====================================================================
 * Searchable Dropdown Component
 * ==================================================================== */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.searchable-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 42px;
}

.searchable-dropdown-trigger:hover {
    border-color: #94a3b8;
}

.searchable-dropdown-trigger:focus,
.searchable-dropdown.open .searchable-dropdown-trigger {
    border-color: #000000 !important;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    outline: none;
}

.searchable-dropdown-text {
    font-size: 0.875rem;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.searchable-dropdown-text.placeholder {
    color: #94a3b8;
}

.searchable-dropdown-arrow {
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    flex-shrink: 0;
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
}

.searchable-dropdown.open .searchable-dropdown-arrow {
    transform: rotate(180deg);
}

.searchable-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 50;
    overflow: hidden;
}

.searchable-dropdown-search-wrap {
    position: relative;
    padding: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.searchable-dropdown-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    pointer-events: none;
}

.searchable-dropdown-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #334155;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.searchable-dropdown-search:focus {
    border-color: #000000 !important;
    background: #ffffff;
    box-shadow: none !important;
}

.searchable-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    max-height: 220px;
    overflow-y: auto;
}

.searchable-dropdown-list li {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
    transition: background-color 0.1s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-dropdown-list li:hover {
    background-color: #f1f5f9;
}

.searchable-dropdown-list li.active {
    background-color: #000000;
    color: #ffffff;
}

.searchable-dropdown-list li.no-results {
    color: #94a3b8;
    cursor: default;
    text-align: center;
    padding: 1rem 0.75rem;
    font-style: italic;
}

.searchable-dropdown-list li.no-results:hover {
    background-color: transparent;
}

/* ====================================================================
 * JITTER FIX DOCUMENTATION
 * ====================================================================
 * 
 * Problem: Layout shifted a few millimeters (left/right) when clicking
 * sidebar navigation items, causing visible jitter/judder.
 * 
 * ROOT CAUSES IDENTIFIED:
 * 
 * 1. INCONSISTENT BORDERS (Primary cause)
 *    - Active items had: border: 2px solid #dc2626
 *    - Inactive items had: border-left: 3px solid transparent (or no border)
 *    - Different border widths/sides = different element dimensions
 *    - Fix: All nav-items now have "border: 2px solid transparent" 
 *           (same width in all states, only color changes)
 * 
 * 2. FONT-WEIGHT CHANGE (Secondary cause)
 *    - Active items had: font-weight: 600
 *    - Inactive items had: font-weight: 500
 *    - Bolder text = wider text = layout shift
 *    - Fix: All nav-items now use "font-weight: 500" consistently
 *           (active state uses color only for distinction)
 * 
 * 3. HOVER TRANSFORMS (Tertiary cause)
 *    - Hover had: transform: translateX(1px) and translateX(-2px)
 *    - This caused horizontal shifting on hover
 *    - Fix: Removed all translateX transforms on hover
 * 
 * 4. TRANSITION: ALL (Contributing factor)
 *    - "transition: all" animates ALL properties including width/height
 *    - Can cause unexpected layout shifts
 *    - Fix: Changed to specific properties only:
 *           transition: background-color 0.2s, border-color 0.2s, color 0.2s
 * 
 * 5. SCROLLBAR APPEARANCE (Potential cause)
 *    - Tab content height changes could show/hide scrollbar
 *    - Scrollbar width causes horizontal layout shift
 *    - Fix: Added "scrollbar-gutter: stable" to #main-content
 * 
 * CHANGES MADE (Summary):
 * CSS Fixes:
 * - Lines 98-106: Added consistent 2px transparent border to all nav-items
 * - Line 105: Added outline: none and box-sizing: border-box
 * - Line 487: Removed border-left: 3px, using 2px all-around border instead
 * - Line 489: Changed transition from "all" to specific properties
 * - Line 508: Fixed font-weight to 500 (was 600 for active)
 * - Line 510: Added white-space: nowrap to prevent text wrapping
 * - Line 519: Changed border-left to border on hover
 * - Line 438, 501: Changed SVG transition from "all" to "color, transform"
 * - Line 439, 502: Added flex-shrink: 0 to SVG icons
 * - Line 443, 605: Removed hover translateX transforms
 * - Line 588-592: Removed conflicting margin/padding overrides (use Tailwind classes)
 * - Line 21: Added scrollbar-gutter: stable to #main-content
 * 
 * HTML Fixes:
 * - Lines 1212-1247: Removed "transition-all" from all nav item inline classes
 * 
 * JavaScript Fixes:
 * - Lines 2291-2292: Removed "transition-all" from className strings
 * 
 * RESULT:
 * Layout is now pixel-stable across all tab switches and hover states.
 * No visible jitter, shift, or judder when clicking sidebar items.
 * 
 * ==================================================================== */

/* ====================================================================
 * MOBILE RESPONSIVE STYLES
 * ==================================================================== */

/* Phones & small tablets (below 768px) */
@media (max-width: 767px) {
    /* Remove fixed left padding - sidebar becomes an overlay */
    body > div.flex.h-screen {
        padding-left: 0 !important;
    }
    body.sidebar-collapsed > div.flex.h-screen {
        padding-left: 0 !important;
    }

    /* Sidebar: off-screen by default, slides in as overlay */
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 50;
        width: 256px !important;
        min-width: 256px !important;
        max-width: 256px !important;
    }
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    /* On mobile, ignore the "collapsed" desktop state */
    #sidebar.collapsed {
        width: 256px !important;
        min-width: 256px !important;
        max-width: 256px !important;
    }
    #sidebar.collapsed .nav-text {
        display: inline !important;
    }
    #sidebar.collapsed .logo-full {
        display: flex !important;
    }

    /* Backdrop behind sidebar */
    .mobile-sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 45;
        display: none;
    }
    .mobile-sidebar-backdrop.active {
        display: block;
    }

    /* Main content: reduce padding */
    #main-content {
        padding: 1rem !important;
    }

    /* Header: adjust for hamburger button */
    #top-header {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Toast notifications: full width on mobile */
    #toast-container {
        left: 10px;
        right: 10px;
    }
    .toast {
        max-width: 100%;
    }

    /* Allow body to scroll on mobile */
    html, body {
        overflow: auto !important;
        height: auto !important;
        min-height: 100%;
    }

    /* Main layout: allow vertical scroll */
    .flex.h-screen.overflow-hidden {
        overflow: auto !important;
        height: auto !important;
        min-height: 100vh;
    }
    .flex-1.flex.flex-col.overflow-hidden {
        overflow: visible !important;
        min-height: 100vh;
    }

    /* Global table scroll fix - any direct parent of a table becomes scrollable */
    *:has(> table) {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Force single-column grids on mobile */
    .grid.grid-cols-2,
    .grid.grid-cols-3,
    .grid.grid-cols-4,
    .grid.grid-cols-5 {
        grid-template-columns: 1fr !important;
    }

    /* Modals: full-width on mobile */
    .bg-white.rounded-lg.shadow-xl,
    .bg-white.rounded-xl.shadow-xl {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 10px auto !important;
    }

    /* Larger tap targets for touch */
    button, a.nav-item, select, input[type="text"], input[type="email"],
    input[type="password"], input[type="number"], input[type="search"] {
        min-height: 44px;
    }

    /* Hide sidebar toggle text on mobile; hamburger is in header */
    #sidebar-toggle-btn .nav-text {
        display: none;
    }

    /* Page title: slightly smaller on mobile */
    #page-title {
        font-size: 1rem !important;
    }

    /* KPI cards: full-width stack */
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }

    /* Collapsed sidebar overrides should not apply on mobile */
    #sidebar.collapsed .nav-item {
        width: auto !important;
        height: auto !important;
        justify-content: flex-start !important;
        padding: 0.75rem 1rem !important;
        margin: 0.25rem 0.75rem !important;
        border-radius: 0.5rem !important;
    }
    #sidebar.collapsed .nav-item svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
        margin: 0 !important;
    }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Full sidebar menu on tablets */
    #sidebar,
    #sidebar.collapsed {
        width: 256px !important;
        min-width: 256px !important;
        max-width: 256px !important;
    }
    body > div.flex.h-screen,
    body.sidebar-collapsed > div.flex.h-screen {
        padding-left: 256px !important;
    }
    #sidebar .nav-text,
    #sidebar.collapsed .nav-text {
        display: inline !important;
    }
    #sidebar .logo-full,
    #sidebar.collapsed .logo-full {
        display: flex !important;
    }
    #sidebar .logo-mini,
    #sidebar.collapsed .logo-mini {
        display: none !important;
    }
    #sidebar .nav-tooltip {
        display: none !important;
    }
    #sidebar-toggle-btn {
        display: none !important;
    }
    #main-content {
        padding: 1.25rem !important;
    }
    #sidebar .nav-item,
    #sidebar.collapsed .nav-item {
        justify-content: flex-start !important;
        padding: 0.75rem 1rem !important;
        margin: 0.25rem 0.75rem !important;
        border-radius: 0.625rem !important;
    }

    /* Tablet-friendly submenu layout across modules */
    #main-content [id$="subtabs"],
    #main-content [id*="submenu-tabs"],
    #main-content #customs-subtabs,
    #main-content .qc-submenu {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.5rem !important;
        border-bottom: 0 !important;
    }
    #main-content [id$="subtabs"] > button,
    #main-content [id$="subtabs"] > a,
    #main-content [id*="submenu-tabs"] > button,
    #main-content [id*="submenu-tabs"] > a,
    #main-content #customs-subtabs > button,
    #main-content #customs-subtabs > a,
    #main-content .qc-submenu > button,
    #main-content .qc-submenu > a {
        width: 100% !important;
        min-height: 44px !important;
        text-align: center !important;
        justify-content: center !important;
        border-width: 1px !important;
        border-radius: 0.75rem !important;
        margin: 0 !important;
        padding: 0.625rem 0.75rem !important;
        white-space: normal !important;
        line-height: 1.2 !important;
    }
    #main-content #accounting-subtabs {
        border-bottom: 0 !important;
    }
}

/* Mixing section form sheets: readable and touch-friendly on tablets */
#view-mixing-section .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}
#view-mixing-section table th,
#view-mixing-section table td {
    vertical-align: middle;
}
@media (min-width: 768px) and (max-width: 1023px) {
    #ms-subtabs {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
        gap: 0.5rem;
    }
    #view-mixing-section input,
    #view-mixing-section select,
    #view-mixing-section button,
    #view-mixing-section textarea {
        min-height: 42px;
    }
}

/* ==================================================================
   Demo Plant - Sidebar (ERP minimalism · white / black / red)
   Appended last so cascade order beats earlier dark-theme rules.
   ================================================================== */

#sidebar {
    background: #ffffff !important;
    color: #262626 !important;
    border-right: 1px solid #e5e5e5 !important;
    box-shadow: none !important;
    font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif !important;
    letter-spacing: -0.005em;
}
#sidebar *,
#sidebar a,
#sidebar span,
#sidebar div {
    color: inherit !important;
}

/* ---- Header / brand ---- */
#sidebar .p-6.border-b {
    background: #ffffff !important;
    border-bottom: 1px solid #ededed !important;
    padding: 1.1rem 1.25rem !important;
    min-height: 64px;
}
.logo-full {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.logo-full img {
    width: 28px !important;
    height: 28px !important;
    border-radius: 4px !important;
    object-fit: cover;
    filter: none !important;
}
.logo-full > div,
.logo-full .sb-brand-title {
    color: #0a0a0a !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase;
    text-shadow: none !important;
    line-height: 1.25;
}
.sb-brand-sub {
    display: block;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: #a3a3a3 !important;
    text-transform: uppercase;
    margin-top: 2px;
}
#sidebar.collapsed .logo-full { display: none !important; }
#sidebar:not(.collapsed) .logo-mini { display: none !important; }
#sidebar.collapsed .logo-mini {
    display: flex !important;
    justify-content: center;
    align-items: center;
}
.logo-mini img {
    width: 28px !important;
    height: 28px !important;
    border-radius: 4px !important;
    object-fit: cover;
}

/* ---- Toggle button ---- */
#sidebar-toggle-btn {
    width: 30px !important;
    height: 30px !important;
    border: none !important;
    border-radius: 6px !important;
    background: transparent !important;
    box-shadow: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 140ms ease;
}
#sidebar-toggle-btn:hover {
    background: #f5f5f5 !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}
#sidebar-toggle-btn svg,
#sidebar-toggle-icon {
    width: 15px !important;
    height: 15px !important;
    color: #737373 !important;
    stroke: #737373 !important;
}
#sidebar-toggle-btn:hover svg {
    color: #0a0a0a !important;
    stroke: #0a0a0a !important;
}

/* ---- Section label ---- */
.sb-section {
    padding: 1rem 1.25rem 0.35rem;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    color: #a3a3a3 !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sb-section::before {
    content: '';
    width: 4px;
    height: 4px;
    background: #d72c2c !important;
    display: inline-block;
    flex-shrink: 0;
}
#sidebar.collapsed .sb-section {
    display: none !important;
}

/* ---- Nav items ---- */
#sidebar .nav-item,
#sidebar a.nav-item {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 0.7rem;
    margin: 0 0.6rem 0.1rem !important;
    padding: 0.5rem 0.7rem !important;
    border: none !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: #404040 !important;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -0.005em;
    box-sizing: border-box !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
#sidebar .nav-item svg,
#sidebar a.nav-item svg {
    width: 17px !important;
    height: 17px !important;
    color: #737373 !important;
    stroke: #737373 !important;
    fill: none !important;
    flex-shrink: 0 !important;
    stroke-width: 1.6 !important;
    transition: color 140ms ease, stroke 140ms ease;
}
#sidebar .nav-item .nav-text,
#sidebar a.nav-item .nav-text,
#sidebar:not(.collapsed) .nav-item span.nav-text {
    color: #404040 !important;
    font-weight: 500 !important;
    white-space: nowrap;
    font-size: 13.5px;
}

/* Hover on inactive */
#sidebar .nav-item:hover:not(.bg-slate-800),
#sidebar a.nav-item:hover:not(.bg-slate-800),
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) {
    background: #fafafa !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
}
#sidebar .nav-item:hover:not(.bg-slate-800) svg,
#sidebar a.nav-item:hover:not(.bg-slate-800) svg,
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) svg {
    color: #0a0a0a !important;
    stroke: #0a0a0a !important;
}
#sidebar .nav-item:hover:not(.bg-slate-800) .nav-text,
#sidebar a.nav-item:hover:not(.bg-slate-800) .nav-text,
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) span.nav-text,
#sidebar:not(.collapsed) a.nav-item:hover:not(.bg-slate-800) span.nav-text,
#sidebar .nav-item:hover:not(.bg-slate-800) *,
#sidebar a.nav-item:hover:not(.bg-slate-800) * {
    color: #0a0a0a !important;
}

/* Active state (uses existing .bg-slate-800 marker class set by JS) */
#sidebar .nav-item.bg-slate-800,
#sidebar a.nav-item.bg-slate-800,
#sidebar a.bg-slate-800 {
    background: #fafafa !important;
    border: none !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    color: #0a0a0a !important;
}
#sidebar .nav-item.bg-slate-800::before,
#sidebar a.nav-item.bg-slate-800::before {
    content: '';
    position: absolute;
    left: -0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: #d72c2c !important;
    border-radius: 0 2px 2px 0;
}
#sidebar .nav-item.bg-slate-800 svg,
#sidebar a.nav-item.bg-slate-800 svg,
#sidebar a.bg-slate-800 svg {
    color: #d72c2c !important;
    stroke: #d72c2c !important;
    fill: none !important;
}
#sidebar .nav-item.bg-slate-800 .nav-text,
#sidebar a.nav-item.bg-slate-800 .nav-text,
#sidebar a.bg-slate-800 .nav-text,
#sidebar:not(.collapsed) .nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.bg-slate-800 span.nav-text,
#sidebar .nav-item.bg-slate-800 *,
#sidebar a.nav-item.bg-slate-800 * {
    color: #0a0a0a !important;
    font-weight: 600 !important;
}
#sidebar .nav-item.bg-slate-800:hover,
#sidebar a.nav-item.bg-slate-800:hover {
    background: #fafafa !important;
}

/* ---- Collapsed sidebar ---- */
#sidebar.collapsed {
    background: #ffffff !important;
    border-right: 1px solid #e5e5e5 !important;
    box-shadow: none !important;
}
#sidebar.collapsed .p-6.border-b {
    padding: 1.1rem 0 !important;
    justify-content: center !important;
    gap: 0.25rem;
    background: #ffffff !important;
    border-bottom: 1px solid #ededed !important;
}
#sidebar.collapsed .p-6.border-b button {
    width: 32px !important;
    height: 32px !important;
    border: none !important;
    background: transparent !important;
    margin: 0 !important;
}
#sidebar.collapsed .p-6.border-b button:hover {
    background: #f5f5f5 !important;
    border: none !important;
    transform: none !important;
    box-shadow: none !important;
}
#sidebar.collapsed .p-6.border-b button svg {
    width: 15px !important;
    height: 15px !important;
    color: #737373 !important;
    stroke: #737373 !important;
}
#sidebar.collapsed .p-6.border-b button:hover svg {
    color: #0a0a0a !important;
    stroke: #0a0a0a !important;
    transform: none !important;
}

#sidebar.collapsed .nav-text { display: none !important; }
#sidebar.collapsed .nav-item,
#sidebar.collapsed a.nav-item {
    justify-content: center !important;
    margin: 2px auto !important;
    padding: 0 !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    gap: 0 !important;
}
#sidebar.collapsed .nav-item svg,
#sidebar.collapsed a.nav-item svg {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    color: #737373 !important;
    stroke: #737373 !important;
}
#sidebar.collapsed .nav-item:hover:not(.bg-slate-800),
#sidebar.collapsed a.nav-item:hover:not(.bg-slate-800) {
    background: #fafafa !important;
    border: none !important;
    box-shadow: none !important;
}
#sidebar.collapsed .nav-item.bg-slate-800,
#sidebar.collapsed a.nav-item.bg-slate-800 {
    background: #fafafa !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 6px !important;
}
#sidebar.collapsed .nav-item.bg-slate-800::before,
#sidebar.collapsed a.nav-item.bg-slate-800::before {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 2px 2px 0;
}
#sidebar.collapsed .nav-item.bg-slate-800 svg,
#sidebar.collapsed a.nav-item.bg-slate-800 svg {
    color: #d72c2c !important;
    stroke: #d72c2c !important;
}

/* ---- Tooltip (collapsed only) ---- */
#sidebar.collapsed .nav-tooltip {
    display: block !important;
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    padding: 6px 10px;
    background: #0a0a0a !important;
    color: #ffffff !important;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 140ms ease, transform 140ms ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
#sidebar.collapsed .nav-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-right-color: #0a0a0a;
}
#sidebar.collapsed .nav-item:hover .nav-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
#sidebar:not(.collapsed) .nav-tooltip { display: none !important; }

/* ---- Nav container ---- */
#sidebar nav,
#sidebar-nav {
    padding-top: 0.5rem !important;
    padding-bottom: 1rem !important;
    background: #ffffff !important;
}

/* ---- Main header (top bar) - keep in sync with sidebar typography ---- */
#top-header {
    background: #ffffff !important;
    border-bottom: 1px solid #ededed !important;
    box-shadow: none !important;
    font-family: 'Geist', system-ui, -apple-system, sans-serif !important;
}
#page-title {
    color: #0a0a0a !important;
    font-weight: 600 !important;
    letter-spacing: -0.011em;
}

/* ---- Beat old dark-theme high-specificity rules (lines 548-605) ---- */
#sidebar:not(.collapsed) a.nav-item,
#sidebar:not(.collapsed) a.nav-item *,
#sidebar:not(.collapsed) .nav-item * {
    color: #404040 !important;
}
#sidebar:not(.collapsed) a.nav-item svg,
#sidebar:not(.collapsed) .nav-item svg {
    color: #737373 !important;
    stroke: #737373 !important;
}
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) {
    background: #fafafa !important;
    border: none !important;
    box-shadow: none !important;
}
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) svg,
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) span.nav-text,
#sidebar:not(.collapsed) a.nav-item:hover:not(.bg-slate-800) * {
    color: #0a0a0a !important;
}
#sidebar:not(.collapsed) .nav-item:hover:not(.bg-slate-800) svg {
    stroke: #0a0a0a !important;
}
#sidebar:not(.collapsed) .nav-item.bg-slate-800,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800,
#sidebar:not(.collapsed) a.bg-slate-800 {
    background: #fafafa !important;
    border: none !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}
#sidebar:not(.collapsed) .nav-item.bg-slate-800:hover,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800:hover {
    background: #f5f5f5 !important;
}
#sidebar:not(.collapsed) .nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800 span.nav-text,
#sidebar:not(.collapsed) a.bg-slate-800 span.nav-text {
    color: #0a0a0a !important;
    font-weight: 600 !important;
}
#sidebar:not(.collapsed) .nav-item.bg-slate-800 svg,
#sidebar:not(.collapsed) a.nav-item.bg-slate-800 svg,
#sidebar:not(.collapsed) a.bg-slate-800 svg {
    color: #d72c2c !important;
    stroke: #d72c2c !important;
    fill: none !important;
}

/* ---- Main content area background - neutral canvas ---- */
body { background-color: #ffffff !important; }
#main-content { background-color: #ffffff !important; }

/* ============================================================================
   Mixing Section CIP - styled blocks (mirrors QC CIP visual language)
   ============================================================================ */
.ms-cip-block {
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}
.ms-cip-block + .ms-cip-block { margin-top: 12px; }

.ms-cip-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ms-cip-panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.ms-cip-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ms-cip-page-count {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
}
.ms-cip-inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ms-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.ms-btn:hover { background: #f1f5f9; }
.ms-btn-primary {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}
.ms-btn-primary:hover { background: #1e293b; }
.ms-btn-danger {
  background: #ffffff;
  border-color: #fecaca;
  color: #b91c1c;
}
.ms-btn-danger:hover { background: #fef2f2; }

.ms-cip-add-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ms-cip-blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ms-cip-attachments-wrap {
  margin-bottom: 10px;
  min-width: 260px;
}
.ms-cip-attachments-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}
.ms-cip-attachments-input {
  display: block;
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
}

.ms-cip-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ms-cip-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}
.ms-cip-title {
  width: 100%;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  color: #0b1220;
  margin: 0;
}
.ms-cip-doc {
  width: 100%;
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  color: #334155;
}
.ms-cip-order-badge {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 999px;
  font-size: 11px;
  color: #334155;
  padding: 2px 8px;
  white-space: nowrap;
}
.ms-cip-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ms-cip-mini-btn {
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.ms-cip-mini-btn:hover { background: #f1f5f9; }
.ms-cip-mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.ms-cip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.ms-cip-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ms-cip-field > span {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.ms-cip-input {
  width: 100%;
  padding: 7px 9px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  outline: none;
}
select.ms-cip-input { appearance: auto; -webkit-appearance: auto; }
.ms-cip-input:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148,163,184,0.15);
}
.ms-cip-input[readonly] {
  background: #f8fafc;
  color: #64748b;
}

.ms-cip-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 8px;
}
.ms-cip-table th,
.ms-cip-table td {
  border: 1px solid #dbe2ea;
  padding: 6px;
  font-size: 12px;
  vertical-align: top;
}
.ms-cip-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}
.ms-cip-sign-cell {
  min-height: 32px;
  background: #f8fafc;
}
.ms-cip-section-title {
  margin: 8px 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #334155;
}

@media (max-width: 768px) {
  .ms-cip-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .ms-cip-grid { grid-template-columns: 1fr; }
}
.ms-cip-sign-cell { vertical-align: top; }

/* ---- Sugar Dissolver page sub-tabs ---- */
.sd-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}
.sd-subtab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.sd-subtab-btn:hover { background: #f8fafc; }
.sd-subtab-btn.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
}
