:root {
            --primary-color: #008080; 
            --primary-dark-color: #006064;
            --secondary-color: #e0f2f1; 
            --text-color: #3A4750;
            --heading-color: var(--primary-color);
            --border-color: #e0e0e0;
            --input-border-color: #cfd8dc;
            /* --background-color: #f0f4f4; */ /* Background removed */
            --card-background-color: #ffffff;
            --card-header-background: #f8f9fa;
            --error-color: #e53935; 
            --error-dark-color: #c62828;
            --success-color: #4CAF50;
            --warning-color: #FFC107;
            --shadow: 0 4px 15px rgba(0,0,0,0.08);
            --input-focus-shadow: 0 0 0 3px rgba(0, 128, 128, 0.2);
            --button-shadow: 0 2px 5px rgba(0,0,0,0.1);

            /* ===================== LOGO VARIABLES (DESKTOP DEFAULTS) ===================== */
            --logo-width: 260px;         /* Default logo width, change as needed */
            --logo-height: 80px;         /* Default logo height, change as needed */
            --logo-align: center;        /* Options: left, center, right */
            --logo-align-offset: -20px;  /* Manual horizontal adjustment (e.g. -20px, 10px) */

            /* ===================== PURCHASE ORDER HEADBOX (DESKTOP DEFAULTS) ===================== */
            --purchase-order-headbox-width: 110%;          /* Desktop: headbox width */
    --purchase-order-headbox-margin-top: 0px;     /* Desktop: top space for headbox */
    --purchase-order-headbox-margin-bottom: 0px; /* Desktop: bottom space for headbox */
    --purchase-order-headbox-align-offset-x: -25px; /* Desktop: horizontal movement (left/right, e.g. -20px, 10px) */
    --purchase-order-headbox-align-offset-y: -25px; /* Desktop: vertical movement (up/down, e.g. -10px, 10px) */
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body,
        input,
        button,
        select,
        textarea,
        table,
        th,
        td,
        h1,
        h2,
        h3,
        h4,
        h5,
        h6,
        label,
        span,
        div,
        p,
        a {
            font-family: 'Poppins', sans-serif !important;
        }

        body {
            /* background-color: var(--background-color); */ /* Background removed */
            background-attachment: fixed;
            color: var(--text-color);
            line-height: 1.6;
            padding: 20px;
            display: flex;
            flex-direction: column; /* Add this */
            justify-content: flex-start; /* Change from center to flex-start */
            align-items: center; /* Center all children horizontally */
            min-height: 100vh;
            width: 100%;
            overflow-x: hidden; 
        }

        .container {
            max-width: 550px; 
            margin: 20px auto;
            background: var(--card-background-color);
            border-radius: 12px; 
            box-shadow: var(--shadow);
            padding: 25px; 
            display: flex;
            flex-direction: column;
            width: 100%;
            opacity: 0; 
            transform: translateY(20px); 
            animation: fadeInSlideUp 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
        }
        
        h1 {
            color: var(--heading-color);
            font-size: 2.2rem;
            text-align: center;
            margin-bottom: 0;
            font-weight: 700;
        }

        h2 {
            font-size: 1.3rem; 
            margin: 30px 0 15px; 
            font-weight: 600;
            color: var(--heading-color);
            text-transform: uppercase;
            border-bottom: 2px solid var(--secondary-color); 
            padding-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        h2 i { 
            font-size: 1.1rem;
            color: var(--primary-color);
        }


        .input-group { 
            margin-bottom: 10px;
        }

        /* input label implicitly handled by placeholder */

        input {
            width: 100%;
            padding: 12px; 
            margin-top: 4px; 
            border: 1px solid var(--input-border-color);
            border-radius: 8px; 
            font-size: 1rem;
            transition: all 0.3s ease;
            background-color: #fdfdfd;
        }
        input:focus{
            border-color: var(--primary-color);
            box-shadow: var(--input-focus-shadow);
            outline: none;
            background-color: #fff;
        }
        input.invalid {
            border-color: var(--error-color) !important; 
            background-color: #fff5f5;
        }
        input.invalid:focus {
            border-color: var(--error-dark-color) !important;
            box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.2) !important;
            outline: none;
        }

        .add-button {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 10px 18px;
            border-radius: 6px;
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            box-shadow: var(--button-shadow);
            white-space: nowrap;
        }

        .add-button:hover {
            background-color: var(--primary-dark-color);
            box-shadow: 0 4px 8px rgba(0,0,0,0.12);
            transform: translateY(-2px); 
        }
        .add-button:active {
            transform: translateY(0px); 
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        .add-button.added {
            background-color: var(--error-color);
        }
        .add-button.added:hover {
            background-color: var(--error-dark-color);
        }

        .group {
            margin-bottom: 20px;
            border: 1px solid var(--border-color);
            border-radius: 10px; 
            overflow: hidden;
            background-color: #fdfdff; 
            box-shadow: 0 3px 8px rgba(0,0,0,0.06);
            transition: box-shadow 0.3s ease-out, transform 0.3s ease-out;
            position: relative; /* Needed for sticky child */
        }
         .group:hover {
            box-shadow: 0 6px 18px rgba(0,0,0,0.12);
            transform: translateY(-3px) scale(1.01);
        }

        .group-header {
            background-color: var(--secondary-color);
            padding: 16px; 
            font-weight: 600; 
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.3s ease;
            position: sticky;
            top: 0;
            z-index: 2;
            background-color: var(--secondary-color);
            /* Add subtle shadow when sticky */
            box-shadow: 0 2px 6px rgba(54,182,187,0.04);
        }
        .group-header:hover {
            background-color: #cce8e5; 
        }

        .group-header span:first-child { 
            font-size: 1.1rem;
            color: var(--primary-dark-color);
        }

        .group-header span:last-child { 
            font-size: 1.3em; 
            color: var(--primary-color);
            transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .group.open .group-header span:last-child {
            transform: rotate(180deg);
        }

        .group-controls {
            padding: 16px; 
            background: var(--card-header-background); 
            border-bottom: 1px solid var(--border-color);
        }

        .group-search {
            width: 100%;
            padding: 10px 12px; 
            border: 1px solid var(--input-border-color);
            border-radius: 6px; 
            font-size: 0.95rem; 
            transition: all 0.3s ease;
        }
        .group-search:focus{
            border-color: var(--primary-color);
            box-shadow: var(--input-focus-shadow);
            outline: none;
        }
        
        .group-products {
            background-color: var(--card-background-color);
            max-height: 0; 
            overflow-y: hidden; 
            transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1); 
        }
         .group.open .group-products {
            max-height: 1000px; 
             overflow-y: auto; 
        }

        /* On mobile, ensure sticky works and group-products scrolls */
@media (max-width: 600px) {
    .group.open .group-products {
        max-height: 320px;
        overflow-y: auto;
    }
    .group-header {
        top: 0;
        z-index: 3;
    }
}

        .product {
            padding: 16px; 
            border-bottom: 1px solid #f0f0f0; 
            display: flex;
            align-items: center;
            gap: 12px; 
            justify-content: space-between;
            transition: background-color 0.2s ease, transform 0.2s ease; /* Added transform for potential shake */
        }
        .product.product-added-in-cart { /* Style for items added to cart for visual distinction */
            background-color: #e0f2f1; /* Light teal background */
        }

        .product:hover {
            background-color: #f9f9f9;
        }

        .product:last-child {
            border-bottom: none;
        }

        .product-name {
            font-weight: 500;
            color: var(--text-color); 
            font-size: 1.05rem;
            flex-grow: 1; 
            flex-basis: 0; 
        }

        .product-price {
            color: var(--primary-color);
            font-weight: 600;
            font-size: 1rem;
            text-align: center;
            background-color: transparent;
            border-radius: 0;
            padding: 0; 
            width: auto; height: auto; 
            display: inline;
        }
        
        .product-controls-mobile { 
            display: flex;
            align-items: center;
            gap: 12px; 
            flex-shrink: 0; 
        }

        .qty-input {
            padding: 8px;
            border: 1px solid var(--input-border-color);
            border-radius: 6px;
            text-align: center;
            font-size: 0.95rem;
            transition: all 0.3s ease;
            flex-basis: 80px; 
        }
        .qty-input:focus {
            border-color: var(--primary-color);
            box-shadow: var(--input-focus-shadow);
            outline: none;
        }
        
        .product-controls-mobile .qty-input { 
             flex-basis: 80px;
             width: 80px;
        }
        .product-controls-mobile .add-button { 
            min-width: 120px;
        }


        .total-section {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 2px solid var(--secondary-color); 
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .total-amount {
            font-size: 1.8rem; 
            font-weight: 700; 
            color: var(--primary-color);
            margin-bottom: 18px; 
        }

        .order-summary {
            margin-top: 30px;
            border: 1px solid var(--border-color);
            border-radius: 10px;
            background-color: var(--card-background-color); 
            box-shadow: 0 3px 10px rgba(0,0,0,0.07);
        }

        .order-summary-header {
            padding: 16px;
            background-color: var(--secondary-color); 
            border-top-left-radius: 10px; 
            border-top-right-radius: 10px; 
            border-bottom: 1px solid var(--border-color);
        }
        
        .order-summary-header .title {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--primary-dark-color); 
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .order-summary-header .description {
            font-size: 0.95rem;
            color: #546e7a; 
            margin-top: 5px;
        }
        
        .order-summary-content {
            padding: 0; 
        }

        .empty-cart-message {
            text-align: center;
            padding: 30px 15px; 
            color: #546e7a;
        }
        .empty-cart-message i {
            font-size: 2.5rem; 
            color: var(--primary-color); 
            margin-bottom: 15px;
            display: block; 
        }

         .empty-cart-message p {
            font-size: 1.1rem; 
            margin-bottom: 8px;
            font-weight: 500;
        }
        .empty-cart-message span {
            font-size: 0.95rem;
        }
        
        .table-responsive-wrapper {
            overflow-x: auto; 
            width: 100%; 
        }

        .cart-table-modern {
            width: 100%;
            border-collapse: collapse;
        }

        .cart-table-modern th,
        .cart-table-modern td {
            padding: 12px 15px; 
            border-bottom: 1px solid var(--border-color); 
            border-right: 1px solid var(--border-color); 
            vertical-align: middle;
            white-space: nowrap; 
        }
        .cart-table-modern th:last-child,
        .cart-table-modern td:last-child {
            border-right: none; 
        }
        .cart-table-modern tr:last-child td {
            border-bottom: none; 
        }


        .cart-table-modern th {
            background-color: #f9fafb; 
            color: var(--primary-dark-color); 
            font-weight: 600; 
            text-transform: uppercase;
            font-size: 0.85rem; 
            letter-spacing: 0.05em;
            text-align: left;
        }
        
        .cart-table-modern th:nth-child(1), 
        .cart-table-modern td:nth-child(1) {
            text-align: left;
            white-space: normal; 
        }

        .cart-table-modern th:not(:first-child), 
        .cart-table-modern td:not(:first-child) { 
            text-align: center;
        }

        .cart-table-modern td {
            font-size: 0.95rem; 
            color: var(--text-color);
        }

        .cart-table-modern .font-semibold {
            font-weight: 600;
            font-size: 1.1rem; 
        }

        .cart-table-modern .remove-item-btn-modern {
            background-color: transparent;
            color: var(--error-color); 
            border: none;
            padding: 6px; 
            border-radius: 50%; 
            font-size: 1.1rem; 
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); 
            display: inline-flex; 
            align-items: center;
            justify-content: center;
            width: 32px; 
            height: 32px; 
        }

        .cart-table-modern .remove-item-btn-modern:hover {
            background-color: #feebee; 
            color: var(--error-dark-color); 
            transform: scale(1.1); 
        }
        
        #downloadExcelButton {
            background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark-color) 100%);
            color: #fff;
            border: none;
            padding: 10px 16px; /* Reduced horizontal padding */
            border-radius: 5px;
            font-size: 1.05rem;
            font-weight: 500;
            cursor: pointer;
            margin-top: 15px;
            transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
            align-self: center;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px; /* Less gap between icon and text */
            white-space: nowrap;
            box-shadow: none;
            min-width: 0;
            max-width: 260px; /* Optional: limit max width */
        }

        #downloadExcelButton:hover {
            background: linear-gradient(90deg, var(--primary-dark-color) 0%, var(--primary-color) 100%);
            transform: translateY(-1px) scale(1.03);
            box-shadow: 0 2px 8px rgba(0,128,128,0.07); /* Very subtle shadow on hover */
        }
         #downloadExcelButton:active {
            transform: scale(0.98);
            box-shadow: none;
        }

        #downloadAndShareButton {
            background-color: var(--primary-color);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 1.05rem;
            font-weight: 500;
            cursor: pointer;
            margin-top: 15px;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            align-self: center;
            box-shadow: var(--button-shadow);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            white-space: nowrap;
        }
        #downloadAndShareButton:hover {
            background-color: var(--primary-dark-color);
            box-shadow: 0 4px 8px rgba(0,0,0,0.12);
            transform: translateY(-2px);
        }
        #downloadAndShareButton:active {
            transform: translateY(0px);
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        #clear-btn {
            background: linear-gradient(90deg,#ff6666 0%,#ff9966 100%);
            color: #fff;
            border: none;
            padding: 10px 16px;
            border-radius: 5px;
            font-size: 1.05rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
            align-self: center;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            white-space: nowrap;
            box-shadow: none;
            min-width: 0;
            max-width: 260px;
        }
        #clear-btn:hover {
            background: linear-gradient(90deg,#ff9966 0%,#ff6666 100%);
            transform: translateY(-1px) scale(1.03);
            box-shadow: 0 2px 8px rgba(255,102,102,0.07);
        }
        #clear-btn:active {
            transform: scale(0.98);
            box-shadow: none;
        }

        .toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .toast {
            background-color: var(--text-color);
            color: white;
            padding: 15px 20px;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
            display: flex;
            align-items: center;
            gap: 10px;
            opacity: 0;
            transform: translateX(100%);
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
            min-width: 280px;
        }

        .toast.show {
            opacity: 1;
            transform: translateX(0);
        }
        
        .toast.hide {
            opacity: 0;
            transform: translateX(100%);
        }

        .toast i {
            font-size: 1.2rem;
        }

        .toast.success { background-color: var(--success-color); }
        .toast.error { background-color: var(--error-color); }
        .toast.warning { background-color: var(--warning-color); color: #333; }

        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border-width: 0;
        }

        @media (min-width: 600px) { 
            .product .product-name { flex-basis: auto; flex-grow: 1; }
            .product .product-price { text-align: center; }
        }


        @media (max-width: 768px) {
            .container {
                width: 95%; 
                padding: 20px;
            }
             h1 {
                font-size: 1.8rem; 
                margin-bottom: 20px;
            }
            .purchase-order-headbox {
                margin: -20px -20px 20px -20px;
                padding: 18px 0 12px 0;
            }
            .purchase-order-headbox h1 {
                font-size: 1.8rem;
            }
        }

        @media (max-width: 480px) {
            body { padding: 10px; }
            .container {
                width: 100%; 
                padding: 15px; 
                border-radius: 0; 
                box-shadow: none; 
                margin: 0 auto; /* Ensure container is centered if body has extra space */
            }

            h1 { font-size: 1.6rem; }
            h2 { font-size: 1.1rem; }
            
            .product { 
                display: grid;
                grid-template-columns: 1fr auto; 
                grid-template-rows: auto auto;    
                grid-template-areas:
                    "name price"
                    "controls controls"; 
                padding: 12px;
                gap: 8px; 
                align-items: center; 
            }
            .product:last-child {
                border-bottom: none;
            }

            .product-name { 
                grid-area: name;
                font-size: 1rem;
                font-weight: 500;
                text-align: left;
                margin-bottom: 0;
            }

            .product-price { 
                grid-area: price;
                justify-self: end; 
                font-size: 0.95rem;
                font-weight: 600;
                color: var(--primary-color); 
                text-align: right; 
                background-color: transparent; 
                border-radius: 0; 
                padding: 0; 
                line-height: 1.2;
                margin-bottom: 0;
            }
            
            .product-controls-mobile {
                grid-area: controls;
                display: flex;
                gap: 10px; 
                width: fit-content; 
                margin: 5px auto 0 auto; 
            }

            .product-controls-mobile .qty-input,
            .product-controls-mobile .add-button { 
                width: 100px;  
                height: 38px; 
                padding: 0 10px; 
                font-size: 0.9rem; 
                display: inline-flex; 
                align-items: center;
                justify-content: center;
                flex-grow: 0; 
                flex-shrink: 0; 
                border-radius: 6px; 
            }
             .product-controls-mobile .qty-input {
                text-align: center; 
                border: 1px solid var(--input-border-color);
                background-color: #fdfdfd;
             }
             .product-controls-mobile .add-button {
                border: 1px solid transparent; 
             }


            .total-amount { font-size: 1.4rem; }
            .order-summary-header .title { font-size: 1.1rem; }
            .order-summary-header .description { font-size: 0.9rem; }

            .cart-table-modern th,
            .cart-table-modern td {
                padding: 12px 10px; 
                font-size: 0.9rem;  
            }
            .cart-table-modern th { 
                font-size: 0.8rem; 
                 white-space: nowrap; 
            } 
            
            .cart-table-modern th:nth-child(1), 
            .cart-table-modern td:nth-child(1) { 
                white-space: normal; 
                text-align: left;   
                min-width: 130px; 
            }

            .cart-table-modern th:not(:first-child), 
            .cart-table-modern td:not(:first-child) {
                text-align: center; 
                white-space: nowrap; 
            }
            .cart-table-modern td:nth-child(2), 
            .cart-table-modern td:nth-child(3)  
             {
                min-width: 55px; 
            }
             .cart-table-modern td:nth-child(4) 
             {
                min-width: 75px; 
                font-weight: 600; 
            }
             .cart-table-modern td:nth-child(5) 
             {
                min-width: 40px; 
            }


            .cart-table-modern .remove-item-btn-modern {
                width: 30px; 
                height: 30px;
                font-size: 1rem;
                padding: 4px; 
            }
            .empty-cart-message i { font-size: 2rem; }
            .empty-cart-message p { font-size: 1rem; }
            .empty-cart-message span { font-size: 0.9rem; }

            #downloadExcelButton{ font-size: 0.95rem; padding: 10px 18px; }
            .toast-container { top: 10px; right: 10px; width: calc(100% - 20px); }
            .toast { min-width: unset; width: 100%;}
        }

        .app-header {
            display: flex;
            justify-content: var(--logo-align); /* left, center, right */
            align-items: center;
            margin-top: var(--logo-margin-top);
            margin-bottom: var(--logo-margin-bottom);
            width: 100%;
            /* Manual horizontal adjustment for logo */
            position: relative;
            left: var(--logo-align-offset);
        }

        #companyLogo {
            width: var(--logo-width);
            height: var(--logo-height);
            max-width: 100%;
            object-fit: contain;
            display: block;
        }

        .purchase-order-headbox {
            width: var(--purchase-order-headbox-width);
            margin-top: var(--purchase-order-headbox-margin-top);
            margin-bottom: var(--purchase-order-headbox-margin-bottom);
            position: relative;
            left: var(--purchase-order-headbox-align-offset-x);
            top: var(--purchase-order-headbox-align-offset-y);
            margin-left: auto;
            margin-right: auto;
            background: var(--primary-color);
            border-radius: 12px 12px 0 0;
            padding: 24px 0 18px 0;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.04);
            position: relative;
        }

        .purchase-order-headbox h1 {
            color: #fff;
            font-size: 2.2rem;
            font-weight: 700;
            margin: 0;
            text-align: center;
            letter-spacing: 0.02em;
        }

        /* Remove margin-bottom from h1 since it's now in the headbox */
        h1 {
            margin-bottom: 0;
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .purchase-order-headbox {
                margin: -20px -20px 20px -20px;
                padding: 18px 0 12px 0;
            }
            .purchase-order-headbox h1 {
                font-size: 1.8rem;
            }
        }

        @media (max-width: 480px) {
            .purchase-order-headbox {
                margin: -15px -15px 15px -15px;
                padding: 14px 0 8px 0;
                /* Only a curved top, upside-down headbox */
                border-radius: 24px 24px 0 0;
            }
            .purchase-order-headbox h1 {
                font-size: 1.4rem;
            }
        }

        /* ===================== MOBILE OVERRIDES ===================== */
