        :root {
            /* Main elements */
            --bg-gradient-start: #0b6b5a;
            --bg-gradient-end: #11998e;
            --container-bg: #ffffffee;
            --teal-primary: #11998e;
            /* RGB companion for alpha blends (keeps highlights consistent across browsers) */
            --teal-primary-rgb: 17, 153, 142;
            --teal-secondary: #38ef7d;
            --accent-color: #ff6b6b;
            --shadow-color: rgba(0, 0, 0, 0.15);
            
            /* Header */
            --header-gradient-start: rgba(17, 153, 142, 0.9);
            --header-gradient-end: rgba(56, 239, 125, 0.95);

            /* Text */
            --text-primary: #333333;
            --text-secondary: #555555;
            --text-light: #ffffff;
            --chart-label-color: #333333;  /* Chart axis labels */

            /* Cards */
            --card-bg: #ffffff;
            --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            --card-border: #e5e7eb;
            --header-columns-bg: rgb(248, 249, 250);

            /* Status Colors */
            --status-critical: #ff5454;
            --status-severe: #ff8400;
            --status-moderate: #ecdd16;
            --status-resolved: #5cb85c;
            
            /* Scroll Arrows */
            --scroll-arrows-bg: rgba(17, 153, 142, 0.15);
            --scroll-arrows-border: rgba(17, 153, 142, 0.6);
            --scroll-arrows-bg-hover: rgba(56, 239, 125, 0.3);
            --scroll-arrows-border-hover: rgba(56, 239, 125, 0.5);

            /* Standard Spacing */
            --spacing-xs: clamp(4px, 0.8vw, 6px);
            --spacing-sm: clamp(8px, 1.5vw, 10px);
            --spacing-md: clamp(12px, 2vw, 15px);
            --spacing-lg: clamp(20px, 3vw, 25px);
            --spacing-xl: clamp(20px, 4vw, 30px);

            /* Tooltips - Matching Shortage Bulletin Style */
            --tooltip-text-color: rgb(66, 66, 66);
            --tooltip-bg: rgba(182, 203, 223, 0.747);
            
            /* Metric Cards - NEW */
            --metric-icon-stockout: #ff8400;
            --metric-icon-waste: #e74c3c;
            --metric-icon-unused: #9b59b6;
            --metric-icon-excessive: #f39c12;
            --metric-hover-bg: rgba(17, 153, 142, 0.05);
            --metric-hover-border: rgba(17, 153, 142, 0.3);
            
            /* Chart Colors - NEW */
            --chart-primary: #11998e;
            --chart-secondary: #38ef7d;
            --chart-bar-gradient-start: rgba(17, 153, 142, 0.8);
            --chart-bar-gradient-end: rgba(56, 239, 125, 0.6);
            --chart-bar-hover: rgba(17, 153, 142, 0.95);
            --chart-text: #333333;
            --chart-axis: #999999;
            --chart-grid: #e5e7eb;
            
            /* Cost Chart Bar Colors */
            --cost-bar-gradient-start: #11998e;
            --cost-bar-gradient-end: #0d7a71;
            --cost-bar-hover-start: #FF7F50;
            --cost-bar-hover-end: #FF6347;
            --cost-bar-selected-start: #38b2ac;
            --cost-bar-selected-end: #2c7a7b;
            --cost-bar-shadow: rgba(17, 153, 142, 0.2);
            --cost-bar-shadow-hover: rgba(255, 127, 80, 0.4);
            --cost-bar-shadow-selected: rgba(56, 178, 172, 0.4);
            
            /* Cost Chart Navigation Colors */
            --cost-nav-label-color: #FF7F50;
            --cost-nav-bg-start: rgba(17, 153, 142, 1);
            --cost-nav-bg-end: rgba(17, 153, 142, 0);
            
            /* Cost Chart Label Colors */
            --cost-label-normal: #333333;
            --cost-label-hover: #2c7a7b;
            --cost-label-selected: #2c7a7b;
            
            /* Cost Chart Grid Colors */
            --cost-grid-line: rgba(200, 200, 200, 0.3);
            --cost-scale-label: #666666;
            
            /* ETA Card Dynamic Colors */
            --eta-past-color: #ff5454;
            --eta-week-color: #ff9800;
            --eta-fortnight-color: #ffc107;
            --eta-none-color: #ff5454;
            
            /* Sankey Chart Colors */
            --sankey-node-color: #11998e;
            --sankey-link-colors: #11998e, #38ef7d;
            --sankey-label-color: #333;
            
            /* Modal - NEW */
            --modal-overlay: rgba(0, 0, 0, 0.7);
            --modal-bg: #ffffff;
            --modal-border: #e5e7eb;
            --modal-header-bg: linear-gradient(135deg, rgba(17, 153, 142, 0.95), rgba(56, 239, 125, 0.85));
            --modal-header-text: #ffffff;
            --modal-close-hover: rgba(255, 255, 255, 0.2);
            --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            
            /* Modal Cards (Info Cards) - NEW */
            --modal-card-bg: #f8f9fa;
            --modal-card-border: #d1d5db;
            --modal-card-bg-alt: #ffffff;
            --modal-card-border-alt: #e5e7eb;
            --section-margin-bottom: 20px;
            --card-padding: 15px;
            --container-padding: 25px;
            --modal-window-bg: #ffffff;
            --modal-shadow-color: rgba(0, 0, 0, 0.5);
            --modal-header-color: linear-gradient(135deg, #0b6b5a 0%, #38ef7d 100%);
            --modal-header-font: #ffffff;
            --modal-close-btn-bg: rgba(0, 0, 0, 0.25);
            
            /* Area Cards in Modals - NEW */
            --area-card-bg: #f8f9fa;
            --area-card-border: #e5e7eb;
            --area-card-hover-bg: rgba(17, 153, 142, 0.05);
            --area-header-text: #333333;
            --area-badge-bg: rgba(17, 153, 142, 0.1);
            --area-badge-text: #11998e;
            
            /* Back Button - NEW */
            --back-button-bg: rgba(17, 153, 142, 0.15);
            --back-button-border: rgba(17, 153, 142, 0.6);
            --back-button-hover-bg: rgba(56, 239, 125, 0.3);
            --back-button-hover-border: rgba(56, 239, 125, 0.8);
            --back-button-text: #11998e;
        }

        body.dark-mode {
            --bg-gradient-start: #1f2a2b;
            --bg-gradient-end: #263334;
            --container-bg: #2b3536ee;
            --teal-primary: #20c8b5;
            /* RGB companion for alpha blends (dark mode) */
            --teal-primary-rgb: 32, 200, 181;
            --teal-secondary: #42e9a0;
            --text-primary: #e6f1f0;
            --text-secondary: #c8d3d3;
            --chart-label-color: #e6f1f0;  /* Chart axis labels */
            --card-bg: #2b3536;
            --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            --card-border: #3f4b4c;
            --header-columns-bg: #343f40;
            
            /* Header Dark Mode */
            --header-gradient-start: rgba(32, 200, 181, 0.55);
            --header-gradient-end: rgba(66, 233, 160, 0.65);
            
            /* Scroll Arrows Dark Mode */
            --scroll-arrows-bg: rgba(32, 200, 181, 0.18);
            --scroll-arrows-border: rgba(32, 200, 181, 0.55);
            --scroll-arrows-bg-hover: rgba(66, 233, 160, 0.25);
            --scroll-arrows-border-hover: rgba(66, 233, 160, 0.45);

            /* Tooltips Dark Mode */
            --tooltip-text-color: #ffffff;
            --tooltip-bg: rgba(52, 58, 64, 0.55);
            
            /* Metric Cards Dark Mode - NEW */
            --metric-hover-bg: rgba(32, 200, 181, 0.08);
            --metric-hover-border: rgba(32, 200, 181, 0.4);
            
            /* Chart Colors Dark Mode - NEW */
            --chart-primary: #20c8b5;
            --chart-secondary: #42e9a0;
            --chart-bar-gradient-start: rgba(32, 200, 181, 0.7);
            --chart-bar-gradient-end: rgba(66, 233, 160, 0.5);
            --chart-bar-hover: rgba(32, 200, 181, 0.9);
            --chart-text: #e6f1f0;
            --chart-axis: #6b7878;
            --chart-grid: #3f4b4c;
            
            /* Cost Chart Bar Colors Dark Mode */
            --cost-bar-gradient-start: #20c8b5;
            --cost-bar-gradient-end: #18a090;
            --cost-bar-hover-start: #FF9970;
            --cost-bar-hover-end: #FF7F67;
            --cost-bar-selected-start: #50d2cc;
            --cost-bar-selected-end: #3caa9b;
            --cost-bar-shadow: rgba(32, 200, 181, 0.3);
            --cost-bar-shadow-hover: rgba(255, 153, 112, 0.5);
            --cost-bar-shadow-selected: rgba(80, 210, 204, 0.5);
            
            /* Cost Chart Navigation Colors Dark Mode */
            --cost-nav-label-color: #FF9970;
            --cost-nav-bg-start: rgba(32, 200, 181, 1);
            --cost-nav-bg-end: rgba(32, 200, 181, 0);
            
            /* Cost Chart Label Colors Dark Mode */
            --cost-label-normal: #c8d3d3;
            --cost-label-hover: #42e9a0;
            --cost-label-selected: #42e9a0;
            
            /* Cost Chart Grid Colors Dark Mode */
            --cost-grid-line: rgba(200, 200, 200, 0.15);
            --cost-scale-label: #8a9a9a;
            
            /* ETA Card Dynamic Colors Dark Mode */
            --eta-past-color: #ff6b6b;
            --eta-week-color: #ffaa33;
            --eta-fortnight-color: #ffd54f;
            --eta-none-color: #ff6b6b;
            
            /* Sankey Chart Colors Dark Mode */
            --sankey-node-color: #20c8b5;
            --sankey-link-colors: #20c8b5, #42e9a0;
            --sankey-label-color: #e6f1f0;
            
            /* Modal Dark Mode - NEW */
            --modal-overlay: rgba(0, 0, 0, 0.85);
            --modal-bg: #2b3536;
            --modal-border: #3f4b4c;
            --modal-header-bg: linear-gradient(135deg, rgba(32, 200, 181, 0.65), rgba(66, 233, 160, 0.55));
            --modal-header-text: #e6f1f0;
            --modal-close-hover: rgba(255, 255, 255, 0.15);
            --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
            
            /* Modal Cards (Info Cards) Dark Mode - NEW */
            --modal-card-bg: #343f40;
            --modal-card-border: #3f4b4c;
            --modal-card-bg-alt: #2b3536;
            --modal-card-border-alt: #3f4b4c;
            --modal-window-bg: #2b3536;
            --modal-shadow-color: rgba(0, 0, 0, 0.55);
            --modal-header-color: linear-gradient(135deg, #0d5a4e 0%, #2fb574 100%);
            --modal-header-font: #e6f1f0;
            --modal-close-btn-bg: rgba(255, 255, 255, 0.08);
            
            /* Area Cards Dark Mode - NEW */
            --area-card-bg: #343f40;
            --area-card-border: #3f4b4c;
            --area-card-hover-bg: rgba(32, 200, 181, 0.08);
            --area-header-text: #e6f1f0;
            --area-badge-bg: rgba(32, 200, 181, 0.15);
            --area-badge-text: #20c8b5;
            
            /* Back Button Dark Mode - NEW */
            --back-button-bg: rgba(32, 200, 181, 0.18);
            --back-button-border: rgba(32, 200, 181, 0.55);
            --back-button-hover-bg: rgba(66, 233, 160, 0.25);
            --back-button-hover-border: rgba(66, 233, 160, 0.7);
            --back-button-text: #20c8b5;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        @keyframes fadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
            min-height: 100vh;
            height: 100vh;
            margin: 0;
            padding: clamp(10px, 2vw, 20px);
            transition: background 0.3s ease, color 0.3s ease;
            overflow: hidden;
        }

        .analytics-container {
            width: 100%;
            height: 100vh;
            max-height: calc(100vh - clamp(30px, 8vw, 40px));
            max-width: 1800px;
            margin: 0;
            background: var(--container-bg);
            border-radius: 12px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            position: relative;
            box-shadow: 0 10px 40px var(--shadow-color);
            transition: background 0.3s ease;

        }
        
        /* Sticky Header */
        .analytics-header {
            background: linear-gradient(135deg, var(--header-gradient-start) 40%, var(--header-gradient-end) 100%);
            color: var(--text-light);
            padding: clamp(15px, 3vw, 20px) clamp(20px, 4vw, 30px);
            position: sticky;
            top: 0;
            z-index: 100;
            -webkit-backdrop-filter: blur(15px);
            backdrop-filter: blur(15px);
            box-shadow: 0 2px 10px var(--shadow-color);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .header-content {
            display: flex;
            align-items: center;
            gap: clamp(12px, 2vw, 20px);
        }
        
        
        .header-icon {
            width: clamp(36px, 5vw, 44px);
            height: clamp(36px, 5vw, 44px);
            background: rgba(255, 255, 255, 0.2);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        
        .header-icon svg {
            width: 60%;
            height: 60%;
            fill: white;
        }
        
        .analytics-header h1 {
            font-size: clamp(1.5em, 4vw, 2em);
            font-weight: 600;
            margin: 0;
        }

        .analytics-content {
            padding: clamp(20px, 4vw, 30px);
            overflow-y: auto;
            overflow-x: hidden;
            flex: 1;
            height: 100%;
            position: relative;
        }

        .analytics-status-notice {
            display: flex;
            flex-direction: column;
            gap: 4px;
            margin-bottom: 16px;
            padding: 10px 14px;
            border-radius: 12px;
            border: 1px solid rgba(242, 140, 40, 0.35);
            background: linear-gradient(135deg, rgba(242, 140, 40, 0.12), rgba(255, 214, 102, 0.08));
            color: var(--text-primary);
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
        }

        .analytics-status-notice-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }

        .analytics-status-notice-title {
            font-size: 13px;
            font-weight: 700;
            letter-spacing: 0.02em;
            text-transform: uppercase;
            color: #b66100;
        }

        .analytics-status-notice-expand-btn {
            width: 22px;
            height: 22px;
            border-radius: 5px;
            border: 1px solid rgba(182, 97, 0, 0.35);
            background: rgba(255, 255, 255, 0.56);
            color: #b66100;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            padding: 0;
            flex-shrink: 0;
        }

        .analytics-status-notice-expand-btn svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            fill: none;
            stroke-width: 1.75;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .analytics-status-notice-expand-btn .status-icon-collapse {
            display: none;
        }

        .analytics-status-notice.is-expanded .analytics-status-notice-expand-btn .status-icon-expand {
            display: none;
        }

        .analytics-status-notice.is-expanded .analytics-status-notice-expand-btn .status-icon-collapse {
            display: block;
        }

        .analytics-status-notice-text {
            font-size: 13px;
            line-height: 1.35;
            color: var(--text-secondary);
            overflow: hidden;
            white-space: nowrap;
            width: 100%;
        }

        .analytics-status-notice-expanded {
            font-size: 12px;
            line-height: 1.4;
            color: var(--text-secondary);
            display: none;
            flex-direction: column;
            gap: 4px;
            max-height: 170px;
            overflow-y: auto;
        }

        .analytics-status-notice-expanded-line {
            white-space: normal;
            word-break: break-word;
        }

        .analytics-status-notice.is-expanded .analytics-status-notice-text {
            display: none;
        }

        .analytics-status-notice.is-expanded .analytics-status-notice-expanded {
            display: flex;
        }

        .analytics-status-notice-ticker-text {
            display: inline-block;
            max-width: none;
            min-width: 100%;
            transform: translateX(0);
            will-change: transform;
        }

        body.dark-mode .analytics-status-notice {
            border-color: rgba(255, 170, 51, 0.35);
            background: linear-gradient(135deg, rgba(255, 170, 51, 0.18), rgba(255, 213, 79, 0.08));
            box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
        }

        body.dark-mode .analytics-status-notice-title {
            color: #ffd27a;
        }

        body.dark-mode .analytics-status-notice-expand-btn {
            border-color: rgba(255, 210, 122, 0.42);
            background: rgba(0, 0, 0, 0.2);
            color: #ffd27a;
        }

        body.dark-mode .analytics-status-notice-text {
            color: #d8e1e1;
        }
        
        /* Hide ALL scrollbars */
        .analytics-content::-webkit-scrollbar {
            display: none;
        }
        
        .analytics-content {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }
        
        .analytics-container::-webkit-scrollbar {
            display: none;
        }
        
        .analytics-container {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }
        
        /* Scroll Arrow Styles */
        .scroll-arrow {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            width: 40px;
            height: 40px;
            background: var(--scroll-arrows-bg);
            border: 2px solid var(--scroll-arrows-border);
            border-radius: 50%;
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 150;
            opacity: 0;
            pointer-events: none;
            transition: all 0.3s ease;
        }

        .scroll-arrow.visible {
            opacity: 1;
            pointer-events: auto;
            animation: fadeIn 0.3s ease;
        }

        .scroll-arrow.hidden {
            animation: fadeOut 0.5s ease;
        }

        .scroll-arrow:hover {
            background: var(--scroll-arrows-bg-hover);
            border-color: var(--scroll-arrows-border-hover);
            transform: translateX(-50%) scale(1.1);
        }

        .scroll-arrow.up {
            top: clamp(75px, 12vw, 90px);
        }

        .scroll-arrow.down {
            bottom: 10px;
        }

        .scroll-arrow svg {
            width: 20px;
            height: 20px;
            fill: none;
            stroke: var(--scroll-arrows-border);
            stroke-width: 3;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .analytics-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: clamp(15px, 2.5vw, 20px);
            margin-bottom: clamp(20px, 3vw, 25px);
        }

        .analytics-card {
            background: var(--card-bg);
            border-radius: 12px;
            padding: clamp(18px, 3vw, 24px);
            box-shadow: var(--card-shadow);
            border: 1px solid var(--card-border);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        body.analytics-login-required .analytics-card {
            filter: blur(8px);
            opacity: 0.34;
            pointer-events: none;
            user-select: none;
        }

        body.analytics-login-required .analytics-card:hover {
            transform: none;
            box-shadow: var(--card-shadow);
            border-color: var(--card-border);
        }
        
        .analytics-card.clickable {
            cursor: pointer;
        }
        
        .analytics-card.clickable:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
            border-color: var(--teal-primary);
        }
        
        .section-spacing {
            margin-top: clamp(20px, 3vw, 25px);
        }

        .analytics-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        }

        .card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .card-header-actions {
            display: flex;
            gap: 8px;
        }

        .icon-button {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(17, 153, 142, 0.1);
            border: 1px solid rgba(17, 153, 142, 0.2);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--teal-primary);
        }

        .icon-button:hover {
            background: rgba(17, 153, 142, 0.2);
            border-color: rgba(17, 153, 142, 0.4);
            transform: translateY(-2px);
        }

        .icon-button:active {
            transform: translateY(0);
        }

        .icon-button svg {
            color: var(--teal-primary);
        }

        /* Filter Chip Styles (from Charts.html) */
        .filter-chip {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            background: rgba(17, 153, 142, 0.1);
            border: 2px solid rgba(17, 153, 142, 0.3);
            border-radius: 20px;
            font-size: 0.9em;
            color: var(--text-primary);
            backdrop-filter: blur(4px);
            transition: all 0.2s ease;
            margin-bottom: 16px;
        }

        .filter-chip:hover {
            background: rgba(17, 153, 142, 0.15);
            border-color: rgba(17, 153, 142, 0.5);
        }

        .clear-filter-btn {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
            background: rgba(128, 128, 128, 0.1);
            border: 1.5px solid rgba(128, 128, 128, 0.2);
            padding: 0;
        }

        .clear-filter-btn svg {
            fill: #666666;
        }

        .clear-filter-btn:hover {
            background: rgba(17, 153, 142, 0.15);
            border-color: rgba(17, 153, 142, 0.4);
            box-shadow: 0 0 8px rgba(17, 153, 142, 0.3);
        }

        .clear-filter-btn:hover svg {
            fill: var(--teal-primary);
        }

        body.dark-mode .filter-chip {
            background: rgba(32, 200, 181, 0.15);
            border-color: rgba(32, 200, 181, 0.4);
        }

        body.dark-mode .filter-chip:hover {
            background: rgba(32, 200, 181, 0.2);
            border-color: rgba(32, 200, 181, 0.6);
        }

        body.dark-mode .clear-filter-btn {
            background: rgba(128, 128, 128, 0.15);
            border-color: rgba(128, 128, 128, 0.3);
        }


        .card-title-group {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .card-icon {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--teal-primary);
            border-radius: 10px;
        }

        .card-icon svg {
            width: 24px;
            height: 24px;
            fill: white;
        }

        .card-title {
            font-size: 18px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .card-subtitle {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .card-value {
            font-size: 36px;
            font-weight: 700;
            color: var(--teal-primary);
            margin: 16px 0;
            line-height: 1;
        }

        .card-change {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .card-change.positive {
            background: rgba(92, 184, 92, 0.1);
            color: var(--status-resolved);
        }

        .card-change.negative {
            background: rgba(255, 84, 84, 0.1);
            color: var(--status-critical);
        }

        .card-description {
            font-size: 14px;
            color: var(--text-secondary);
            margin-top: 12px;
        }

        .analytics-card-loading {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            margin: -4px 0 14px;
            border-radius: 999px;
            background: rgba(17, 153, 142, 0.1);
            border: 1px solid rgba(17, 153, 142, 0.22);
            color: var(--text-secondary);
            font-size: 11px;
            font-weight: 600;
            letter-spacing: 0.02em;
            width: fit-content;
        }

        .analytics-card[aria-busy="true"] > :not(.analytics-card-loading) {
            filter: blur(5px);
            opacity: 0.34;
            pointer-events: none;
            user-select: none;
        }

        .analytics-card[aria-busy="true"] .analytics-card-loading {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            margin: 0;
            z-index: 3;
            font-size: 12px;
            background: rgba(255, 255, 255, 0.92);
            border-color: rgba(17, 153, 142, 0.30);
        }

        .analytics-card-loading[hidden] {
            display: none !important;
        }

        .analytics-card-loading::before {
            content: '';
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: var(--teal-primary);
            animation: analytics-card-loading-pulse 1.5s ease-in-out infinite;
        }

        body.dark-mode .analytics-card-loading {
            background: rgba(32, 200, 181, 0.14);
            border-color: rgba(32, 200, 181, 0.28);
        }

        body.dark-mode .analytics-card[aria-busy="true"] .analytics-card-loading {
            background: rgba(17, 25, 30, 0.9);
            border-color: rgba(32, 200, 181, 0.40);
        }

        @keyframes analytics-card-loading-pulse {
            0%, 100% { opacity: 0.45; transform: scale(0.9); }
            50% { opacity: 1; transform: scale(1); }
        }

        .chart-card {
            grid-column: 1 / -1;
            min-height:64px;
        }

        
        /* Cost Chart Content - Side by Side Layout */
        .cost-chart-content {
            display: flex;
            flex-direction: column;
            gap: 0;
            padding: 20px;
            min-height: 600px;
        }
        
        /* Scale container stays at top */
        .cost-chart-scale-container {
            width: 100%;
            height: 71px;
            background: var(--header-columns-bg);
            border-radius: 8px 8px 0 0;
            position: relative;
            flex-shrink: 0;
        }
        
        .cost-chart-side {
            flex: 1;
            background: var(--header-columns-bg);
            border-radius: 0 0 8px 8px;
            padding: 0px;
            display: flex;
            align-items: flex-start;
            justify-content: right;
            overflow-y: auto;
            overflow-x: hidden;
            max-height: 529px;  /* 600px - 71px for scale container */
        }
        
        /* Scrollbar for chart side - shortened to show rounded corner */
        .cost-chart-side::-webkit-scrollbar {
            width: 8px;
        }
        
        .cost-chart-side::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.05);
            margin-top: 8px;
            margin-bottom: 8px;  /* Shorten to reveal rounded corner */
            border-radius: 4px;
        }
        
        .cost-chart-side::-webkit-scrollbar-thumb {
            background: var(--teal-primary);
            border-radius: 4px;
        }
        
        .cost-chart-side::-webkit-scrollbar-thumb:hover {
            background: var(--teal-secondary);
        }
        
        /* Cost Chart View Selector in Title */
        .cost-chart-title-selector {
            display: inline;
            background: transparent;
            border: 1px solid rgba(128, 128, 128, 0.2);
            border-radius: 4px;
            padding: 2px 6px;
            font-size: inherit;
            font-family: inherit;
            font-weight: inherit;
            color: inherit;
            cursor: pointer;
            outline: none;
            transition: all 0.2s ease;
        }
        
        .cost-chart-title-selector:hover {
            border-color: rgba(128, 128, 128, 0.4);
            background: rgba(128, 128, 128, 0.05);
        }
        
        .cost-chart-title-selector:focus {
            border-color: var(--teal-primary);
        }
        
        body.dark-mode .cost-chart-title-selector {
            border-color: rgba(200, 200, 200, 0.2);
        }
        
        body.dark-mode .cost-chart-title-selector:hover {
            border-color: rgba(200, 200, 200, 0.4);
            background: rgba(200, 200, 200, 0.05);
        }
        
        /* Cost Chart Back Arrow - positioned in scale container */
        .cost-chart-back-arrow {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            display: none;
            width: 32px;
            height: 32px;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
            z-index: 10;
        }
        
        .cost-chart-back-arrow.visible {
            display: flex;
        }
        
        .cost-chart-back-arrow svg {
            width: 32px;
            height: 32px;
            fill: #11998e;  /* Match bar green color */
            filter: drop-shadow(0 2px 4px rgba(9, 79, 73, 0.3));
            transition: all 0.2s ease;
        }
        
        .cost-chart-back-arrow:hover svg {
            fill: #0d7a71;  /* Darker green on hover */
            transform: translateX(-4px);
            filter: drop-shadow(0 3px 6px rgba(17, 153, 142, 0.5));
        }
        
        body.dark-mode .cost-chart-back-arrow svg {
            fill: #20c8b5;
        }
        
        body.dark-mode .cost-chart-back-arrow:hover svg {
            fill: #42e9a0;
        }
        
        /* Cost Chart View Selector */
        .cost-chart-view-selector {
            position: absolute;
            left: 5px;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(17, 153, 142, 0.15);
            border: 2px solid var(--teal-primary);
            border-radius: 3px;
            padding: 6px 12px;
            font-size: 12px;
            font-family: system-ui, -apple-system, sans-serif;
            font-weight: normal;
            color: var(--teal-primary);
            cursor: pointer;
            outline: none;
            pointer-events: auto;
            transition: all 0.2s ease;
            backdrop-filter: blur(4px);
            z-index: 20;
        }
        
        body.dark-mode .cost-chart-view-selector {
            background: rgba(32, 200, 181, 0.2);
        }
        
        .cost-chart-view-selector:hover {
            background: rgba(17, 153, 142, 0.25);
            border-color: var(--teal-secondary);
            box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
        }
        
        body.dark-mode .cost-chart-view-selector:hover {
            background: rgba(32, 200, 181, 0.3);
        }
        
        .cost-chart-view-selector:focus {
            box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.2);
        }
        
        .cost-chart-view-selector option {
            background: rgba(255, 255, 255, 0.95);
            color: var(--text-primary);
            padding: 8px;
            border-radius: 3px;
        }
        
        body.dark-mode .cost-chart-view-selector option {
            background: rgba(45, 55, 72, 0.95);
        }
        
        /* Breadcrumb navigation */
        .cost-breadcrumb {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.9em;
            color: var(--text-secondary);
            margin-bottom: 4px;
        }
        
        .breadcrumb-item {
            color: var(--teal-primary);
            cursor: pointer;
            transition: color 0.2s ease;
        }
        
        .breadcrumb-item:hover {
            color: var(--teal-secondary);
            text-decoration: underline;
        }
        
        .breadcrumb-separator {
            color: var(--text-secondary);
            user-select: none;
        }
        
        .breadcrumb-current {
            color: var(--text-primary);
            font-weight: 600;
            cursor: default;
        }
        
        .chart-container {
            width: 100%;
            height: 650px;  /* Increased to fit 600px chart + padding */
            background: var(--header-columns-bg);
            border-radius: 8px;
            position: relative;  /* For absolute positioning of back button */
            color: var(--text-secondary);
            font-size: 18px;
            display: flex;
            align-items: center;  /* Center vertically */
            justify-content: center;  /* Center horizontally */
        }
        
        /* Scrollbar styling for canvas wrapper inside chart-container */
        .chart-container > div::-webkit-scrollbar {
            height: 10px;
        }
        
        .chart-container > div::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.1);
            border-radius: 5px;
        }
        
        .chart-container > div::-webkit-scrollbar-thumb {
            background: var(--teal-primary);
            border-radius: 5px;
        }
        
        .chart-container > div::-webkit-scrollbar-thumb:hover {
            background: var(--teal-secondary);
        }
        
        
        .chart-placeholder {
            text-align: center;
            padding: 40px;
        }

        .chart-placeholder-icon {
            width: 80px;
            height: 80px;
            margin: 0 auto 20px;
            opacity: 0.3;
        }

        .chart-placeholder-icon svg {
            width: 100%;
            height: 100%;
            fill: var(--text-secondary);
        }

        /* Trend indicators */
        .trend-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .trend-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid var(--card-border);
            gap: 10px;
            min-width: 0;
        }

        .trend-item:last-child {
            border-bottom: none;
        }

        .trend-name {
            font-size: 15px;
            color: var(--text-primary);
            font-weight: 500;
            display: block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }


        .trend-name-block {
            display: inline-flex;
            flex-direction: column;
            gap: 3px;
            min-width: 0;
            flex: 1 1 auto;
            margin-right: 10px;
            overflow: hidden;
        }


        .trend-value {
            font-size: 16px;
            font-weight: 600;
            color: var(--teal-primary);
            display: inline-flex;
            align-items: baseline;
            gap: 10px;
            flex: 0 0 auto;
        }

        .trend-pct {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-secondary);
            opacity: 0.9;
        }

        /* "NEW" badge for items with no usable baseline window */
        .trend-pct.trend-new {
            color: var(--teal-primary);
            opacity: 0.95;
        }

        #topUsedItemsCard .trend-list {
            min-height: 252px;
        }

        #topUsedItemsCard .trend-item {
            min-height: 42px;
        }

        .trend-pager {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 8px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--card-border);
        }

        .trend-pager-btn {
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            color: var(--text-primary);
            border-radius: 8px;
            padding: 4px 10px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
        }

        .trend-pager-btn:disabled {
            opacity: 0.45;
            cursor: default;
        }

        .trend-pager-label {
            font-size: 12px;
            color: var(--text-secondary);
            min-width: 62px;
            text-align: center;
        }

        /* Status distribution */
        .status-bar {
            display: flex;
            height: 30px;
            border-radius: 8px;
            overflow: hidden;
            margin: 20px 0;
        }

        .status-segment {
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 600;
            color: white;
            transition: all 0.3s ease;
        }

        .status-segment:hover {
            opacity: 0.8;
        }

        .status-legend {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            margin-top: 15px;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            padding: 8px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .legend-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        /* Individual legend frame colors */
        .legend-frame-outofstock {
            background: rgba(255, 84, 84, 0.15);
            border: 1px solid rgba(255, 84, 84, 0.3);
        }

        .legend-frame-lowstock {
            background: rgba(255, 132, 0, 0.15);
            border: 1px solid rgba(255, 132, 0, 0.3);
        }

        .legend-frame-normalstock {
            background: rgba(92, 184, 92, 0.15);
            border: 1px solid rgba(92, 184, 92, 0.3);
        }

        .legend-frame-overstock {
            background: rgba(102, 126, 234, 0.15);
            border: 1px solid rgba(102, 126, 234, 0.3);
        }

        .legend-frame-expiring {
            background: rgba(255, 193, 7, 0.15);
            border: 1px solid rgba(255, 193, 7, 0.35);
        }

        /* Dark mode - white text */
        body.dark-mode .legend-item span {
            color: #ffffff;
        }

        /* Custom Tooltip Styles - Matching Shortage Bulletin */
        .custom-tooltip {
            position: fixed;
            background: var(--tooltip-bg);
            color: var(--tooltip-text-color);
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 500;
            pointer-events: none;
            z-index: 10000;
            white-space: normal;
            max-width: 240px;
            opacity: 0;
            transition: opacity 0.2s ease;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }

        .custom-tooltip.visible {
            opacity: 1;
        }

        /* Metric cards in grid */
        .metric-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 40px; /* Increased from 15px to 40px */
            margin-top: 40px;
            margin-left: 10px;
            margin-right: 10px;
        }

        .metric-item {
            padding: 30px;
            background: var(--header-columns-bg);
            border-radius: 8px;
            min-width: 0; /* Allow flex items to shrink below content size */
            position: relative;
        }

        .metric-label {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .metric-value {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        /* Small 4-bar sparkline used in Pyxis Metrics "Waste" card (expiring 1-4 months) */
        .metric-spark {
            position: absolute;
            right: 18px;
            top: 22px;
            display: flex;
            align-items: flex-end;
            gap: 10px;
            height: 60px;
            pointer-events: none; /* Card click should pass through */
        }

        .metric-spark .spark-bar {
            width: 6px;
            border-radius: 6px;
            background: #ff8400;
            opacity: 0.9;
            min-height: 10px;
        }

        body.dark-mode .metric-spark .spark-bar {
            opacity: 0.95;
        }

        .clickable-metric {
            cursor: pointer;
            transition: all 0.3s ease;
            border-radius: 8px;
            padding: 8px;
            margin: -8px;
        }

        .clickable-metric:hover {
            background: rgba(17, 153, 142, 0.1);
            transform: translateY(-2px);
        }

        .clickable-metric:hover .metric-value {
            color: var(--teal-primary);
        }

        /* Sub-card containers for Projected Waste and Usage Vs Restock */
        .sub-cards-container {
            display: flex;
            gap: 8px;
            min-width: 0; /* Allow shrinking */
        }
        
        .sub-card {
            flex: 1;
            min-width: 0; /* Allow shrinking */
            padding: 8px;
            border-radius: 8px;
            background: rgba(17, 153, 142, 0.1);
            border: 1px solid rgba(17, 153, 142, 0.3);
            cursor: pointer;
            transition: all 0.2s;
            overflow: hidden; /* Prevent content overflow */
        }
        
        .sub-card:hover {
            background: rgba(17, 153, 142, 0.15);
            transform: translateY(-2px);
            box-shadow: 0 2px 8px rgba(17, 153, 142, 0.2);
        }
        
        .sub-card-label {
            font-size: 11px;
            opacity: 0.8;
            margin-bottom: 4px;
            white-space: normal;
            max-width: 240px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .sub-card-value {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
            white-space: normal;
            max-width: 240px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .threshold-chart-icon {
            color: var(--teal-primary);
            flex-shrink: 0;
        }
        
        .sub-card:hover .threshold-chart-icon {
            opacity: 1 !important;
        }

        /* Inventory Cost Card - Full Width Like Other Cards */
        .inventory-cost-card {
            /* No max-width - full width like other analytics cards */
        }

        .inventory-cost-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;  /* Match card-header margin-bottom */
        }

        .inventory-cost-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .inventory-cost-title {
            font-size: 18px;  /* Match card-title */
            font-weight: 600;
            color: var(--text-primary);
        }

        .inventory-cost-subtitle {
            font-size: 12px;  /* Match card-subtitle */
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .inventory-cost-right {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }

        .inventory-cost-total {
            font-size: 28px;  /* Slightly smaller than before */
            font-weight: 700;
            color: var(--text-primary);
        }

        .inventory-cost-caption {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: -1px; /* Reduced from 4px to -1px (5px shorter gap) */
        }

        .restock-efficiency-value {
            font-weight: 700;
            color: rgba(17, 153, 142, 0.8); /* Match the line graph color */
        }

        .projected-waste-section {
            /* No extra padding - card already has padding from .analytics-card */
        }

        .usage-restock-line-chart {
            margin-top: 20px;
            width: 100%;
            height: 200px;
        }

        .usage-restock-line-chart canvas {
            width: 100% !important;
            height: 200px !important;
            background: transparent !important; /* Transparent to show card background */
        }

        .projected-waste-section {
            /* No extra padding - card already has padding from .analytics-card */
        }

        .projected-waste-title {
            font-size: 1em;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 16px;
        }

        .projected-waste-cards {
            display: grid;
            grid-template-columns: 1fr;  /* Single column now */
            gap: 12px;
        }

        .projected-waste-card {
            padding: 16px;
            border-radius: 12px;
            background: rgba(17, 153, 142, 0.12);
            border: 1px solid rgba(17, 153, 142, 0.25);
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            flex-direction: column;
        }

        .projected-waste-card:hover {
            background: rgba(17, 153, 142, 0.18);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(17, 153, 142, 0.2);
        }

        .projected-waste-label {
            font-size: 0.85em;
            opacity: 0.85;
            margin-bottom: auto;  /* Push value to bottom */
            padding-bottom: 8px;
            color: var(--text-primary);
        }

        .projected-waste-value {
            font-size: 1.8em;
            font-weight: 700;
            color: var(--text-primary);
            align-self: flex-start;  /* Align to left */
        }

        /* Dark mode adjustments */
        body.dark-mode .restock-efficiency-value {
            color: rgba(32, 200, 181, 0.8); /* Match the dark mode line graph color */
        }

        body.dark-mode .projected-waste-section {
            background: var(--bg-secondary);
        }

        /* Inventory Waste Card Styles */
        .inventory-waste-card {
            /* Full width like other analytics cards */
        }

        .inventory-waste-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .inventory-waste-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .inventory-waste-title {
            font-size: 18px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .inventory-waste-subtitle {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 2px;
        }

        .inventory-waste-right {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }

        .inventory-waste-total {
            font-size: 28px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .inventory-waste-caption {
            font-size: 12px;
            color: var(--text-primary);
            margin-top: -1px; /* Reduced from 4px to -1px (5px shorter gap) */
            border: 1px solid var(--modal-card-border);
            border-radius: 999px;
            background: transparent;
            padding: 2px 10px;
            cursor: pointer;
        }

        .waste-chart-section {
            display: flex;
            align-items: center;
            margin-top: 20px; /* Match the inventory cost chart spacing */
        }

        .waste-mini-chart {
            flex: 1;
            display: flex;
            align-items: flex-end;
            height: 200px; /* Match inventory cost chart height */
            width: 100%; /* Expand to full width */
            /* gap is set dynamically in JavaScript */
        }

        .waste-mainlocation-list {
            flex: 1;
            display: grid;
            gap: 8px;
            max-height: 200px;
            overflow: auto;
        }

        .waste-mainlocation-row {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 8px;
            align-items: center;
            font-size: 12px;
            color: var(--text-primary);
            border-bottom: 1px solid rgba(120, 140, 160, 0.16);
            padding-bottom: 4px;
        }

        
        .waste-bar-col{
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-end;
            height: 100%;
        }

        .waste-bar-wrap{
            flex: 1;
            width: 100%;
            display: flex;
            align-items: flex-end;
            justify-content: center;
        }

        .waste-bar-pair {
            flex: 1;
            width: 100%;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            gap: 4px;
            position: relative;
        }

        .waste-bar-wrap.series-actual,
        .waste-bar-wrap.series-projected {
            width: auto;
            flex: 1 1 0;
        }

        .waste-bar-wrap.series-overlay {
            position: absolute;
            left: 50%;
            bottom: 0;
            width: 58%;
            transform: translateX(-50%);
            z-index: 2;
        }

        .waste-bar-label{
            margin-top: 6px;
            font-size: 10px;
            font-weight: 600;
            letter-spacing: 0.5px;
            color: #6b7280;
            text-align: center;
            line-height: 1;
            user-select: none;
        }

        body.dark-mode .waste-bar-label{
            color: rgba(255,255,255,0.65);
        }

        .waste-tt-title{
            font-weight: 700;
            margin-bottom: 2px;
        }

        .waste-tt-meta{
            opacity: 0.9;
            margin-bottom: 6px;
        }

        .waste-tt-subhead{
            margin-top: 6px;
            font-weight: 700;
            opacity: 0.95;
        }

        .waste-tt-row{
            display: flex;
            justify-content: space-between;
            gap: 10px;
            margin-top: 2px;
            opacity: 0.95;
        }

        .waste-tt-more{
            margin-top: 4px;
            opacity: 0.8;
        }
.waste-bar {
            /* width set dynamically in JavaScript based on number of bars */
            flex-shrink: 0; /* Prevent shrinking */
            background: #d1d5db;
            border-radius: 4px 4px 0 0;
            transition: all 0.3s ease;
            min-height: 0;
            cursor: pointer;
            position: relative;
        }

        .waste-bar:hover {
            opacity: 0.8;
        }

        .waste-bar-tooltip {
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.9);
            color: white;
            padding: 6px 10px;
            border-radius: 6px;
            font-size: 12px;
            white-space: normal;
            max-width: 240px;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s;
            margin-bottom: 5px;
            z-index: 1000;
        }

        body.dark-mode .waste-bar-tooltip {
            background: rgba(255, 255, 255, 0.95);
            color: #000;
        }

        .waste-bar:hover .waste-bar-tooltip {
            opacity: 1;
        }

        .waste-bar.current {
            background: var(--teal-primary);
        }

        .waste-bar.actual-waste-bar {
            background: var(--accent-coral, #ff7a6b);
        }

        .waste-bar.current-month-actual-bar {
            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
        }

        /* Projected Waste Bar Styling */
        .waste-bar.projected-waste-bar {
            background: #c7ced8;
            transition: all 0.3s ease;
        }

        .waste-bar.projected-waste-bar:hover {
            opacity: 0.8;
            transform: translateY(-2px);
        }

        .waste-bar.is-active-series {
            opacity: 1;
            box-shadow: 0 0 0 1px rgba(255,255,255,0.18);
        }

        .waste-bar.is-inactive-series {
            opacity: 0.42;
        }

        body.dark-mode .waste-bar.projected-waste-bar {
            background: #8a95a3;
        }

        body.dark-mode .waste-bar.current-month-actual-bar {
            box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.45);
        }

        /* Cost Back Button - NEW */

        /* Modal Styles - NEW */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 9998;
            transition: all 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
        }

        .modal-overlay.active {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--modal-shadow-color);
            -webkit-backdrop-filter: blur(18px);
            backdrop-filter: blur(18px);
        }
        
        .modal-overlay.closing {
            opacity: 0;
            display: flex !important;
        }

        .modal-container {
            background: var(--modal-window-bg);
            border-radius: 15px;
            box-shadow: 0 20px 60px var(--modal-shadow-color);
            max-width: clamp(400px, 80vw, 700px);
            width: 90%;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
            animation: slideIn 0.3s ease;
            position: relative;
            overflow: hidden;
            transition: background 0.3s ease;
        }
        
        .modal-overlay.active .modal-container {
            transform: translateY(0);
            opacity: 1;
        }
        
        .modal-overlay.closing .modal-container {
            transform: translateY(-30px);
            opacity: 0;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(-30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes modalFadeOut {
            from {
                opacity: 1;
                transform: translateY(0);
            }
            to {
                opacity: 0;
                transform: translateY(-30px);
            }
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: clamp(20px, 3vw, 25px) clamp(20px, 4vw, 30px);
            background: var(--modal-header-color);
        }

        .modal-title {
            font-size: clamp(1.4em, 2.5vw, 1.8em);
            font-weight: 600;
            color: var(--modal-header-font);
            display: flex;
            align-items: center;
            gap: clamp(10px, 2vw, 12px);
        }

        .modal-title svg {
            width: clamp(26px, 4vw, 32px);
            height: clamp(26px, 4vw, 32px);
            fill: var(--modal-header-font);
        }

        .modal-header-actions {
            display: flex;
            gap: clamp(8px, 1.5vw, 10px);
            align-items: center;
        }

        .modal-close-btn {
            background: none;
            border: none;
            font-size: clamp(28px, 4vw, 32px);
            color: var(--modal-header-font);
            cursor: pointer;
            padding: 0;
            width: clamp(28px, 4vw, 32px);
            height: clamp(28px, 4vw, 32px);
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.3s ease;
            line-height: 1;
            font-weight: bold;
        }

        .modal-close-btn:hover {
            background: var(--modal-close-btn-bg);
            transform: rotate(90deg);
        }

        .modal-body {
            padding: var(--container-padding);
            overflow-y: auto;
            flex: 1;
            scrollbar-width: none; /* Firefox */
            -ms-overflow-style: none; /* IE/Edge */
        }

        .modal-body::-webkit-scrollbar {
            display: none; /* Chrome/Safari/Opera */
        }

        /* Modal Info Cards (Shortage Bulletin Style) */
        .modal-drug-info {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 20vw, 150px), 1fr));
            gap: var(--spacing-md);
            margin-bottom: var(--section-margin-bottom);
        }

        .modal-info-item {
            background: var(--modal-card-bg);
            padding: var(--spacing-md);
            border-radius: 8px;
            border: 2px solid var(--modal-card-border);
            transition: background 0.3s ease, border-color 0.3s ease;
        }

        .modal-info-label {
            font-size: clamp(0.85em, 1.4vw, 0.95em);
            color: var(--teal-primary);
            margin-bottom: var(--spacing-xs);
            font-weight: 600;
            transition: color 0.3s ease;
        }

        .modal-info-value {
            font-size: clamp(1.4em, 2.5vw, 1.8em);
            color: var(--teal-primary);
            font-weight: 700;
        }

        .modal-info-sublabel {
            font-size: clamp(0.75em, 1.2vw, 0.85em);
            color: var(--text-secondary);
            margin-top: var(--spacing-xs);
            line-height: 1.3;
        }

        /* Trend Bar Container */
        .trend-bar-container {
            margin-top: var(--spacing-sm);
            height: 50px;
            display: flex;
            align-items: flex-end;
        }

        .trend-bars {
            display: flex;
            align-items: flex-end;
            gap: 3px;
            width: 100%;
            height: 100%;
        }

        .trend-bar {
            flex: 1;
            height: 100%;
            display: flex;
            align-items: flex-end;
            min-width: 4px;
        }

        .trend-bar-fill {
            width: 100%;
            border-radius: 2px 2px 0 0;
            transition: all 0.3s ease;
        }

        .trend-bar-previous {
            background: #9ca3af;
        }

        .trend-bar-current {
            background: var(--teal-primary);
        }

        /* Settings Modal Styles */

        /* Modal Summary Cards - NEW */
        .modal-summary-section {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
            margin-bottom: 25px;
            width: 100%;
            box-sizing: border-box;
        }
        
        .modal-summary-card {
            background: linear-gradient(135deg, var(--modal-card-bg) 0%, var(--modal-card-bg-alt) 100%);
            border: 2px solid var(--modal-card-border);
            border-radius: 10px;
            padding: 18px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            min-width: 0;
            overflow: hidden;
            text-align: center;
            /* Static - no hover effects like companion modal */
        }
        
        .modal-summary-card-header {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            color: var(--text-secondary);
            font-size: 0.85em;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .modal-summary-card-header svg {
            width: 16px;
            height: 16px;
            fill: var(--teal-primary);
            flex-shrink: 0;
        }
        
        .modal-summary-card-value {
            font-size: 1.4em;
            font-weight: 700;
            color: var(--teal-primary);
        }
        
        .modal-summary-card-detail {
            color: var(--text-secondary);
            font-size: 0.9em;
            margin-top: 4px;
            overflow: hidden;
            word-wrap: break-word;
            word-break: break-word;
            white-space: normal;
            line-height: 1.4;
        }
        
        /* Modal Sort Controls - NEW */
        /* Modal Sort Controls */
        .modal-controls-section {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 10px;
            margin-bottom: 20px;
            position: relative;
        }
        
        .modal-sort-control,
        .modal-filter-control {
            position: relative;
            flex-shrink: 0;
        }
        
        .modal-sort-select,
        .modal-filter-button {
            padding: 12px 40px 12px 16px;
            border: 2px solid var(--teal-primary);
            border-radius: 8px;
            background: var(--card-bg);
            color: var(--text-primary);
            font-size: 0.95em;
            font-weight: 600;
            cursor: pointer;
            outline: none;
            transition: all 0.2s ease;
            appearance: none;
            min-width: 180px;
            text-align: left;
        }
        
        .modal-sort-select {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2311998e' d='M7,10L12,15L17,10H7Z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            background-size: 24px;
        }
        
        .modal-filter-button {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            background: var(--teal-primary);
            color: white;
            border-color: var(--teal-primary);
        }
        
        .modal-filter-button svg {
            width: 20px;
            height: 20px;
            fill: white;
            flex-shrink: 0;
        }
        
        .modal-sort-select:hover,
        .modal-filter-button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(17, 153, 142, 0.2);
        }
        
        .modal-sort-select:focus {
            border-color: var(--teal-primary);
            box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.1);
        }
        
        /* Filter Slider Panel - Dropdown Style */
        .filter-slider-panel {
            position: absolute;
            right: 0;
            top: calc(100% + 8px);
            width: 320px;
            background: var(--card-bg);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
            border-radius: 12px;
            border: 2px solid var(--area-card-border);
            z-index: 10002;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s ease;
            display: flex;
            flex-direction: column;
            max-height: 400px;
        }
        
        .filter-slider-panel.active {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        
        .filter-panel-header {
            padding: 20px;
            background: var(--teal-primary);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-radius: 10px 10px 0 0;
        }
        
        .filter-panel-title {
            font-size: 1.1em;
            font-weight: 600;
        }
        
        .filter-panel-close {
            background: transparent;
            border: none;
            color: white;
            font-size: 28px;
            cursor: pointer;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            transition: background 0.2s ease;
            line-height: 1;
            padding: 0;
        }
        
        .filter-panel-close:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        .filter-panel-body {
            padding: 25px;
            flex: 1;
            overflow-y: auto;
        }
        
        .filter-group {
            margin-bottom: 20px;
        }
        
        .filter-group-title {
            font-size: 0.9em;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 15px;
        }
        
        .price-range-display {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding: 12px;
            background: var(--area-card-bg);
            border-radius: 8px;
            border: 2px solid var(--area-card-border);
        }
        
        .price-range-label {
            font-size: 0.85em;
            color: var(--text-secondary);
            font-weight: 500;
        }
        
        .price-range-value {
            font-size: 1.1em;
            font-weight: 700;
            color: var(--teal-primary);
        }
        
        .price-slider-container {
            padding: 20px 10px;
        }
        
        .price-slider {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: var(--area-card-border);
            outline: none;
            -webkit-appearance: none;
        }
        
        .price-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--teal-primary);
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            transition: transform 0.2s ease;
        }
        
        .price-slider::-webkit-slider-thumb:hover {
            transform: scale(1.2);
        }
        
        .price-slider::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--teal-primary);
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            transition: transform 0.2s ease;
        }
        
        .price-slider::-moz-range-thumb:hover {
            transform: scale(1.2);
        }
        
        .filter-actions {
            padding: 20px;
            border-top: 2px solid var(--area-card-border);
            display: flex;
            gap: 10px;
        }
        
        .filter-button-apply,
        .filter-button-reset {
            flex: 1;
            padding: 12px;
            border: none;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.95em;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .filter-button-apply {
            background: var(--teal-primary);
            color: white;
        }
        
        .filter-button-apply:hover {
            background: var(--teal-secondary);
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(17, 153, 142, 0.3);
        }
        
        .filter-button-reset {
            background: var(--area-card-bg);
            color: var(--text-primary);
            border: 2px solid var(--area-card-border);
        }
        
        .filter-button-reset:hover {
            border-color: var(--teal-primary);
            color: var(--teal-primary);
        }

        /* Area List in Modals - UPDATED */
        .area-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .area-card {
            background: var(--area-card-bg);
            border: 2px solid var(--area-card-border);
            border-radius: 10px;
            padding: 0;
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .area-card:hover {
            border-color: var(--teal-primary);
        }

        .area-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 18px;
            cursor: pointer;
            user-select: none;
        }
        
        .area-card-header:hover {
            background: var(--area-card-hover-bg);
        }
        
        .area-card-header-left {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .area-expand-icon {
            width: 20px;
            height: 20px;
            transition: transform 0.3s ease;
            fill: var(--text-secondary);
        }
        
        .area-card.expanded .area-expand-icon {
            transform: rotate(90deg);
        }

        .area-name {
            font-size: 1.1em;
            font-weight: 600;
            color: var(--area-header-text);
        }

        .area-badge {
            background: var(--area-badge-bg);
            color: var(--area-badge-text);
            padding: 6px 14px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.95em;
        }

        .sublocation-list {
            display: none;
            flex-direction: column;
            gap: 12px;
            padding: 0 5px;
        }
        
        .area-card.expanded .sublocation-list {
            display: flex;
        }

        .sublocation-item {
            background: var(--area-card-bg);
            border-radius: 8px;
            border: 2px solid var(--area-card-border);
            overflow: hidden;
        }
        
        .sublocation-item:last-child {
            margin-bottom: 0;
        }
        
        .sublocation-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 18px;
            background: var(--area-card-bg);
            border-bottom: 2px solid var(--area-card-border);
            font-weight: 600;
        }
        
        .sublocation-header-left {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .sublocation-name {
            color: var(--text-primary);
            font-weight: 600;
            font-size: 1em;
        }

        .sublocation-badge {
            background: var(--text-primary);
            color: var(--card-bg);
            padding: 4px 12px;
            border-radius: 12px;
            font-weight: 600;
            font-size: 0.85em;
        }
        
        .item-list {
            display: flex;
            flex-direction: column;
            gap: 0;
            background: var(--card-bg);
            padding: 0;
        }
        
        .item-row {
            padding: 14px 18px;
            border-bottom: 1px solid var(--area-card-border);
            color: var(--text-secondary);
            font-size: 0.9em;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            background: var(--card-bg);
        }
        
        .item-row:last-child {
            border-bottom: none;
        }
        
        .item-row:hover {
            background: rgba(17, 153, 142, 0.03);
        }
        
        .item-description {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .item-bullet {
            width: 6px;
            height: 6px;
            background: var(--teal-primary);
            border-radius: 50%;
            flex-shrink: 0;
        }
        
        .item-cost {
            color: var(--teal-primary);
            font-weight: 600;
            font-size: 0.95em;
            white-space: normal;
            max-width: 240px;
        }

        /* Waste Modal Sections */
        .waste-section {
            margin-bottom: 20px;
        }

        .waste-section-header h3 {
            color: var(--text-primary);
            font-size: 16px;
            margin: 0 0 15px 0;
        }

        .waste-summary-frame {
            background: var(--card-bg);
            border: 2px solid var(--area-card-border);
            border-radius: 10px;
            padding: 20px;
            display: flex;
            gap: 30px;
            justify-content: center;
        }

        .waste-summary-item {
            text-align: center;
        }

        .waste-summary-label {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .waste-summary-value {
            font-size: 24px;
            font-weight: 600;
            color: var(--teal-primary);
        }

        .location-waste-card {
            background: var(--area-card-bg);
            border: 2px solid var(--area-card-border);
            border-radius: 10px;
            margin-bottom: 12px;
            overflow: hidden;
            transition: all 0.3s ease;
        }

        .location-waste-card:hover {
            border-color: var(--teal-primary);
        }

        .location-waste-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 18px;
            cursor: pointer;
            user-select: none;
        }

        .location-waste-header:hover {
            background: var(--area-card-hover-bg);
        }

        .location-name {
            font-size: 1.05em;
            font-weight: 600;
            color: var(--area-header-text);
        }

        .location-count {
            background: var(--area-badge-bg);
            color: var(--area-badge-text);
            padding: 6px 14px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.95em;
        }

        .expand-arrow {
            transform: rotate(-90deg);
            transition: transform 0.2s ease;
            color: var(--text-secondary);
        }

        .sublocation-waste-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 18px;
            background: var(--card-bg);
            border-top: 1px solid var(--area-card-border);
            font-size: 0.95em;
        }

        .sublocation-waste-item:last-child {
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }

        /* Scrollbar styling */
        .analytics-content::-webkit-scrollbar {
            width: 8px;
        }

        .analytics-content::-webkit-scrollbar-track {
            background: transparent;
        }

        .analytics-content::-webkit-scrollbar-thumb {
            background: rgba(17, 153, 142, 0.3);
            border-radius: 4px;
        }

        .analytics-content::-webkit-scrollbar-thumb:hover {
            background: rgba(17, 153, 142, 0.5);
        }

        /* ============= PYXIS MODAL STYLES ============= */

        .pyxis-modal-controls {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 14px 0 10px;
        }

        .pyxis-sort {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .pyxis-sort label {
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 600;
        }

        .pyxis-sort select {
            appearance: none;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 10px 34px 10px 12px;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            outline: none;
        }

        .pyxis-modal-hint {
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 600;
            text-align: right;
        }

        .pyxis-summary-row {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 12px;
            margin: 8px 0 14px;
        }

        .pyxis-summary-card {
	            /* Match Item Details summary card typography + frame thickness */
	            background: linear-gradient(135deg, rgba(238, 247, 244, 0.92) 0%, rgba(238, 247, 244, 0.78) 100%);
	            border: 2px solid rgba(207, 214, 221, 0.9);
	            border-radius: 10px;
	            padding: 14px 12px;
	            text-align: center;
	            cursor: pointer;
	            overflow: hidden;
	            transition: all 0.2s ease;
        }

        .pyxis-summary-card:hover {
	            border-color: rgba(17, 153, 142, 0.55);
            transform: translateY(-1px);
	            background: rgba(238, 247, 244, 1);
        }

        .pyxis-summary-card.active {
	            border-color: rgba(17, 153, 142, 0.95);
	            box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
        }

        .pyxis-summary-label {
	            color: rgba(70, 78, 90, 0.9);
	            /* Keep text inside card at all sizes */
	            font-size: clamp(0.75em, 1.2vw, 0.85em);
	            font-weight: 600;
	            letter-spacing: 0.5px;
	            text-transform: uppercase;
	            margin-bottom: 8px;
        }

        .pyxis-summary-value {
	            color: rgba(15, 160, 140, 0.98);
	            font-size: clamp(1.4em, 2.4vw, 2em);
	            font-weight: 700;
	            font-variant-numeric: tabular-nums;
	            line-height: 1.15;
        }

	        /* Divider line similar to companion modal cards */
	        .pyxis-summary-card .pyxis-summary-value::after {
	            content: '';
	            display: block;
	            width: 60%;
	            height: 1px;
	            margin: 10px auto 0;
	            background: rgba(180, 190, 205, 0.65);
	        }

	        /* PYXIS LIST SECTION (companion-modal-like) */
	        .pyxis-list-section {
	            border: 1px solid rgba(208, 216, 228, 0.85);
	            background: rgba(255, 255, 255, 0.06);
	            border-radius: 6px;
	            overflow: hidden;
	        }

	        .pyxis-list-header {
	            display: flex;
	            align-items: center;
	            justify-content: space-between;
	            gap: 12px;
	            padding: 14px 16px;
	            border-bottom: 2px solid rgba(15, 160, 140, 0.55);
	            background: rgba(0, 0, 0, 0.02);
	        }

	        .pyxis-list-title {
	            font-size: clamp(1em, 1.5vw, 1.1em);
	            font-weight: 700;
	            letter-spacing: 0.5px;
	            color: rgba(15, 160, 140, 0.95);
	            text-transform: uppercase;
	            display: flex;
	            align-items: center;
	            gap: 10px;
	        }

	        .pyxis-list-subtitle {
	            font-size: 12px;
	            font-weight: 700;
	            color: rgba(70, 78, 90, 0.75);
	            margin-top: 2px;
	        }

	        .pyxis-list-header-left {
	            display: flex;
	            flex-direction: column;
	            min-width: 0;
	        }

	        .pyxis-list-header-right {
	            display: flex;
	            align-items: center;
	            gap: 10px;
	        }

	        .pyxis-sort-select {
	            padding: 8px 10px;
	            border-radius: 10px;
	            border: 2px solid rgba(15, 160, 140, 0.35);
	            background: rgba(255, 255, 255, 0.7);
	            color: rgba(30, 38, 50, 0.95);
	            font-weight: 800;
	            font-size: 13px;
	            outline: none;
	        }

	        .pyxis-print-btn {
	            display: inline-flex;
	            align-items: center;
	            gap: 8px;
	            padding: 8px 12px;
	            border-radius: 12px;
	            border: 2px solid rgba(15, 160, 140, 0.75);
	            background: rgba(255, 255, 255, 0.6);
	            color: rgba(15, 160, 140, 0.95);
	            font-weight: 900;
	            cursor: pointer;
	        }

	        .pyxis-print-btn:hover {
	            background: rgba(15, 160, 140, 0.12);
	        }

	        .pyxis-list-body {
	            padding: 12px;
	            max-height: 52vh;
	            overflow: auto;
	        }

	        .pyxis-empty {
	            padding: 18px;
	            text-align: center;
	            color: rgba(70, 78, 90, 0.75);
	            font-weight: 700;
	        }

	        /* Accordion list items */
	        .pyxis-acc-item {
	            margin: 10px 0;
	        }

	        .pyxis-acc-header {
	            width: 100%;
	            display: flex;
	            align-items: center;
	            justify-content: space-between;
	            gap: 10px;
	            padding: 12px 15px;
	            border-radius: 8px;
	            border: 2px solid rgba(138, 160, 179, 0.75);
	            background: rgba(238, 247, 244, 0.95);
	            cursor: pointer;
	            text-align: left;
	        }

	        .pyxis-acc-title {
	            font-size: clamp(1em, 1.6vw, 1.1em);
	            font-weight: 700;
	            color: rgba(45, 55, 70, 0.95);
	            line-height: 1.15;
	            flex: 1;
	            min-width: 0;
	            overflow: hidden;
	            text-overflow: ellipsis;
	            white-space: normal;
            max-width: 240px;
	        }

	        .pyxis-acc-badges {
	            display: flex;
	            align-items: center;
	            gap: 8px;
	        }

	        .pyxis-acc-chevron {
	            font-size: 18px;
	            font-weight: 900;
	            color: rgba(15, 160, 140, 0.9);
	            transform: rotate(-90deg);
	            transition: transform 0.15s ease;
	        }

	        .pyxis-acc-item.expanded .pyxis-acc-chevron {
	            transform: rotate(0deg);
	        }

	        .pyxis-acc-content {
	            display: none;
	            margin-top: 8px;
	            padding: 10px 10px 2px;
	            border-radius: 16px;
	            border: 2px solid rgba(138, 160, 179, 0.55);
	            background: rgba(255, 255, 255, 0.06);
	        }

	        .pyxis-acc-item.expanded .pyxis-acc-content {
	            display: block;
	        }

	        .pyxis-acc-row {
	            display: flex;
	            align-items: center;
	            justify-content: space-between;
	            gap: 10px;
	            padding: 12px 12px;
	            border-radius: 14px;
	            border: 2px solid rgba(138, 160, 179, 0.55);
	            background: rgba(232, 245, 241, 0.75);
	            margin: 8px 0;
	        }

	        .pyxis-acc-row-label {
	            font-size: 16px;
	            font-weight: 800;
	            color: rgba(45, 55, 70, 0.95);
	            overflow: hidden;
	            text-overflow: ellipsis;
	            white-space: normal;
            max-width: 240px;
	        }

	        .pyxis-badge {
	            display: inline-flex;
	            align-items: center;
	            justify-content: center;
	            padding: 6px 10px;
	            border-radius: 999px;
	            font-weight: 900;
	            font-size: 13px;
	            border: 2px solid rgba(15, 160, 140, 0.35);
	            color: rgba(15, 160, 140, 0.95);
	            background: rgba(255, 255, 255, 0.7);
	            font-variant-numeric: tabular-nums;
	        }

	        .pyxis-badge.money {
	            border-color: rgba(46, 204, 113, 0.55);
	            color: rgba(22, 140, 82, 0.95);
	        }

	        .pyxis-badge.standard {
	            border-color: rgba(255, 193, 7, 0.55);
	            color: rgba(152, 111, 0, 0.95);
	            background: rgba(255, 193, 7, 0.14);
	        }

	        .pyxis-badge.nonstandard {
	            border-color: rgba(170, 170, 170, 0.5);
	            color: rgba(118, 126, 138, 0.95);
	            background: rgba(170, 170, 170, 0.16);
	        }

	        .pyxis-sort-select {
	            border: 2px solid rgba(15, 160, 140, 0.65);
	            background: rgba(255, 255, 255, 0.75);
	            color: rgba(18, 24, 33, 0.92);
	            border-radius: 12px;
	            padding: 9px 10px;
	            font-weight: 800;
	            cursor: pointer;
	        }

	        .pyxis-print-btn {
	            border: 2px solid rgba(15, 160, 140, 0.65);
	            background: rgba(255, 255, 255, 0.75);
	            color: rgba(18, 24, 33, 0.92);
	            border-radius: 12px;
	            padding: 9px 10px;
	            font-weight: 900;
	            display: inline-flex;
	            align-items: center;
	            gap: 8px;
	            cursor: pointer;
	        }

	        .pyxis-print-btn:hover {
	            background: rgba(255, 255, 255, 0.9);
	            transform: translateY(-1px);
	        }

	        .pyxis-list-body {
	            padding: 14px 14px 16px;
	            max-height: 52vh;
	            overflow: auto;
	        }

	        .pyxis-accordion-item {
	            border: 2px solid rgba(150, 165, 185, 0.65);
	            border-radius: 16px;
	            background: rgba(238, 247, 244, 0.85);
	            padding: 0;
	            margin-bottom: 12px;
	            overflow: hidden;
	        }

	        .pyxis-accordion-header {
	            width: 100%;
	            display: flex;
	            align-items: center;
	            justify-content: space-between;
	            gap: 12px;
	            padding: 14px 14px;
	            cursor: pointer;
	            background: transparent;
	            border: none;
	            text-align: left;
	        }

	        .pyxis-accordion-title {
	            font-size: 22px;
	            font-weight: 900;
	            color: rgba(35, 45, 58, 0.92);
	            line-height: 1.2;
	        }

	        .pyxis-badge {
	            display: inline-flex;
	            align-items: center;
	            justify-content: center;
	            padding: 6px 10px;
	            border-radius: 999px;
	            background: rgba(15, 160, 140, 0.9);
	            color: #fff;
	            font-weight: 900;
	            font-size: 13px;
	            font-variant-numeric: tabular-nums;
	            white-space: normal;
            max-width: 240px;
	        }

	        .pyxis-accordion-chevron {
	            width: 28px;
	            height: 28px;
	            border-radius: 12px;
	            border: 2px solid rgba(15, 160, 140, 0.65);
	            display: inline-flex;
	            align-items: center;
	            justify-content: center;
	            background: rgba(255, 255, 255, 0.7);
	            flex: 0 0 auto;
	        }

	        .pyxis-accordion-chevron svg {
	            transition: transform 0.18s ease;
	        }

	        .pyxis-accordion-item.expanded .pyxis-accordion-chevron svg {
	            transform: rotate(180deg);
	        }

	        .pyxis-accordion-content {
	            display: none;
	            padding: 0 14px 14px;
	        }

	        .pyxis-accordion-item.expanded .pyxis-accordion-content {
	            display: block;
	        }

	        .pyxis-detail-row {
	            display: flex;
	            align-items: center;
	            justify-content: space-between;
	            gap: 12px;
	            padding: 10px 10px;
	            border-radius: 12px;
	            border: 2px solid rgba(180, 190, 205, 0.55);
	            background: rgba(255, 255, 255, 0.65);
	            margin-top: 10px;
	        }

	        .pyxis-detail-left {
	            display: flex;
	            flex-direction: column;
	            min-width: 0;
	        }

	        .pyxis-detail-primary {
	            font-size: 16px;
	            font-weight: 900;
	            color: rgba(35, 45, 58, 0.92);
	            overflow: hidden;
	            text-overflow: ellipsis;
	            white-space: normal;
            max-width: 240px;
	        }

	        .pyxis-detail-secondary {
	            font-size: 12px;
	            font-weight: 800;
	            color: rgba(70, 78, 90, 0.72);
	            margin-top: 2px;
	        }

        .pyxis-table-frame {
            border: 1px solid var(--border-color);
            background: var(--card-bg);
            border-radius: 14px;
            overflow: hidden;
        }

        .pyxis-table-header {
            padding: 14px 16px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
        }

        .pyxis-table-title {
            font-weight: 800;
            font-size: 15px;
            color: var(--text-primary);
        }

        .pyxis-table-subtitle {
            margin-top: 4px;
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
        }

        .pyxis-table-wrap {
            max-height: 520px;
            overflow: auto;
        }

        .pyxis-summary-table {
            width: 100%;
            border-collapse: collapse;
        }

        .pyxis-summary-table thead th {
            position: sticky;
            top: 0;
            z-index: 1;
            background: var(--bg-secondary);
            color: var(--text-secondary);
            font-size: 12px;
            font-weight: 700;
            padding: 12px 14px;
            border-bottom: 1px solid var(--border-color);
            text-align: left;
            white-space: normal;
            max-width: 240px;
        }

        .pyxis-summary-table tbody td {
            padding: 12px 14px;
            border-bottom: 1px solid var(--border-color);
            color: var(--text-primary);
            font-size: 13px;
            vertical-align: top;
        }

        .pyxis-summary-table tbody tr:hover {
            background: var(--hover-bg);
        }

        .pyxis-td-num {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        .pyxis-td-muted {
            color: var(--text-secondary);
            font-weight: 600;
        }

        .modal-action-btn {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            border: 1px solid var(--border-color);
            background: var(--bg-secondary);
            color: var(--text-primary);
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .modal-action-btn:hover {
            background: var(--hover-bg);
        }

        .pyxis-location-section {
            margin-bottom: 20px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            overflow: hidden;
            background: var(--card-bg);
        }

        .pyxis-location-header {
            padding: 15px 20px;
            background: var(--bg-secondary);
            cursor: pointer;
            user-select: none;
            transition: background 0.2s ease;
        }

        .pyxis-location-header:hover {
            background: var(--hover-bg);
        }

        .pyxis-location-title {
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .collapse-icon {
            width: 20px;
            height: 20px;
            fill: var(--text-secondary);
            transition: transform 0.3s ease;
        }

        .location-name {
            font-size: 16px;
        }

        .location-count {
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: normal;
        }

        .pyxis-location-content {
            max-height: 600px;
            overflow: hidden;
            transition: max-height 0.3s ease, opacity 0.3s ease;
        }

        .pyxis-location-content.expanded {
            max-height: 2000px;
            opacity: 1;
        }

        .pyxis-location-content.collapsed {
            max-height: 0;
            opacity: 0;
        }

        .pyxis-items-table {
            width: 100%;
            border-collapse: collapse;
        }

        .pyxis-items-table thead {
            background: var(--bg-secondary);
            position: sticky;
            top: 0;
            z-index: 1;
        }

        .pyxis-items-table th {
            padding: 12px 15px;
            text-align: left;
            font-weight: 600;
            font-size: 13px;
            color: var(--text-secondary);
            border-bottom: 2px solid var(--border-color);
        }

        .pyxis-items-table td {
            padding: 12px 15px;
            border-bottom: 1px solid var(--border-color);
            font-size: 14px;
            color: var(--text-primary);
        }

        .pyxis-items-table tbody tr:hover {
            background: var(--hover-bg);
        }

        .drug-name-cell {
            font-weight: 500;
            min-width: 250px;
        }

        .qty-cell,
        .cost-cell,
        .usage-cell {
            text-align: center;
            font-variant-numeric: tabular-nums;
        }

        .overage-cell {
            text-align: center;
            color: #ffc107;
            font-weight: 600;
        }

        .cost-cell {
            color: var(--orange-primary);
            font-weight: 500;
        }

        .no-data-message {
            padding: 40px;
            text-align: center;
            color: var(--text-secondary);
            font-size: 16px;
        }

        /* Dark mode adjustments */
        body.dark-mode .pyxis-location-section {
            border-color: var(--dark-border);
        }

        body.dark-mode .pyxis-location-header {
            background: var(--dark-card-hover);
        }

        body.dark-mode .pyxis-location-header:hover {
            background: var(--dark-hover-bg);
        }

        body.dark-mode .pyxis-items-table thead {
            background: var(--dark-card-hover);
        }

        body.dark-mode .pyxis-items-table th {
            border-bottom-color: var(--dark-border);
        }

        body.dark-mode .pyxis-items-table td {
            border-bottom-color: var(--dark-border);
        }

        body.dark-mode .pyxis-items-table tbody tr:hover {
            background: var(--dark-hover-bg);
        }


        /* ===== Forecast & Correlation Cards ===== */
        .mini-select{
            height: 34px;
            padding: 6px 10px;
            border-radius: 10px;
            border: 1px solid var(--card-border);
            background: var(--card-bg);
            color: var(--text-primary);
            font-size: 0.85em;
            outline: none;
            cursor: pointer;
        }
        .mini-select:focus{
            border-color: var(--teal-primary);
            box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.15);
        }

        .stockout-timeline-legend{
            display:grid;
            grid-template-columns: 270px 1fr;
            align-items:center;
            column-gap:16px;
            margin-top:-8px;
            margin-bottom:12px;
        }
        .stockout-timeline-legend-left{
            display:flex;
            align-items:center;
            gap:10px;
            min-width:0;
        }
        .stockout-timeline-legend-right{
            display:flex;
            align-items:center;
            justify-content:center;
            gap:40px;
            min-width:0;
        }
        .legend-pill{
            color: var(--text-primary);
            display:inline-flex;
            align-items:center;
            padding:4px 10px;
            border-radius:999px;
            font-size:0.78em;
            border:1px solid var(--card-border);
            background: rgba(255,255,255,0.06);
        }
        .legend-pill.risk-high{ background: rgba(255,84,84,0.16); border-color: rgba(255,84,84,0.32); }
        .legend-pill.risk-med{ background: rgba(255,132,0,0.14); border-color: rgba(255,132,0,0.30); }
        .legend-pill.risk-low{ background: rgba(102,126,234,0.14); border-color: rgba(102,126,234,0.30); }
        .legend-note{ color: var(--text-primary); opacity:0.75; font-size:0.8em; }


        @media (max-width: 980px){
            .stockout-timeline-legend{
                grid-template-columns: 1fr;
                row-gap: 8px;
            }
            .stockout-timeline-legend-right{
                justify-content:flex-start;
                gap:20px;
                padding-left:0;
            }
        }
        .stockout-timeline{
            position:relative;
            display:flex;
            flex-direction:column;
            margin-top:-5px;
            /* Gantt rows should touch so vertical grid lines appear continuous */
            gap:0;
        }
        .stockout-row{
            display:grid;
            grid-template-columns: 1.2fr 2fr;
            gap:12px;
            align-items:center;
            padding:10px 10px;
            border:1px solid var(--card-border);
            border-radius:12px;
            background: rgba(255,255,255,0.03);
        }
        .stockout-row:hover{
            border-color: rgba(17,153,142,0.45);
            box-shadow: 0 6px 18px rgba(0,0,0,0.08);
        }
        .stockout-left{
            display:flex;
            flex-direction:column;
            gap:4px;
            min-width:0;
        }
        .stockout-title{
            font-weight:700;
            font-size:0.92em;
            white-space:nowrap;
            overflow:hidden;
            text-overflow:ellipsis;
        }
        .stockout-sub{
            font-size:0.78em;
            opacity:0.78;
            white-space:nowrap;
            overflow:hidden;
            text-overflow:ellipsis;
        }
        .stockout-track{
            position:relative;
            height:26px;
            border-radius:12px;
            border:1px solid var(--card-border);
            background: rgba(0,0,0,0.08);
            overflow:hidden;
        }
        .stockout-now{
            position:absolute;
            left:0;
            top:0;
            bottom:0;
            width:2px;
            background: rgba(255,255,255,0.65);
        }
        .stockout-bar{
            position:absolute;
            top:4px;
            bottom:4px;
            border-radius:10px;
        }
        .stockout-bar.risk-high{ background: rgba(255,84,84,0.55); }
        .stockout-bar.risk-med{ background: rgba(255,132,0,0.55); }
        .stockout-bar.risk-low{ background: rgba(102,126,234,0.55); }
        .stockout-meta{
            position:absolute;
            right:8px;
            top:50%;
            transform: translateY(-50%);
            font-size:0.76em;
            opacity:0.85;
            background: rgba(0,0,0,0.25);
            padding:2px 8px;
            border-radius:999px;
            border:1px solid rgba(255,255,255,0.10);
            pointer-events:none;
        }



        /* --- Stock-out Risk Timeline (grouped Gantt / usage distribution) --- */
        .stockout-item-group{
            border:1px solid var(--card-border);
            border-radius:14px;
            padding:12px 12px;
            background: rgba(255,255,255,0.03);
            display:flex;
            flex-direction:column;
            gap:10px;
        }
        .stockout-item-header{
            display:flex;
            align-items:flex-start;
            justify-content:space-between;
            gap:10px;
        }
        .stockout-item-title{
            font-weight:800;
            font-size:0.95em;
            color: var(--text-primary);
            min-width:0;
            overflow:hidden;
            text-overflow:ellipsis;
            white-space:nowrap;
        }
        .stockout-item-meta{
            display:flex;
            align-items:center;
            gap:8px;
            flex-shrink:0;
            color: var(--text-primary);
        }
        .stockout-item-stats{
            font-size:0.78em;
            opacity:0.78;
        }
        .stockout-usage-track{
            position:relative;
            height:30px;
            border-radius:14px;
            border:1px solid var(--card-border);
            background: rgba(0,0,0,0.10);
            overflow:hidden;
        }
        .stockout-usage-seg{
            position:absolute;
            top:4px;
            bottom:4px;
            border-radius:10px;
            overflow:hidden;
            cursor:pointer;
        }
        .stockout-usage-seg.tier-high{ background: rgba(255,84,84,0.55); }
        .stockout-usage-seg.tier-med{  background: rgba(255,132,0,0.55); }
        .stockout-usage-seg.tier-low{  background: rgba(102,126,234,0.55); }
        .stockout-usage-label{
            position:absolute;
            left:8px;
            top:50%;
            transform: translateY(-50%);
            font-size:0.76em;
            font-weight:700;
            color: rgba(255,255,255,0.92);
            text-shadow: 0 1px 2px rgba(0,0,0,0.35);
            pointer-events:none;
            white-space:nowrap;
        }
        .stockout-loc-row{
            display:flex;
            flex-wrap:wrap;
            gap:8px;
        }
        .stockout-loc-badge{
            display:inline-flex;
            align-items:center;
            justify-content:center;
            padding:4px 10px;
            border-radius:999px;
            border:1px solid var(--card-border);
            background: rgba(255,255,255,0.06);
            color: var(--text-primary);
            font-size:0.78em;
            cursor:pointer;
            user-select:none;
        }
        .stockout-loc-badge:hover{
            border-color: rgba(17,153,142,0.45);
        }

        /* Score-based Stock-out Timeline (v2) */
        .legend-pill.risk-stockout,
        .legend-pill.risk-overstock{
            background: transparent;
            border: none;
            border-radius: 0;
            padding: 0;
            font-size: 0.8em;
            font-weight: 450;
        }
        .legend-pill.risk-stockout{
            color: rgba(255,84,84,0.95);
        }
        .legend-pill.risk-overstock{
            color: rgba(128,164,255,0.98);
        }
        .legend-pill.risk-standard{
            background: rgba(255,84,84,0.14);
            border: 1px solid rgba(255,84,84,0.35);
            color: rgba(255,180,180,0.95);
        }
        .legend-pill.risk-nonstandard{
            background: rgba(160,160,160,0.16);
            border: 1px solid rgba(180,180,180,0.42);
            color: rgba(220,220,220,0.96);
        }
        .stockout-score-track{
            position:relative;
            border-radius:14px;
            border:1px solid var(--card-border);
            background: rgba(0,0,0,0.10);
            overflow:hidden;
            min-height:44px;
        }
        .stockout-score-seg{
            position:absolute;
            height:22px;
            border-radius:10px;
            overflow:hidden;
            cursor:pointer;
            display:flex;
            align-items:center;
            justify-content:center;
            box-shadow: 0 1px 2px rgba(0,0,0,0.18);
        }
        .stockout-score-seg.seg-standard{ background: rgba(255,84,84,0.65); }
        .stockout-score-seg.seg-nonstandard{ background: rgba(255,132,0,0.60); }
        .stockout-score-label{
            font-size:0.78em;
            font-weight:800;
            color: rgba(255,255,255,0.92);
            text-shadow: 0 1px 2px rgba(0,0,0,0.35);
            pointer-events:none;
            white-space:nowrap;
            padding:0 8px;
        }
        .stockout-item-group.score-v2 .stockout-item-stats{
            opacity:0.85;
        }
    

        
        /* Stock-out Gantt (score axis) – reference-style layout */
        /* Hide score labels (requested) */
        .stockout-gantt-axis{
            display:none;
        }
        .stockout-gantt-axis-track{
            /* Move the timeline start about 30px to the right */
            width: calc(100% - 270px);
            display:grid;
            grid-auto-flow:column;
            grid-auto-columns: 1fr;
            gap:0;
            align-items:end;
            color: var(--text-primary);
            opacity:0.85;
            font-weight:800;
            font-size:0.92em;
        }
        .stockout-gantt-tick{
            text-align:center;
            padding:2px 0;
        }

        .stockout-gantt-row{
            display:grid;
            /* Move timeline right so it doesn't overlap the left list */
            grid-template-columns: 270px 1fr;
            gap:16px;
            /* Stretch tracks to full row height so vertical grid lines don't show gaps between rows */
            align-items:stretch;
            padding:0;
        }
        .stockout-gantt-left{
            min-width:0;
            display:flex;
            align-items:center;
        }
        .stockout-gantt-title{
            font-size: 15px;
            font-size: 15px;
            font-weight: 500;
            color: var(--text-primary);
            white-space:nowrap;
            overflow:hidden;
            text-overflow:ellipsis;
        }

        .stockout-origin-overlay{
            position:absolute;
            width:1px;
            background: rgba(180,180,180,0.45);
            pointer-events:none;
            z-index:1;
        }

        .stockout-gantt-track{
            position:relative;
            /* Fill row height so grid lines are continuous with no vertical gaps */
            height:100%;
            min-height:44px;
            /* Prevent segments/animation from bleeding into the left item list */
            overflow:hidden;
            border-top: none;
        }

        /* When zoomed, give every row a bit more height to help avoid overlaps */
        #stockOutTimeline.gantt-zoomed .stockout-gantt-track{
            height:44px;
            min-height:44px;
            transition: height 220ms ease;
        }

        /* Smooth segment motion when zooming */
        #stockOutTimeline .stockout-gantt-seg{
            transition: left 220ms ease, transform 220ms ease;
        }
        body.dark-mode .stockout-gantt-track{
            border-top: none;
        }
        .stockout-gantt-track::before,
        .stockout-gantt-track::after{
            content:none;
        }

        .stockout-gantt-seg{
            position:absolute;
            top:4px;
            height:24px;
            border-radius:8px;
            display:flex;
            align-items:center;
            justify-content:center;
            transform: translateX(-50%);
            cursor:pointer;
            /* No shadows on segments (requested) */
            box-shadow: none;
            border: 1px solid rgba(0,0,0,0.10);
        }

        /* Slide-out/in animation helpers for zoom transitions */
        .stockout-gantt-seg.seg-exit{
            opacity:0;
            transform: translateX(-90px) translateX(-50%);
        }
        .stockout-gantt-seg.seg-enter{
            opacity:0;
            transform: translateX(90px) translateX(-50%);
        }
        body.dark-mode .stockout-gantt-seg{
            border: 1px solid rgba(255,255,255,0.12);
        }
        .stockout-gantt-seg.seg-stockout.seg-standard{ background: rgba(255,84,84,0.68); }
        .stockout-gantt-seg.seg-overstock.seg-standard{ background: rgba(80,132,255,0.70); }
        .stockout-gantt-seg.seg-standard{ background: rgba(255,84,84,0.68); }
        .stockout-gantt-seg.seg-nonstandard{ background: rgba(160,160,160,0.35); }

        .stockout-gantt-seg-label{
            font-size:0.82em;
            font-weight:900;
            color: rgba(255,255,255,0.92);
            text-shadow: 0 1px 2px rgba(0,0,0,0.35);
            padding:0 10px;
            white-space:nowrap;
            pointer-events:none;
        }

        body.dark-mode .stockout-gantt-axis-track{ opacity:0.92; }
        body.dark-mode .stockout-gantt-title{ color: rgba(255,255,255,0.90); }

/* Dark-mode readability fixes for Insights charts */
        body.dark-mode .waste-usage-tooltip{ color: var(--text-primary); }
        body.dark-mode .stockout-item-stats{ opacity:0.82; }
        .waste-usage-wrap{ display:flex; flex-direction:column; gap:12px; }
        .waste-usage-scatter{
            width:100%;
            height:320px;
            border:none;
            border-radius:0;
            background: rgba(255,255,255,0.03);
            overflow:hidden;
            position:relative;
        }
        .waste-usage-summary{
            display:flex;
            flex-wrap:wrap;
            gap:10px;
        }
        .quadrant-chip{
            display:flex;
            align-items:center;
            gap:8px;
            padding:8px 10px;
            border-radius:12px;
            border:1px solid var(--card-border);
            background: rgba(255,255,255,0.03);
            cursor:pointer;
            user-select:none;
        }
        .quadrant-chip:hover{
            border-color: rgba(17,153,142,0.45);
        }
        .quadrant-chip .q-title{ font-weight:700; font-size:0.85em; }
        .quadrant-chip .q-meta{ font-size:0.78em; opacity:0.78; }
        .waste-usage-tooltip{
            position:fixed;
            white-space: normal;
            word-break: normal;
            overflow-wrap: break-word;
            z-index:9999;
            padding:10px 12px;
            border-radius:12px;
            border:1px solid var(--card-border);
            background: var(--card-bg);
            box-shadow: var(--card-shadow);
            font-size:0.85em;
            pointer-events:none;
            width: 280px;
            max-width: calc(100% - 16px);
            line-height: 1.35;
        }

        /* ── Waste Detail Modal (wdm) ── */
        .modal-overlay.active .wdm-container{ animation: wdmIn 0.25s cubic-bezier(0.34,1.26,0.64,1); }
        .modal-overlay.closing .wdm-container{ transform: translateY(-20px); opacity: 0; transition: all 0.2s ease; }
        @keyframes wdmIn{ from{ transform: translateY(16px); opacity: 0; } to{ transform: none; opacity: 1; } }
        .wdm-container{
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            width: min(1080px, calc(100vw - 32px));
            max-height: calc(100vh - 48px);
            overflow-y: auto;
            background: rgba(11, 32, 42, 0.97);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 18px;
            padding: 28px 32px 24px;
            color: #e8eef2;
            box-shadow: 0 24px 60px rgba(0,0,0,0.5);
            display: flex;
            flex-direction: column;
            gap: 0;
        }
        .wdm-header{
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 24px;
        }
        .wdm-header-left{
            display: flex;
            align-items: center;
            gap: 16px;
            min-width: 0;
            flex: 1;
        }
        .wdm-drug-name{
            font-size: 1.25em;
            font-weight: 700;
            line-height: 1.2;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            flex-shrink: 1;
        }
        .wdm-header-sep{
            width: 1px;
            height: 24px;
            background: rgba(255,255,255,0.22);
            flex-shrink: 0;
        }
        .wdm-total-waste{
            font-size: 0.9em;
            white-space: nowrap;
            opacity: 0.88;
        }
        .wdm-total-waste strong{
            font-size: 1.08em;
            color: #e8eef2;
        }
        .wdm-close{
            flex-shrink: 0;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.18);
            background: rgba(255,255,255,0.06);
            color: #e8eef2;
            font-size: 22px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .wdm-close:hover{ background: rgba(255,255,255,0.12); }
        .wdm-body{
            display: grid;
            grid-template-columns: minmax(180px, 0.7fr) minmax(280px, 1.3fr);
            gap: 0;
            align-items: start;
        }
        .wdm-col-left{
            border-right: 1px solid rgba(255,255,255,0.1);
            padding-right: 24px;
        }
        .wdm-col-right{
            padding-left: 24px;
            min-width: 0;
        }
        .wdm-section-title{
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.82em;
            font-weight: 600;
            opacity: 0.7;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin-bottom: 14px;
        }
        .wdm-icon{
            width: 16px;
            height: 16px;
            fill: currentColor;
            flex-shrink: 0;
            opacity: 0.8;
        }
        .waste-detail-location-total{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 9px 0;
            border-top: 1px solid rgba(255,255,255,0.07);
            font-size: 0.9em;
        }
        .waste-detail-location-total:first-of-type{ border-top: 0; padding-top: 0; }
        .waste-detail-location-total strong{
            color: var(--teal-primary, #11998e);
            font-weight: 700;
        }
        .waste-detail-empty{
            font-size: 0.82em;
            opacity: 0.6;
            padding: 6px 0;
        }
        .wdm-stats-bar{
            display: flex;
            align-items: center;
            gap: 0;
            padding-bottom: 20px;
        }
        .wdm-stats-bar--top{
            border-bottom: 1px solid rgba(255,255,255,0.1);
            margin-bottom: 0;
            padding-bottom: 18px;
        }
        .wdm-total-qty{ font-size: 0.88em; opacity: 0.72; font-weight: 400; }
        .wdm-no-detail{ font-size: 0.82em; opacity: 0.55; }
        /* Location breakdown table */
        .wdm-loc-table-wrap{
            overflow-x: auto;
            margin: 0 -4px;
            border-radius: 8px;
        }
        .wdm-loc-table{
            width: 100%;
            border-collapse: collapse;
            font-size: 0.82em;
            min-width: 680px;
        }
        .wdm-th{
            padding: 8px 10px;
            text-align: left;
            font-size: 0.78em;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            opacity: 0.6;
            border-bottom: 1px solid rgba(255,255,255,0.12);
            white-space: nowrap;
        }
        .wdm-th-num, .wdm-td-num{ text-align: right; }
        .wdm-th-loc{ min-width: 100px; }
        .wdm-td{
            padding: 7px 10px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            vertical-align: middle;
            white-space: nowrap;
        }
        .wdm-td-loc{
            font-weight: 600;
            color: var(--teal-primary, #11998e);
            vertical-align: top;
            border-right: 1px solid rgba(255,255,255,0.08);
        }
        .wdm-td-waste{ font-weight: 700; color: #f87171; }
        .wdm-loc-first .wdm-td{ border-top: 1px solid rgba(255,255,255,0.1); }
        .wdm-loc-table tbody tr:hover .wdm-td{ background: rgba(255,255,255,0.04); }
        .wdm-stat{
            display: flex;
            align-items: center;
            gap: 10px;
            flex: 1;
        }
        .wdm-stat-divider{
            width: 1px;
            height: 40px;
            background: rgba(255,255,255,0.12);
            margin: 0 20px;
            flex-shrink: 0;
        }
        .wdm-stat-label{
            display: block;
            font-size: 0.76em;
            opacity: 0.62;
            margin-bottom: 3px;
        }
        .wdm-stat-value{
            display: block;
            font-size: 1.08em;
            font-weight: 700;
        }
        .wdm-days{
            font-size: 0.82em;
            opacity: 0.72;
            font-weight: 400;
        }
        .wdm-sep-line{
            border: none;
            border-top: 1px solid rgba(255,255,255,0.1);
            margin: 0 0 20px;
        }
        .wdm-qty-label-title{
            font-size: 0.82em;
            font-weight: 600;
            opacity: 0.7;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin-bottom: 24px;
        }
        .wdm-qty-track-wrap{ padding: 0 4px; }
        .wdm-qty-track{
            display: flex;
            align-items: center;
            gap: 0;
            margin-bottom: 10px;
        }
        .wdm-qty-tick{
            display: block;
            width: 2px;
            height: 20px;
            background: rgba(255,255,255,0.4);
            border-radius: 1px;
            flex-shrink: 0;
        }
        .wdm-qty-line{
            flex: 1;
            position: relative;
            height: 2px;
            background: rgba(255,255,255,0.25);
            margin: 0 2px;
        }
        .wdm-qty-marker{
            position: absolute;
            top: 50%;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #11998e;
            border: 3px solid rgba(255,255,255,0.9);
            box-shadow: 0 2px 10px rgba(17,153,142,0.5);
            transform: translate(-50%, -50%);
        }
        .wdm-qty-labels{
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            font-size: 0.9em;
            font-weight: 700;
        }
        .wdm-qty-labels span:last-child{ text-align: right; }
        .wdm-qty-current{
            color: #11998e;
            text-align: center;
        }
        .wdm-drill{
            align-self: flex-start;
            margin-top: 24px;
            border: 1px solid rgba(17,153,142,0.4);
            background: rgba(17,153,142,0.1);
            color: #e8eef2;
            border-radius: 8px;
            padding: 8px 16px;
            font-family: inherit;
            font-size: 0.88em;
            font-weight: 600;
            cursor: pointer;
            letter-spacing: 0.01em;
        }
        .wdm-drill:hover{ background: rgba(17,153,142,0.2); }
        @media (max-width: 640px){
            .wdm-container{ padding: 20px; }
            .wdm-body{ grid-template-columns: 1fr; }
            .wdm-col-left{ border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.1); padding-right: 0; padding-bottom: 20px; }
            .wdm-col-right{ padding-left: 0; padding-top: 20px; }
            .wdm-drug-name{ font-size: 1.05em; }
        }



        /* ===== Insights layout (Top Used / Pyxis / Stock-out / Cost / Waste / Correlation) ===== */
        .analytics-grid.insights-grid{
            grid-template-columns: repeat(2, minmax(0, 1fr));
            grid-template-areas:
                "topUsed pyxis"
                "stockout stockout"
                "invCost wasteUsage"
                "waste wasteUsage";
            align-items: stretch;
        }
        .analytics-grid.insights-grid #topUsedItemsCard{ grid-area: topUsed; }
        .analytics-grid.insights-grid #pyxisMetricsCard{ grid-area: pyxis; }
        .analytics-grid.insights-grid #stockOutTimelineCard{ grid-area: stockout; }
        .analytics-grid.insights-grid #inventoryCostCard{ grid-area: invCost; }
        .analytics-grid.insights-grid #wasteCard{ grid-area: waste; }
        .analytics-grid.insights-grid #wasteUsageCard{ grid-area: wasteUsage; }

        /* Ensure spanning cards stretch naturally */
        .analytics-grid.insights-grid .analytics-card{ height: 100%; }

        /* Make correlation plot take advantage of the 2-card height */
        .analytics-grid.insights-grid #wasteUsageCard{
            display:flex;
            flex-direction:column;
        }
        .analytics-grid.insights-grid #wasteUsageCard .waste-usage-wrap{
            flex:1;
            min-height: 560px; /* roughly two KPI cards */
        }
        .analytics-grid.insights-grid #wasteUsageCard .waste-usage-scatter{
            height:auto;
            min-height: 380px;
            flex:1;
        }



/* Waste vs Usage selection header */
.waste-usage-card .card-header{ display:flex; align-items:center; justify-content:space-between; }
.waste-usage-header-right{ text-align:right; line-height:1.1; }
.waste-usage-selected-total{ font-weight:700; font-size:28px; color: var(--accent-coral, #ff7a6b); }
.waste-usage-selected-caption{ margin-top:-1px; font-size:12px; letter-spacing:0.08em; text-transform:uppercase; color: var(--accent-coral, #ff7a6b); opacity:0.95; }

.waste-mini-bar.selected{ background: var(--accent-coral, #ff7a6b) !important; opacity:0.55; }

.waste-bar-wrap.is-selected .waste-bar{ background: var(--accent-coral, #ff7a6b) !important; opacity:0.55; }


/* Stockout Gantt expansion styling */
.stockout-gantt-seg.seg-muted{
    opacity: 0.22;
    filter: grayscale(1);
    pointer-events: none;
}
.stockout-gantt-seg.seg-expanded{
    z-index: 3;
}

/* Stockout KPI (header right) */
.stockout-kpi-right{
    margin-left:auto;
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    gap:2px;
}
.stockout-kpi-total{
    font-size:1.25em;
    font-weight:800;
    letter-spacing:0.2px;
}
.stockout-kpi-caption{
    font-size:0.78em;
    opacity:0.72;
}

.stockout-mode-toggle{
    font-size:0.72em;
    padding:5px 8px;
    margin-bottom:4px;
}


/* Unified SVG sprite icon styling */
.ui-icon{
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  vector-effect: non-scaling-stroke;
}
.ui-icon use{ pointer-events: none; }

/* Pyxis PAR Summary */
.pyxis-adj-controls,
.pyxis-adj-bars {
    display: none;
}

.pyxis-par-metrics {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.pyxis-par-metric {
    border: 1px solid var(--border-color);
    background: var(--header-columns-bg);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 8px 9px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 64px;
    cursor: pointer;
}

.pyxis-par-metric-label {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.pyxis-par-metric-value {
    font-size: 19px;
    font-weight: 800;
    line-height: 1;
}

.pyxis-par-metric.active[data-bucket="coral"] {
    border-color: rgba(219, 72, 77, 0.6);
    background: rgba(219, 72, 77, 0.12);
    color: #cf4448;
}

.pyxis-par-metric.active[data-bucket="blue"] {
    border-color: rgba(77, 110, 200, 0.6);
    background: rgba(77, 110, 200, 0.12);
    color: #4d6ec8;
}

.pyxis-par-metric.active[data-bucket="gray"] {
    border-color: rgba(105, 112, 120, 0.6);
    background: rgba(105, 112, 120, 0.14);
    color: #697078;
}

.pyxis-par-metric:disabled {
    cursor: default;
    opacity: 0.65;
}

.pyxis-par-locations {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-height: 150px;
    max-height: 230px;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pyxis-par-location {
    border: 1px solid var(--border-color);
    background: var(--header-columns-bg);
    border-radius: 7px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    cursor: pointer;
}

.pyxis-par-location-main {
    font-size: 12px;
    font-weight: 700;
}

.pyxis-par-location-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.pyxis-par-locations-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
}

@media (max-width: 640px) {
    .pyxis-par-metrics {
        grid-template-columns: 1fr;
    }
}
