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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    font-size: 14px;
    -webkit-overflow-scrolling: touch;
}

/* Lock page scroll when overlays/modals are open */
html.no-scroll, body.no-scroll { overflow: hidden !important; height: 100%; }

.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 15px;
}

.layout { display: grid; grid-template-columns: 280px 1fr; gap: 12px; }
.layout.sidebar-hidden { grid-template-columns: 0 1fr; }

.sidebar { background: linear-gradient(135deg, #e8f0ff 0%, #f3e8ff 100%); border-radius: 12px; padding: 14px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); transition: transform 0.3s ease; }
.sidebar.hidden { transform: translateX(-100%); }
.sidebar-header { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.header-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.close-sheet-btn { min-width: 36px; height: 36px; display: none; align-items: center; justify-content: center; }
.sidebar-header h1 { margin: 0; font-size: 1.4rem; color: #333; }
.sidebar-toggle { 
    background: #007bff; 
    color: white;
    border: none; 
    border-radius: 6px; 
    padding: 8px 12px; 
    cursor: pointer; 
    font-size: 1rem;
    display: none;
}
.sidebar-toggle:hover { background: #0056b3; }

/* FAB and backdrop for mobile filters */
.filter-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}
.filter-fab:hover { background: #0056b3; }

/* Floating Stats Button */
.stats-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #10b981; /* teal */
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* below sidebar (1100) */
}
.stats-fab:hover { background: #059669; }

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1090;
    display: none;
}

.main { min-width: 0; }

.header { margin-bottom: 12px; color: white; }

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-text {
    text-align: left;
}

.header h1 { font-size: 1.6rem; margin: 0; text-shadow: none; }

.header p {
    font-size: 1rem;
    opacity: 0.9;
}

.import-section { display: flex; align-items: center; gap: 8px; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1500;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Customer Orders Modal should appear above Order Details Modal */
#customerOrdersModal {
    z-index: 1600;
}

/* Prevent background scroll when any modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    overscroll-behavior: none !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Ensure all modals prevent scroll propagation */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    overscroll-behavior-y: none !important;
    overscroll-behavior-x: none !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
}

.modal .modal-content {
    touch-action: pan-y !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Mobile optimization for Customer Orders Modal */
@media (max-width: 768px) {
    
    #customerOrdersModal .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 1600 !important;
    }
    
    #customerOrdersModal .modal-header {
        padding: 15px 20px !important;
        flex-shrink: 0 !important;
    }
    
    #customerOrdersModal .modal-header h3 {
        font-size: 1.1rem !important;
    }
    
    #customerOrdersModal .modal-body {
        padding: 15px 20px !important;
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Optimize customer orders table on mobile */
    .customers-orders-table {
        width: 100% !important;
        table-layout: fixed !important;
        font-size: 0.65rem !important; /* Match common mobile table font size */
        word-wrap: break-word !important;
    }
    
    /* Set specific column widths for mobile */
    .customers-orders-table th:nth-child(1),
    .customers-orders-table td:nth-child(1) { /* Order number */
        width: 25% !important;
        max-width: 25% !important;
        padding: 8px 4px !important;
        word-wrap: break-word !important;
        white-space: normal !important;
    }
    
    .customers-orders-table th:nth-child(2),
    .customers-orders-table td:nth-child(2) { /* Date */
        width: 20% !important;
        max-width: 20% !important;
        padding: 8px 4px !important;
        word-wrap: break-word !important;
        white-space: normal !important;
    }
    
    .customers-orders-table th:nth-child(3),
    .customers-orders-table td:nth-child(3) { /* Total */
        width: 25% !important;
        max-width: 25% !important;
        padding: 8px 4px !important;
        text-align: right;
        word-wrap: break-word !important;
        white-space: normal !important;
    }
    
    .customers-orders-table th:nth-child(4),
    .customers-orders-table td:nth-child(4) { /* Status */
        width: 30% !important;
        max-width: 30% !important;
        padding: 8px 4px !important;
        text-align: center;
        word-wrap: break-word !important;
        white-space: normal !important;
    }
    
    /* Ensure table wrapper doesn't cause horizontal scroll */
    #customerOrdersModal .table-wrapper {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        width: 100% !important;
    }
    
    /* Optimize customer orders content */
    .customer-orders-content {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    /* Make customer info more compact */
    .customer-info {
        font-size: 0.9rem !important;
        padding: 10px !important;
        word-wrap: break-word !important;
    }
    
    .customer-info h4 {
        font-size: 1rem !important;
        margin-bottom: 8px !important;
    }
    
    .customer-info p {
        font-size: 0.8rem !important;
        margin: 4px 0 !important;
        word-wrap: break-word !important;
    }
    
    /* Ensure all text wraps properly */
    .customers-orders-table th,
    .customers-orders-table td {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
    
    /* Prevent modal backdrop from allowing scroll */
    #customerOrdersModal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
    }
    
    /* Ensure modal content captures all scroll events */
    #customerOrdersModal .modal-content {
        touch-action: pan-y !important;
        overscroll-behavior: contain !important;
    }
}