@media (max-width: 480px) {
    :root {
        /* LOGO VARIABLES (MOBILE) */
        --logo-width: 175px;         /* Mobile: logo width, change as needed */
        --logo-height: 80px;         /* Mobile: logo height, change as needed */
        --logo-align: center;        /* Mobile: logo alignment */
        --logo-align-offset: -17px;    /* Mobile: horizontal adjustment */

        /* PURCHASE ORDER HEADBOX (MOBILE) */
        --purchase-order-headbox-width: 108%;          /* Mobile: headbox width */
        --purchase-order-headbox-margin-top: 0px;      /* Mobile: top space for headbox */
        --purchase-order-headbox-margin-bottom: 0px;  /* Mobile: bottom space for headbox */
        --purchase-order-headbox-align-offset-x: 0px;  /* Mobile: horizontal movement */
        --purchase-order-headbox-align-offset-y: 16px;  /* Mobile: vertical movement */
    }
}

/* ...existing code... */

.group {
    /* ...existing code... */
    position: relative; /* Needed for sticky child */
}

.group-header {
    /* ...existing code... */
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--secondary-color);
    /* Add subtle shadow when sticky */
    box-shadow: 0 2px 6px rgba(54,182,187,0.04);
}

/* On mobile, ensure sticky works and group-products scrolls */
@media (max-width: 600px) {
    .group.open .group-products {
        max-height: 320px;
        overflow-y: auto;
    }
    .group-header {
        top: 0;
        z-index: 3;
    }
}