/* Product Orders Modal should appear above all other modals */
#productOrdersModal {
    z-index: 1700;
}

/* Products Page Styles */
.products-page {
    padding: 20px;
    background: #f8f9fa;
    min-height: 100vh;
    position: relative;
    z-index: 1300; /* Above bottom sheet (1100) */
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.products-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

/* Add scroll for products table on desktop */
#productsPage .table-wrapper {
    flex: 1; /* Take remaining space */
    overflow-y: auto;
    min-height: 0; /* Allow flex item to shrink below content size */
}

/* Desktop pagination container - handled by general .pagination-container CSS */

.products-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    min-width: 0; /* Allow shrinking */
    max-width: 100%;
}

.products-actions .search-input {
    padding: 10px 14px;
    min-width: 200px;
    max-width: 400px;
    width: 100%;
    font-size: 0.95rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    height: 36px;
    box-sizing: border-box;
}

.products-actions .btn { 
    height: 36px; 
    display: inline-flex; 
    align-items: center; 
}

#productsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#productsTable th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e9ecef;
}

#productsTable td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

#productsTable tr:hover {
    background: #f8f9fa;
}

.product-row {
    transition: all 0.2s ease;
}

.product-row:hover {
    background: #e3f2fd !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Clickable line item names in order details modal */
.details-table .line-item-name-clickable {
    cursor: pointer !important;
    color: #667eea !important;
    text-decoration: underline !important;
    transition: all 0.2s ease;
    display: inline-block;
}

.details-table .line-item-name-clickable:hover {
    color: #5a67d8 !important;
    text-decoration: none !important;
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Return Customer and Product Tags */
.return-customer-tag,
.return-product-tag {
    display: inline-block;
    font-size: 0.9rem;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.return-customer-tag:hover,
.return-product-tag:hover {
    opacity: 1;
}

/* Product Count Tag */
.product-count-tag {
    display: inline-block;
    font-size: 0.75rem;
    margin-left: 6px;
    padding: 2px 6px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 10px;
    font-weight: 600;
    vertical-align: middle;
    border: 1px solid #bbdefb;
    transition: all 0.2s ease;
}

.product-count-tag:hover {
    background: #bbdefb;
    transform: scale(1.05);
}

/* Tip Amount Tag */
.tip-amount-tag {
    display: inline-block;
    font-size: 0.75rem;
    margin-left: 6px;
    padding: 2px 6px;
    background: #e8f5e8;
    color: #2e7d32;
    border-radius: 10px;
    font-weight: 600;
    vertical-align: middle;
    border: 1px solid #c8e6c9;
    transition: all 0.2s ease;
}

.tip-amount-tag:hover {
    background: #c8e6c9;
    transform: scale(1.05);
}

.customer-name {
    display: inline-block;
    vertical-align: middle;
}

/* Mobile responsiveness for tags */
@media (max-width: 768px) {
    .return-customer-tag,
    .return-product-tag {
        font-size: 0.8rem;
        margin-left: 4px;
    }
    
    .product-count-tag,
    .tip-amount-tag {
        font-size: 0.7rem;
        padding: 1px 4px;
        margin-left: 4px;
    }
}

#productsTable tr:last-child td {
    border-bottom: none;
}

/* Mobile responsiveness for products page */
@media (max-width: 768px) {
    .products-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .products-actions {
        justify-content: space-between;
        max-width: 100%;
        flex: 1 1 auto;
    }
    
    .products-actions .search-input {
        min-width: 120px;
        max-width: 100%;
        flex: 1;
    }
    
    /* Font size and padding now handled by common mobile table CSS above */
}

/* Product Orders Modal Styles */
.product-orders-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.product-orders-header h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.3rem;
}

.product-orders-header p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

.product-stats {
    display: flex;
    gap: 20px;
    margin: 8px 0;
    font-size: 0.9rem;
    color: #495057;
}

.product-stats span {
    font-weight: 500;
}

.product-orders-list {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.product-order-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    transition: box-shadow 0.2s ease;
}

.product-order-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
    gap: 15px;
}

.order-number {
    background: #667eea;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.order-header h5 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.order-date {
    color: #6c757d;
    font-size: 0.85rem;
}

.order-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.order-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-row .label {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.info-row .value {
    color: #212529;
    font-size: 0.9rem;
}

.status-paid {
    color: #28a745;
    font-weight: 600;
}

.status-pending {
    color: #ffc107;
    font-weight: 600;
}

.status-cancelled {
    color: #dc3545;
    font-weight: 600;
}

.line-items h6 {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 0.95rem;
    font-weight: 600;
}

.line-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.line-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    font-size: 0.85rem;
}

.item-name {
    flex: 1;
    font-weight: 500;
    color: #495057;
}

.item-variant {
    color: #6c757d;
    font-size: 0.8rem;
    margin-left: 8px;
}

.item-qty {
    color: #6c757d;
    margin: 0 8px;
    font-weight: 500;
}

.item-price {
    color: #28a745;
    font-weight: 600;
}

/* Mobile responsiveness for product orders modal */
@media (max-width: 768px) {
    .order-details {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .order-header h5 {
        flex: none;
    }
    
    .line-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .item-variant {
        margin-left: 0;
    }
    
    .item-qty,
    .item-price {
        margin: 0;
    }
    
    .product-stats {
        flex-direction: column;
        gap: 8px;
        margin: 6px 0;
    }
}

.modal.show {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.modal-content {
    background: white;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    width: 100%;
    height: 100vh;
    max-height: none;
    overflow-y: auto;
    animation: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem; /* Reduced from 1.3rem */
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 25px;
}

.order-summary .summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px 16px;
}

.order-summary .summary-grid > div {
    display: flex;
    gap: 6px;
}

.order-summary .summary-grid strong {
    min-width: 110px;
    color: #4b5563;
}

/* Order Modal Styles */
.order-modal {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
}

.order-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 32px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}

.order-modal .header-left h3 {
    margin: 0 0 8px 0;
    font-size: 1.5rem;
    color: #1f2937;
}

.order-modal .order-summary {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.4;
}

.order-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.modal-sections {
    display: grid;
    grid-template-columns: 1fr 550px;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.section {
    padding: 20px 24px;
    border-right: 1px solid #f3f4f6;
    overflow-y: auto;
}

.section:last-child {
    border-right: none;
}

.section.right-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.section.right-panel > div {
    padding: 20px 24px;
    border-bottom: 1px solid #f3f4f6;
}

.section.right-panel > div:last-child {
    border-bottom: none;
}

.section-title {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Line Items Table */
.details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.details-table th {
    background: #f9fafb;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.8rem;
}

.details-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}

/* Product name wrapping for order line items */
.details-table td:nth-child(2) { /* Product name column */
    max-width: 200px; /* Limit width */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

/* Mobile optimization for order details table */
@media (max-width: 768px) {
    /* Force fixed table layout to control column widths */
    .details-table {
        table-layout: fixed !important;
        width: 100% !important;
        font-size: 0.65rem !important; /* Match common mobile table font size */
    }
    
    /* Set specific widths for each column on mobile */
    .details-table th:nth-child(1),
    .details-table td:nth-child(1) { /* # column */
        width: 35px !important;
        max-width: 35px !important;
        text-align: center;
        padding: 6px 2px !important;
    }
    
    .details-table th:nth-child(2),
    .details-table td:nth-child(2) { /* Product name column - smaller on mobile */
        width: 120px !important;
        max-width: 120px !important;
        padding: 6px 4px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
        line-height: 1.3 !important;
    }
    
    .details-table th:nth-child(3),
    .details-table td:nth-child(3) { /* Quantity column */
        width: 50px !important;
        max-width: 50px !important;
        text-align: center;
        padding: 6px 2px !important;
    }
    
    .details-table th:nth-child(4),
    .details-table td:nth-child(4) { /* Price column */
        width: 70px !important;
        max-width: 70px !important;
        text-align: right;
        padding: 6px 4px !important;
    }
    
    /* Ensure table wrapper doesn't cause horizontal scroll */
    .details-table .table-wrapper {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}

.details-table tbody tr:hover {
    background: #f9fafb;
}

/* Financial Summary */
.financial-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.financial-summary {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

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

.summary-item .label {
    font-weight: 500;
    color: #4b5563;
}

.summary-item .value {
    font-weight: 600;
    color: #1f2937;
}

.summary-item.tip-item .value {
    color: #059669;
    font-weight: 700;
}

.summary-item.total-item {
    border-top: 2px solid #d1d5db;
    margin-top: 6px;
    padding-top: 8px;
    font-size: 1rem;
}

.summary-item.total-item .value {
    color: #1f2937;
    font-size: 1.1rem;
}

/* Profit Analysis */
.profit-analysis {
    background: #fef7ff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 16px;
}

.profit-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-weight: 500;
    color: #4b5563;
    font-size: 0.8rem;
}

.profit-input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.profit-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.calculated-value {
    padding: 8px 10px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
}

.calculated-value.readonly {
    background: #e5e7eb;
    color: #6b7280;
    cursor: not-allowed;
}

.other-costs {
    margin-bottom: 16px;
}

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

.costs-header label {
    font-weight: 500;
    color: #4b5563;
    font-size: 0.8rem;
}

.btn-add-cost {
    background: #8b5cf6;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-add-cost:hover {
    background: #7c3aed;
}

.cost-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-item {
    display: grid;
    grid-template-columns: 1fr 80px 60px 24px;
    gap: 6px;
    align-items: center;
    padding: 6px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.cost-item input {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.75rem;
}

.cost-type {
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.75rem;
    background: white;
}

.btn-link {
    background: transparent;
    color: #ef4444;
    border: none;
    cursor: pointer;
    padding: 2px;
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-link:hover {
    background: #fef2f2;
}

.profit-result {
    border-top: 2px solid #d1d5db;
    padding-top: 12px;
}

.profit-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 10px 12px;
}

.profit-total .label {
    font-weight: 600;
    color: #166534;
    font-size: 0.9rem;
}

.profit-total .value {
    font-weight: 700;
    color: #166534;
    font-size: 1rem;
}

/* Customer Info */
.customer-info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.customer-info .customer-details {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.customer-info .detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.customer-info .detail-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.customer-info .detail-value {
    font-size: 0.8rem;
    color: #1f2937;
    font-weight: 500;
}

.customer-info .tags {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.customer-info .tag {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin: 1px 2px 1px 0;
}

/* Modal Footer */
.order-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .order-modal {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }
    
    .modal-sections {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto; /* Auto height based on content */
        gap: 0;
    }
    
    /* Remove large gaps between sections on mobile */
    .section {
        margin: 0 !important;
        padding: 16px !important;
    }
    
    /* Ensure sections are properly aligned */
    .section.right-panel {
        margin-top: 0 !important;
        padding-top: 16px !important;
    }
    
    /* Override right-panel padding on mobile to match other sections */
    .section.right-panel > div {
        padding: 0px !important; /* Match the general section padding */
    }
    
    /* Make sure both sections have same width and alignment */
    .section {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Remove any margins that might cause misalignment */
    .section:first-child {
        margin-bottom: 0 !important;
    }
    
    .section:last-child {
        margin-top: 0 !important;
    }
    
    .order-modal .modal-header,
    .section {
        padding: 12px 16px;
    }
    
    /* Fix modal body layout on mobile */
    .order-modal .modal-body {
        padding: 0 !important;
        overflow-y: auto !important;
        flex: 1 !important;
    }
    
    /* Ensure proper spacing between sections */
    .modal-sections {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .profit-inputs {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .customer-info .customer-details {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .cost-item {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .cost-item > * {
        width: 100%;
    }
}

.money-tip {
    color: #16a34a;
    font-weight: 700;
}

.customer-box {
    margin-top: 14px;
    background: #f8f9ff;
    border: 1px solid #eef2ff;
    border-radius: 10px;
    padding: 12px;
}

.customer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}

.customer-grid > div { display: flex; gap: 6px; }

.customer-grid strong { min-width: 90px; color: #4b5563; }

.tags {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 8px;
}

.tag-badge {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #e0e7ff;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 6px;
}

.details-table th, .details-table td {
    padding: 10px 12px;
}

.file-input-section {
    margin-bottom: 25px;
}

.file-input-section input[type="file"] {
    display: none;
}

.file-input-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    border: 2px dashed #667eea;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.file-input-label:hover {
    background: #e8f0ff;
    border-color: #5a6fd8;
}

.file-icon {
    font-size: 1.5rem;
}

.file-text {
    font-weight: 600;
    color: #667eea;
}

.selected-file {
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e8;
    border-radius: 8px;
    color: #2d5a2d;
    font-weight: 500;
    display: none;
}

.selected-file.show {
    display: block;
}

.import-options h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1rem;
}

.import-mode {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    border: 2px solid #f0f0f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.import-mode:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.import-mode input[type="radio"] {
    margin: 0;
    accent-color: #667eea;
    margin-top: 2px;
}

.mode-option {
    display: flex;
    flex-direction: column;
    gap: 5px;
    user-select: none;
}

.mode-option strong {
    color: #333;
    font-size: 1rem;
}

.mode-option small {
    color: #666;
    font-size: 0.85rem;
    line-height: 1.4;
}

.import-mode:has(input:checked) {
    border-color: #667eea;
    background: #f0f4ff;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px 25px;
    border-top: 1px solid #eee;
    background: #fafafa;
    border-radius: 0 0 15px 15px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.import-section .btn { position: relative; min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-animation 2s ease-in-out infinite;
}

@keyframes progress-animation {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

.upload-section {
    display: none;
}

.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #28a745;
    color: white;
}

.btn-secondary:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

/* Status Dialog */
.status-dialog {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    max-width: 400px;
    min-width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow: hidden;
    animation: slideInRight 0.3s ease-out;
}

.status-dialog-content {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}


.status-dialog-close {
    background: rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.status-dialog-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #495057;
    transform: scale(1.1);
}

.status-dialog-body {
    padding: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.status-message {
    margin: 0;
    padding: 0;
    border-radius: 0;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.4;
    flex: 1;
}

/* Dialog background based on status type */
.status-dialog.success .status-dialog-content {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 4px solid #28a745;
}

.status-dialog.error .status-dialog-content {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left: 4px solid #dc3545;
}

.status-dialog.loading .status-dialog-content {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid #2196f3;
}


/* Page Loading Overlay */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease-out;
}

.page-loading-content {
    text-align: center;
    padding: 50px 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.page-loading-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 100%;
    animation: gradientShift 2s ease-in-out infinite;
}

.page-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top: 4px solid #667eea;
    border-right: 4px solid #764ba2;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 24px;
    position: relative;
}

.page-loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 1.5s ease-in-out infinite;
}

.page-loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    letter-spacing: 0.5px;
    position: relative;
}

.page-loading-text::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: #667eea;
    border-radius: 50%;
    margin-left: 4px;
    animation: dots 1.5s infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.7;
    }
}

@keyframes dots {
    0%, 20% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    80%, 100% {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Auto-hide animation */
.status-dialog.hide {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.status-success {
    background: none;
    color: #155724;
    border: none;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-success::before {
    content: '✓';
    font-size: 1.2rem;
    font-weight: bold;
    color: #28a745;
    flex-shrink: 0;
}

.status-error {
    background: none;
    color: #721c24;
    border: none;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-error::before {
    content: '✕';
    font-size: 1.2rem;
    font-weight: bold;
    color: #dc3545;
    flex-shrink: 0;
}

.status-message .loading {
    background: none;
    color: #1976d2;
    border: none;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-message .loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #2196f3;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    grid-template-rows: repeat(2, 1fr);
    gap: 12px; 
    margin-bottom: 15px; 
}

.stat-card { background: white; border-radius: 12px; padding: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); display: flex; align-items: center; transition: transform 0.2s ease; min-height: 60px; }

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

.stat-icon { font-size: 1.3rem; margin-right: 8px; opacity: 0.8; }

.stat-content h3 { font-size: clamp(0.9rem, 2.2vw, 1.05rem); color: #667eea; margin-bottom: 2px; font-weight: 700; line-height: 1.1; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stat-content p { color: #666; font-size: 0.78rem; font-weight: 500; margin: 0; }

.charts-section { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 10px; margin-bottom: 12px; }

.chart-container { background: white; border-radius: 12px; padding: 14px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }

.chart-container h3 {
    margin-bottom: 12px;
    color: #333;
    text-align: center;
    font-size: 1rem;
}

.chart-container canvas {
    max-height: 300px;
}

.tables-section {
    margin-bottom: 20px;
}

.table-container { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); }

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0; /* Allow flex items to shrink */
}
.table-search { 
    margin-left: auto; 
    flex: 1;
    min-width: 0; /* Allow shrinking */
    max-width: 400px; /* Prevent it from taking too much space */
}
.table-search input { 
    padding: 8px 12px; 
    border: 1px solid #ddd; 
    border-radius: 6px; 
    font-size: 0.9rem; 
    min-width: 150px; 
    max-width: 300px;
    width: 100%;
    font-style: italic; 
    box-sizing: border-box;
}

.table-header h3 {
    margin: 0;
    color: #333;
}

.table-info {
    color: #666;
    font-size: 0.9rem;
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 0.9rem;
}

.pagination-info select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 5px;
}

.page-numbers {
    display: flex;
    gap: 5px;
    margin: 0 10px;
}

.page-number {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: center;
}

.page-number:hover {
    background: #f8f9ff;
    border-color: #667eea;
}

.page-number.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.page-number.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 40px;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.table-wrapper {
    overflow: auto;
    max-height: 520px; /* fixed height for ordersTable container */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td { padding: 10px; text-align: left; border-bottom: 1px solid #eee; font-size: 0.92rem; }

th {
    background: #f8f9ff;
    font-weight: 600;
    color: #333;
}

tr:hover {
    background: #f8f9ff;
}

.filters-section { 
    background: white; 
    border-radius: 16px; 
    padding: 20px; 
    box-shadow: 0 8px 25px rgba(0,0,0,0.1); 
    margin-bottom: 20px;
    border: 1px solid #f0f4ff;
}

.filters-section h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.filters { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 20px; 
    align-items: end; 
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.filter-group label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filters select,
.filters input { 
    padding: 14px 16px; 
    border: 2px solid #e2e8f0; 
    border-radius: 12px; 
    font-size: 1rem; 
    width: 100%; 
    background: #fafbfc;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #2d3748;
    min-height: 48px;
}

.filters select:hover,
.filters input:hover {
    border-color: #cbd5e0;
    background: #f7fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.filters select:focus,
.filters input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1), 0 8px 25px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.filters select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    padding-right: 50px;
}

.filters input[type="date"] {
    cursor: pointer;
}

.filters input[type="date"]::-webkit-calendar-picker-indicator {
    background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3e%3c/rect%3e%3cline x1='16' y1='2' x2='16' y2='6'%3e%3c/line%3e%3cline x1='8' y1='2' x2='8' y2='6'%3e%3c/line%3e%3cline x1='3' y1='10' x2='21' y2='10'%3e%3c/line%3e%3c/svg%3e") no-repeat center;
    background-size: 20px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .header-text {
        text-align: center;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .import-section {
        align-items: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 1fr); /* Show all 8 cards in 4 rows */
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
        min-height: 56px;
    }
    
    .stat-icon {
        font-size: 1.2rem;
        margin-right: 8px;
    }
    
    .stat-content h3 {
        font-size: clamp(0.9rem, 4.2vw, 1rem);
    }
    
    .stat-content p {
        font-size: 0.8rem;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .chart-container {
        padding: 15px;
    }
    
    .chart-container canvas {
        max-height: 250px;
    }
    
    .filters {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filters select,
    .filters input {
        padding: 10px;
    }
    
    .table-container {
        padding: 15px;
    }
    
    /* Make table search responsive on mobile */
    .table-search {
        max-width: 100%;
        flex: 1 1 auto;
    }
    
    .table-search input {
        min-width: 100px;
        max-width: 100%;
        font-size: 0.85rem;
    }
    
    /* Make customers actions responsive on mobile */
    .customers-actions {
        max-width: 100%;
        flex: 1 1 auto;
    }
    
    .customers-actions .search-input {
        min-width: 120px;
        max-width: 100%;
        font-size: 0.9rem;
    }
    
    .filters-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .filters-section h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .filters {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .filter-group label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }
    
    .filters select,
    .filters input {
        padding: 12px 14px;
        font-size: 0.95rem;
        min-height: 44px;
    }

    /* Mobile responsive tables - show all columns with horizontal scroll */
    
    /* Orders table - show all columns with horizontal scroll */
    #ordersTable {
        width: 100% !important;
        table-layout: auto !important; /* Allow natural column sizing */
        min-width: 800px !important; /* Ensure minimum width for all columns */
    }
    
    /* Use native table layout; JS will reorder columns on mobile */
    
    /* Enable horizontal scroll for orders table wrapper on mobile */
    .table-wrapper {
        overflow-x: auto !important; /* Enable horizontal scroll */
        overflow-y: auto !important; /* Keep vertical scroll */
        -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
        touch-action: pan-x pan-y !important; /* Allow finger horizontal panning */
    }
    
    /* Disable table dragging on mobile but allow horizontal scroll */
    #ordersTable {
        touch-action: auto !important; /* Allow horizontal and vertical panning */
        -webkit-touch-callout: none !important; /* Disable callout on iOS */
        -webkit-user-select: none !important; /* Disable text selection */
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }
    
    /* Allow text selection for clickable elements only */
    #ordersTable .clickable {
        -webkit-user-select: text !important;
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        user-select: text !important;
    }
    
    /* Customers table - show all columns with horizontal scroll */
    #customersTable {
        width: 100% !important;
        table-layout: auto !important; /* Allow natural column sizing */
        min-width: 600px !important; /* Ensure minimum width for all columns */
    }
    
    /* Products table - show all columns with horizontal scroll */
    #productsTable {
        width: 100% !important;
        table-layout: auto !important; /* Allow natural column sizing */
        min-width: 500px !important; /* Ensure minimum width for all columns */
    }
    
    /* Mobile-specific adjustments for customers and products pages - Fixed header/footer pattern */
    #customersPage,
    #productsPage {
        height: 100vh; /* Full viewport height like orderDetailsModal */
        max-height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0; /* Remove padding to maximize space */
        overflow-x: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Fixed header like modal-header */
    #customersPage .customers-header,
    #productsPage .products-header {
        flex-shrink: 0; /* Prevent shrinking like modal-header */
        padding: 16px 20px; /* Similar to modal-header padding */
        background: #fafafa; /* Same background as modal-header */
        border-bottom: 1px solid #e5e7eb; /* Same border as modal-header */
        box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Subtle shadow */
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    /* Table wrapper like modal-body */
    #customersPage .table-wrapper,
    #productsPage .table-wrapper {
        flex: 1; /* Take remaining space like modal-body */
        overflow-y: auto; /* Allow scrolling like modal-body */
        min-height: 0; /* Allow flex item to shrink */
        padding: 0; /* No padding like modal-body */
        margin: 0; /* Remove margin to maximize space */
    }
    
    /* Fixed footer like modal-footer */
    #customersPage .pagination-container,
    #productsPage .pagination-container {
        flex-shrink: 0; /* Prevent shrinking like modal-footer */
        padding: 16px 20px; /* Similar to modal-footer padding */
        background: #fafafa; /* Same background as modal-footer */
        border-top: 1px solid #e5e7eb; /* Same border as modal-footer */
        position: sticky;
        bottom: 0;
        z-index: 10;
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        box-shadow: 0 -2px 4px rgba(0,0,0,0.1); /* Subtle shadow */
        margin: 0; /* Remove margin to maximize space */
    }
    
    /* Ensure pagination is always visible on mobile */
    #customersPage .pagination,
    #productsPage .pagination {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Mobile pagination info adjustments */
    #customersPage .pagination-info,
    #productsPage .pagination-info {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    /* Pagination container sizing now handled by fixed footer CSS above */
    
    /* Mobile table optimizations - Common styles for all tables */
    table {
        font-size: 0.65rem !important; /* Even smaller font for mobile */
    }
    
    /* Specific mobile table font sizes */
    #ordersTable,
    #customersTable, 
    #productsTable {
        font-size: 0.65rem !important;
    }
    
    table th, table td {
        padding: 6px 4px !important; /* Smaller padding for mobile */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Prevent horizontal scrolling and dragging on mobile tables */
    #customersPage .table-wrapper,
    #productsPage .table-wrapper {
        overflow-x: auto !important; /* Enable horizontal scroll */
        overflow-y: auto !important; /* Only allow vertical scroll */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    /* Disable touch dragging for table content */
    #customersTable,
    #productsTable {
        touch-action: pan-y !important; /* Only allow vertical panning */
        -webkit-touch-callout: none; /* Disable callout on iOS */
        -webkit-user-select: none; /* Disable text selection */
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection for clickable elements only */
    #customersTable .clickable,
    #productsTable .clickable {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
    
    /* Table cells styling for better horizontal scroll experience */
    #ordersTable th,
    #ordersTable td {
        white-space: nowrap !important; /* Prevent wrapping; use horizontal scroll */
        padding: 8px 12px !important;
        box-sizing: border-box !important;
        overflow: visible !important; /* Show full content */
        text-overflow: initial !important; /* No ellipsis */
        width: max-content !important; /* Fit to content width */
        max-width: none !important;
        flex: 0 0 auto !important; /* Let cells size to content in flex rows */
    }
    
    #customersTable th,
    #customersTable td,
    #productsTable th,
    #productsTable td {
        white-space: nowrap !important; /* Prevent text wrapping for better horizontal scroll */
        padding: 8px 12px !important; /* Adequate padding for readability */
    }
    
    
    /* Mobile pagination adjustments */
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .pagination .btn {
        min-width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    
    .page-numbers {
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
    }
    
    .page-numbers .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
        padding: 4px 6px;
    }
}

/* Customers Page */
.customers-page { 
    background: white; 
    border-radius: 12px; 
    padding: 16px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    position: relative;
    z-index: 1300; /* Above bottom sheet (1100) */
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}
.customers-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 10px; 
    margin-bottom: 12px; 
    flex-wrap: wrap;
    flex-shrink: 0; /* Prevent header from shrinking */
}
.customers-actions { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    flex: 1;
    min-width: 0; /* Allow shrinking */
    max-width: 100%;
}
.customers-actions .search-input { 
    padding: 10px 14px; 
    min-width: 200px; 
    max-width: 400px;
    width: 100%;
    font-size: 0.95rem; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    height: 36px; 
    box-sizing: border-box;
}
.customers-actions .btn { height: 36px; display: inline-flex; align-items: center; }
.customers-table { width: 100%; border-collapse: collapse; }
.customers-table th, .customers-table td { padding: 10px; border-bottom: 1px solid #eee; text-align: left; font-size: 0.9rem; vertical-align: top; }
.customers-table th:first-child, .customers-table td:first-child { width: 48px; color: #666; }

/* Add scroll for customers table on desktop */
#customersPage .table-wrapper {
    flex: 1; /* Take remaining space */
    overflow-y: auto;
    min-height: 0; /* Allow flex item to shrink below content size */
}

/* Desktop pagination container - handled by general .pagination-container CSS */
.customers-modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.customers-modal-section { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.customers-modal-section h5 { margin: 0 0 8px 0; font-size: 1rem; color: #333; }
.customers-orders-table { width: 100%; border-collapse: collapse; }
.customers-orders-table th, .customers-orders-table td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: left; font-size: 0.85rem; }
.customers-orders-table th { background: #f9fafb; font-weight: 600; }
@media (max-width: 768px) { 
    .customers-modal-grid { grid-template-columns: 1fr; } 
    
    .customers-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .customers-actions {
        justify-content: space-between;
        max-width: 100%;
        flex: 1 1 auto;
    }
    
    .customers-actions .search-input {
        min-width: 120px;
        max-width: 100%;
        flex: 1;
    }
    
    /* Status Dialog Mobile */
    .status-dialog {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        min-width: auto;
    }
    
    .status-dialog-header {
        padding: 12px 16px;
    }
    
    .status-dialog-body {
        padding: 16px;
    }
    
    /* Page Loading Mobile */
    .page-loading-content {
        padding: 40px 30px;
        margin: 20px;
        border-radius: 20px;
    }
    
    .page-loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 3px;
    }
    
    .page-loading-spinner::after {
        width: 16px;
        height: 16px;
    }
    
    .page-loading-text {
        font-size: 1.1rem;
    }
}
.customers-table th { background: #f8f9ff; font-weight: 600; color: #333; }
.customers-table td .address-cell { color: #4f46e5; text-decoration: underline; cursor: pointer; }

@media (max-width: 768px) {
    .customer-meta { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .stat-card {
        padding: 12px;
        min-height: 60px;
    }
    
    .stat-icon {
        font-size: 1.3rem;
        margin-right: 10px;
    }
    
    .stat-content h3 {
        font-size: 1.2rem;
    }
}

/* Mobile Sidebar Toggle */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 0;
    }
    /* Bottom sheet behavior - Full screen with auto scroll */
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: 100vw;
        transform: translateY(100%);
        border-radius: 0;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
        z-index: 1100;
        overflow-y: auto;
        overflow-x: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar.show { transform: translateY(0); }
    
    /* Add padding to sidebar content to prevent overlap with status bar */
    .sidebar {
        padding-top: 20px;
        padding-bottom: 20px;
    }
    .sidebar-toggle { display: none; }
    .filter-fab { display: inline-flex; }
    .stats-fab { display: inline-flex; }
    .sheet-backdrop.show { display: block; }
    .close-sheet-btn { display: flex; }
    .main { width: 100%; }
}

/* Stats Page Overlay */
.stats-page {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #e8f0ff 0%, #f3e8ff 100%);
    z-index: 1050; /* ensure below sidebar (1100) */
    display: none;
    overflow: hidden;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
}

.stats-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f0f4ff 0%, #f8f0ff 100%);
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-page-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.stats-page-content {
    padding: 12px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

/* Eye toggle on stat cards */
.stat-card {
    position: relative;
}
.stat-visibility-toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: #ffffffcc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
}
.stat-visibility-toggle:hover { background: #f3f4f6; }
.stat-visibility-toggle.hidden { color: #9ca3af; opacity: 0.7; }

/* Home selected stats container (mobile) */
.home-stats { margin-bottom: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .home-stats { grid-template-columns: 1fr; } }
